[GHC] #13093: Runtime linker chokes on LLVM function on Windows
GHC
ghc-devs at haskell.org
Tue Jan 10 02:24:34 UTC 2017
#13093: Runtime linker chokes on LLVM function on Windows
-------------------------------------+-------------------------------------
Reporter: RyanGlScott | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 8.2.1
Component: Runtime | Version: 8.0.1
System (Linker) |
Keywords: | Operating System: Windows
Architecture: | Type of failure: GHCi crash
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
This error prevents the [http://hackage.haskell.org/package/llvm-general
llvm-general] library from loading in GHCi on Windows. I don't know how to
reproduce this error without using LLVM.
First, you need to install LLVM. On Windows, you can install it with
MSYS2:
{{{
pacman -S mingw-w64-x86_64-llvm
}}}
Currently, this gives you LLVM-3.9, although I've reproduced it with
LLVM-3.8 as well.
Now define this Haskell file:
{{{#!hs
module Main (main) where
import Foreign.C.Types
newtype LLVMBool = LLVMBool CUInt deriving Show
foreign import ccall unsafe "LLVMIsMultithreaded"
isMultithreaded :: IO LLVMBool
main :: IO ()
main = isMultithreaded >>= print
}}}
If you compile it, it works OK:
{{{
$ ghc LLVM.hs -fforce-recomp $(llvm-config --libs) $(llvm-config --system-
libs) -lstdc++-6 -lgcc_s_seh-1
[1 of 1] Compiling Main ( LLVM.hs, LLVM.o )
Linking LLVM.exe ...
$ ./LLVM
LLVMBool 1
}}}
Or, if you're allergic to `llvm-config`:
{{{
$ ghc LLVM.hs -fforce-recomp -lLLVMLTO -lLLVMObjCARCOpts -lLLVMSymbolize
-lLLVMDebugInfoPDB -lLLVMDebugInfoDWARF -lLLVMGlobalISel -lLLVMCoverage
-lLLVMTableGen -lLLVMLineEditor -lLLVMOrcJIT -lLLVMMIRParser
-lLLVMARMDisassembler -lLLVMARMCodeGen -lLLVMARMAsmParser -lLLVMARMDesc
-lLLVMARMInfo -lLLVMARMAsmPrinter -lLLVMObjectYAML -lLLVMLibDriver
-lLLVMOption -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen
-lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoCodeView -lLLVMX86Desc
-lLLVMMCDisassembler -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils
-lLLVMMCJIT -lLLVMPasses -lLLVMipo -lLLVMVectorize -lLLVMLinker
-lLLVMIRReader -lLLVMAsmParser -lLLVMInterpreter -lLLVMExecutionEngine
-lLLVMRuntimeDyld -lLLVMObject -lLLVMMCParser -lLLVMCodeGen -lLLVMTarget
-lLLVMScalarOpts -lLLVMInstCombine -lLLVMInstrumentation
-lLLVMTransformUtils -lLLVMMC -lLLVMBitWriter -lLLVMBitReader
-lLLVMAnalysis -lLLVMProfileData -lLLVMCore -lLLVMSupport -lpsapi
-lshell32 -lole32 -luuid -lstdc++-6 -lgcc_s_seh-1
[1 of 1] Compiling Main ( LLVM.hs, LLVM.o )
Linking LLVM.exe ...
$ ./LLVM
LLVMBool 1
}}}
If you load it into GHCi, however, things go awry:
{{{
$ ghci $(llvm-config --libs) $(llvm-config --system-libs) -lgcc_s_seh-1
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from
C:\Users\RyanGlScott\AppData\Roaming\ghc\ghci.conf
Ok, modules loaded: Main (LLVM.o).
> main
ghc.exe: LLVM.o: unknown symbol `LLVMIsMultithreaded'
}}}
On GHC 8.0.1 and HEAD, it's a slightly different error:
{{{
> main
ByteCodeLink: can't find label
During interactive linking, GHCi couldn't find the following symbol:
LLVMIsMultithreaded
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session. Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please send a bug report to:
glasgow-haskell-bugs at haskell.org
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13093>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list