[GHC] #11072: Runtime linker doesn't search for DLLs referenced in import libraries on Windows

GHC ghc-devs at haskell.org
Sun Nov 8 21:02:12 UTC 2015


#11072: Runtime linker doesn't search for DLLs referenced in import libraries on
Windows
-------------------------------------+-------------------------------------
           Reporter:  RyanGlScott    |             Owner:  Phyx-
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:  8.0.1
          Component:  Compiler       |           Version:  7.10.2-rc2
  (Linking)                          |
           Keywords:                 |  Operating System:  Windows
       Architecture:                 |   Type of failure:  Runtime crash
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 (This is adapted from the comments [https://github.com/bos/text-
 icu/issues/12#issuecomment-154452774 here].)

 On Windows, the GHC runtime linker only searches for DLLs that have the
 same names as the import libraries passed to `-l`. This can sometimes
 create problems, since a library name could be different from the DLL it
 needs.

 `text-icu` provides an example of this, since it needs the extra libraries
 `icuuc`, `icudt`, and `icuin`. However, if you download the [http://site
 .icu-project.org/download/56#TOC-ICU4C-Download official ICU 56 binaries],
 they are distributed with DLLs named `icuuc56.dll`, `icudt56.dll`, and
 `icuin56.dll`, rather than `icuuc.dll`, `icudt.dll`, and `icuin.dll`.

 This doesn't create any trouble for the linker at compile-time. In fact,
 if you compile this program

 {{{#!hs
 -- TextICU.hs
 import Data.Text.ICU.Break

 main = print Kana
 }}}

 with `ghc TextICU.hs` and then run `cygcheck ./TextICU.hs` without having
 the ICU4C `bin64` folder in your `PATH`, it ''appears'' to search for the
 right DLLs:

 {{{
 $ cygcheck ./TextICU.hs
 ...
 cygcheck: track_down: could not find icuin56.dll

 cygcheck: track_down: could not find icuuc56.dll
 }}}

 But actually running the code reveals a different story:

 {{{
 $ runghc TextICU.hs
 TextICU.hs: icuuc: The specified module could not be found.
 TextICU.hs: <command line>: can't load .so/.DLL for: icuuc.dll (addDLL:
 could not load DLL)
 }}}

 This demonstrates that the runtime linker behaves differently; it is
 dependent on what the linked libraries' names are. To confirm this, you
 can recompile `text-icu` with the following changes to `text-icu.cabal`:

 {{{
 extra-libraries: icuuc56
 if os(mingw32)
   extra-libraries: icuin56 icudt56
 }}}

 Also make symlinks named `icuuc56.lib`, `icuin56.lib`, and `icudt56.lib`
 that refer to `icuuc.lib`, `icuin.lib`, and `licudt.lib`, respectively, in
 the ICU4C `lib64` directory. Now `cygcheck` and `ghc` agree on which DLLs
 to use:

 {{{
 $ ghc TextICU.hs
 $ cygcheck ./TextICU.exe
 ...
 cygcheck: track_down: could not find icuin56.dll

 cygcheck: track_down: could not find icuuc56.dll
 $ runghc TextICU.hs
 TextICU.hs: icuuc56: The specified module could not be found.
 TextICU.hs: <command line>: can't load .so/.DLL for: icuuc56.dll (addDLL:
 could not load DLL)
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11072>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list