linker fails to load package with binding to foreign library
GHCI is unable to load 'network' package on Windows. The versions:
$ ghci --version
The Glorious Glasgow Haskell Compilation System, version 7.4.2
$ ghc-pkg list network
c:/mnt/data1/ghc32b\lib\package.conf.d:
network-2.3.0.14
The test code:
import Network
main = withSocketsDo $ do listenOn (PortNumber 3333) -- >>= accept
The failure:
> ghci winsock-load-failure.hs
GHCi, version 7.4.2: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main ( winsock-crash.hs, interpreted )
Ok, modules loaded: Main.
*Main> main
Loading package bytestring-0.9.2.1 ... linking ... done.
Loading package transformers-0.3.0.0 ... linking ... done.
Loading package mtl-2.1.2 ... linking ... done.
Loading package array-0.4.0.0 ... linking ... done.
Loading package deepseq-1.3.0.0 ... linking ... done.
Loading package text-0.11.2.2 ... linking ... done.
Loading package parsec-3.1.3 ... linking ... done.
Loading package network-2.3.0.14 ... linking ... <interactive>: C:\mnt\data1\ghc32b\network-2.3.0.14\ghc-7.4.2\HSnetwork-2.3.0.14.o: unknown symbol `__imp__WSACleanup'
ghc.exe: unable to load package `network-2.3.0.14'
The load trace log ('+RTS -Dl'):
[...snip...]
lookupSymbol: looking up __imp__WSACleanup@0
initLinker: start
initLinker: idempotent return
lookupSymbol: symbol not found
<interactive>: C:\mnt\data1\ghc32b\network-2.3.0.14\ghc-7.4.2\HSnetwork-2.3.0.14.o: unknown symbol `__imp__WSACleanup'
[...snip...]
The symbol to be resolved:
$ nm network-2.3.0.14/ghc-7.4.2/HSnetwork-2.3.0.14.o |grep WSACleanup
U __imp__WSACleanup@0
The actual symbol in the foreign library:
$ objdump -p /c/Windows/System32/ws2_32.dll
c:/Windows/System32/ws2_32.dll: file format pei-i386
[...snip...]
[Ordinal/Name Pointer] Table
[...snip...]
[ 115] WSACleanup
[...snip...]
The test snippet only works when compiled by ghc (so the resulting binary is produced by ld.bfd).
Trac metadata
Trac field | Value |
---|---|
Version | 7.4.2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Runtime System |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |