Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default to enable-shared for ghc 7.8 #85

Open
cartazio opened this issue Feb 1, 2014 · 5 comments
Open

default to enable-shared for ghc 7.8 #85

cartazio opened this issue Feb 1, 2014 · 5 comments

Comments

@cartazio
Copy link
Contributor

cartazio commented Feb 1, 2014

[2014-01-31T00:13:09-0500] <enthropy> carter: you report it. Also I have a /usr/bin/ld: dist/build/LLVM/General/Internal/FFI/InstructionDefs.dyn_o: relocation R_X86_64_PC32 against undefined symbol `llvmzmgeneralzm3zi3zi8zi2_LLVMziGeneralziInternalziFFIziLLVMCTypes_zdfShowCPPOpcode_closure' can not be used when making a shared object; recompile with -fPIC

linker errors happen in ghci / etc unless llvm-general is built with -fenable-shared on my machine

eg

Prelude> import LLVM.General as LG
Prelude LG> LG.
LG.Module                LG.moduleObject          LG.writeAssemblyToFile
LG.linkModules           LG.moduleString          LG.writeBitcodeToFile
LG.moduleAST             LG.withModuleFromAST     LG.writeObjectToFile
LG.moduleAssembly        LG.withModuleFromString
Prelude LG> let f x = LG.linkModules  x
Loading package transformers-0.3.0.0 ... linking ... done.
Loading package pretty-1.1.1.1 ... linking ... done.
Loading package array-0.5.0.0 ... linking ... done.
Loading package deepseq-1.3.0.2 ... linking ... done.
Loading package containers-0.5.4.0 ... linking ... done.
Loading package bytestring-0.10.4.0 ... linking ... done.
Loading package mtl-2.1.2 ... linking ... done.
Loading package text-1.1.0.0 ... linking ... done.
Loading package parsec-3.1.5 ... linking ... done.
Loading package old-locale-1.0.0.6 ... linking ... done.
Loading package time-1.4.1 ... linking ... done.
Loading package unix-2.7.0.0 ... linking ... done.
Loading package setenv-0.1.1 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package llvm-general-pure-3.3.8.2 ... linking ... done.
Loading package utf8-string-0.3.7 ... linking ... done.
Loading package llvm-general-3.3.8.2 ... linking ... <interactive>: 
lookupSymbol failed in relocateSection (RELOC_GOT)
/usr/local/Cellar/llvm33/3.3/lib/llvm-3.3/lib/libLLVMSupport.a: unknown symbol `___dso_handle'
ghc: unable to load package `llvm-general-3.3.8.2'

if I build with enable-shared, I can use llvm-general in ghci pretty easily!
such as the following thing where I used clang to emit llvm asm, parsed it in with llvm, converted the module from LLVM's module model to llvm-generals, then printed it in the ghci prompt
https://gist.github.com/cartazio/8748569

@cartazio
Copy link
Contributor Author

cartazio commented Feb 3, 2014

I asked Austin (thoughtpolice) on IRC and he's got a pretty good explanation (or at least the start of one )

does "unknown symbol `___dso_handle'" mean anything?
[14:02:03-13:30:13] i'd have to look more closely later, but this doesn't really surprise me, i think - ghci is using the system linker, which has no clue how to dynamically load/relocate a static archive (the code isn't position independent.)

@CRogers
Copy link

CRogers commented Feb 15, 2014

Hey, I'm having the same problem. How to you install with -fenable-shared? I tried cabal install --configure-option=-fenable-shared llvm-general* but I get the same error. Cheers.

*I actually did cabal install --reinstall --ghc-options=-XImpredicativeTypes --configure-option=-fenable-shared llvm-general because I'm on GHC 7.8 RC1 and already installed it.

@cartazio
Copy link
Contributor Author

@CRogers cabal install -fshared-llvm

@CRogers
Copy link

CRogers commented Feb 16, 2014

Thanks, cabal install llvm-general -fshared-llvm worked perfectly!

@cartazio
Copy link
Contributor Author

the best part is you should be able to use llvm-general in ghci now! test some toy trivial code and sanity check it works for you please (eg have clang output the llvm ir asm or bitcode, read it in with llvm-general, then pretty print it as a haskell ast)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants