[GHC] #12209: Windows: ByteCodeLink can't find labels "lseek" and "write"

GHC ghc-devs at haskell.org
Fri Jul 8 18:45:05 UTC 2016


#12209: Windows: ByteCodeLink can't find labels "lseek" and "write"
-------------------------------------+-------------------------------------
        Reporter:  thomie            |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Runtime System    |              Version:  8.0.1
  (Linker)                           |
      Resolution:                    |             Keywords:
Operating System:  Windows           |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Phyx-):

 `lseek` and `write` existed before Microsoft deprecated the POSIX
 functions. As such, they did used to exist https://msdn.microsoft.com/en-
 us/library/ms235323.aspx

 During `WAY=ghci` we query `msvcrt.dll` directly which is the C runtime.
 The function has been deprecated long enough that it's been removed.

 {{{
 e:\temp\dynamic>dumpbin /exports c:\Windows\System32\msvcrt.dll | findstr
 lseek
         496  1EF 0001D080 _lseek = _lseek
         497  1F0 0001D230 _lseeki64 = _lseeki64

 e:\temp\dynamic>dumpbin /exports c:\Windows\System32\msvcrt.dll | findstr
 write
         998  3E5 0001FA20 _write = _write
        1113  458 0004DB90 fwrite = fwrite
 }}}

 During linking, `Mingw-w64` ends up linking against the import library
 `msvcrt.a` which contains a redirect from `lseek` to `_lseek`. Probably
 for backwards compatibility.

 {{{
 $ nm -s "inplace\mingw\x86_64-w64-mingw32\lib\libmsvcrt.a" | grep lseek
 _lseeki64 in dcnfs00450.o
 __imp__lseeki64 in dcnfs00450.o
 _lseek in dcnfs00449.o
 __imp__lseek in dcnfs00449.o
 lseek in dcnfs00448.o
 __imp_lseek in dcnfs00448.o
 0000000000000000 I __imp__lseeki64
 0000000000000000 T _lseeki64
 0000000000000000 I __imp__lseek
 0000000000000000 T _lseek
 0000000000000000 I __imp_lseek
 0000000000000000 T lseek
 }}}

 So the correct solution would be to use the `_` versions.

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


More information about the ghc-tickets mailing list