[GHC] #13431: Linker error related to atan and ntdll on 32-bit Windows
GHC
ghc-devs at haskell.org
Thu Mar 16 14:05:06 UTC 2017
#13431: Linker error related to atan and ntdll on 32-bit Windows
-------------------------------------+-------------------------------------
Reporter: RyanGlScott | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
Keywords: | Operating System: Windows
Architecture: x86 | Type of failure: GHC rejects
| valid program
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
That's a somewhat confusing title, so let me explain in more detail what I
mean.
I first noticed this issue when someone [https://github.com/idris-lang
/Idris-dev/pull/3684 couldn't build Idris] on 32-bit Windows (using GHC
7.8, 7.10, or 8.0). Trying to link the Idris executable resulted in this
cryptic linker error:
{{{
Preprocessing executable 'idris' for idris-0.99.1...
[1 of 1] Compiling Main ( main\Main.hs, dist\build\idris
\idris-tmp\Main.o )
Linking dist\build\idris\idris.exe ...
C:/Users/RyanGlScott/Software/ghc-8.0.1-x86/mingw/bin/../lib/gcc/i686-w64-mingw32/5.2.0/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a(dohds01059.o):(.idata$5+0x0):
multiple definition of `_imp__atan'
C:/Users/RyanGlScott/Software/ghc-8.0.1-x86/mingw/bin/../lib/gcc/i686-w64-mingw32/5.2.0/../../../../i686-w64-mingw32/lib/../lib/libntdll.a(dgjjs01967.o):(.idata$5+0x0):
first defined here
collect2.exe: error: ld returned 1 exit status
`gcc.exe' failed in phase `Linker'. (Exit code: 1)
}}}
The culprit was apparently Idris's dependency on the `mintty` package. The
important bit was that `mintty` lists `ntdll` as in the `extra-libraries`
stanza of its `.cabal` file. As it turns out, you can also reproduce this
with a more recent version of `Win32`, which also depends on `ntdll`.
First, run these steps:
{{{
$ cabal get Win32
$ cd Win32-2.5.2.0/
$ cabal sandbox init
$ cabal install . -w $(pwd)/../../../../Software/ghc-8.0.1-x86/bin/ghc
}}}
This will install the recent `Win32-2.5.2.0` in a sandbox (NB: I'm using
32-bit Windows GHC 8.0.1 here). Now create this file (which I named
`Bug.hs`):
{{{
module Main (main) where
main :: IO ()
main = print (atan 0.5 :: Double)
}}}
And you can reproduce the linker error like so:
{{{
$ ../../../../Software/ghc-8.0.1-x86/bin/ghc Bug.hs -package-db .cabal-
sandbox/i386-windows-ghc-8.0.1-packages.conf.d/ -package Win32 -fforce-
recomp
[1 of 1] Compiling Main ( Bug.hs, Bug.o )
Linking Bug.exe ...
C:/Users/RyanGlScott/Software/ghc-8.0.1-x86/mingw/bin/../lib/gcc/i686-w64-mingw32/5.2.0/../../../../i686-w64-mingw32/lib/../lib/libmsvcrt.a(dohds01059.o):(.idata$5+0x0):
multiple definition of `_imp__atan'
C:/Users/RyanGlScott/Software/ghc-8.0.1-x86/mingw/bin/../lib/gcc/i686-w64-mingw32/5.2.0/../../../../i686-w64-mingw32/lib/../lib/libntdll.a(dgjjs01967.o):(.idata$5+0x0):
first defined here
collect2.exe: error: ld returned 1 exit status
`gcc.exe' failed in phase `Linker'. (Exit code: 1)
}}}
It's important to use 32-bit Windows GHC here, since I am unable to
reproduce this with 64-bit Windows GHC.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13431>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list