[GHC] #9215: GHC 7.8.2 mingw-w64: symbol not found in link

GHC ghc-devs at haskell.org
Wed Jan 20 09:57:25 UTC 2016


#9215: GHC 7.8.2 mingw-w64: symbol not found in link
-------------------------------------+-------------------------------------
        Reporter:  stuartallenmills  |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.8.2
      Resolution:                    |             Keywords:
Operating System:  Windows           |         Architecture:  x86_64
                                     |  (amd64)
 Type of failure:  Other             |            Test Case:
      Blocked By:  9218              |             Blocking:
 Related Tickets:  #9218             |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Phyx-):

 I have just removed all the special cases from the linker in Phab:D1805
 which means GHCi will *probably* not load this library anymore either...
 If it ever did..

 I also think that their patch only fixes 64bit compilation but not 32bit.

 The prefixed _ has nothing to do with the usual name mangling of
 functions. Instead it was a conscious choice by Microsoft to deprecate the
 functions that are not part of the C standard (`strdup` is `POSIX`, not
 `C`, and the Microsoft POSIX Subsystem was never fully POSIX compliant
 afaik, SUA was but that's now deprecated.) into a different namespace
 following the C++ ISO naming convention. https://msdn.microsoft.com/en-
 us/subscriptions/7e259932-c6c8-4c1a-9637-639e591681a5(v=vs.90) in order to
 free up the namespace to user defined functions.

 As in, on Windows `strdup` should always be used as `_strdup` regardless
 if it's 32 or 64bit.

 And indeed, if you look at the export table of the standard C runtime on
 Windows (msvcrt) which both GHCi and MingW-w64 link to:

 {{{
 >dumpbin /exports c:\Windows\SysWOW64\msvcrt.dll | findstr "strdup"
         859  35A 000247AD _strdup
         860  35B 000801D6 _strdup_dbg

 >dumpbin /exports c:\Windows\System32\msvcrt.dll | findstr "strdup"
         742  2E5 000152D0 _strdup
         743  2E6 0006635C _strdup_dbg
 }}}

 Both the 32bit and the 64bit version report only the undeprecated
 function, always with the _ prefix.

 So this is not a GHC bug, nor a Windows one. The library just did not use
 the correct function as stated on MSDN.

 The correct fix would probably be

 {{{
 #if _WIN32
 #define STRDUP _strdup
 #else
 #define STRDUP strdup
 #endif
 }}}

 Because it will always be the case on Windows.

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


More information about the ghc-tickets mailing list