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

GHC ghc-devs at haskell.org
Wed Nov 18 14:13:57 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)                          |
      Resolution:                    |             Keywords:
Operating System:  Windows           |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  Runtime crash     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Matt):

 > I'm not sure what you mean by "not officially supported". Specifying
 .lib files + DLL files has always been the standard way to use FFI for
 third party libraries on Windows.

 In `compiler/ghci/Linker.hs` in function `locateLib` you can see line
 {{{arch_file = "lib" ++ lib ++ lib_tag <.> "a"}}}. This is how static
 archive name which will GHCi attempt to load is constructed.

 When you for example try to link against foo by `ghc -libfoo ...` that
 option is passed to GCC as GCC is used for linking everything together
 into final executable or DLL, and GCC can usually link against `.lib`
 files, unless you try to link against C++ mangled function names of
 course.

 But when you invoke `ghci -lfoo ....` now GHCi-s internal linker is used
 for linking, and he resolves external libraries a bit differently, as you
 can see in `locateLib` funtion. First it tries to load `foo.dll` and
 `libfoo.dll`. If that fails it resorts to loading of static archive
 followed by some more logic after that.

 However, important distinction between GHCi linker and GCCs linker on
 Windows is that GHCi can't resolve DLL name from import library. as
 explained in description of this ticked.This  only becomes apparent when
 DLL name is different than import library name (which is the case with
 almost all libraries that come with MSYS2).

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


More information about the ghc-tickets mailing list