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

[llvm-3.5] Support GHCi and TH #199

Open
wants to merge 2 commits into
base: llvm-3.5
Choose a base branch
from

Conversation

tmcdonell
Copy link

Enables llvm-general to be used out-of-the-box with GHCi and TemplateHaskell whenever possible. This requires the LLVM shared library to be available, but only if you use GHCi/TH; regular compiles work as usual. Since cabal dependencies can not specify flags, this also makes llvm-general easier to work with as a dependency.

Requires Cabal-1.22 or newer, otherwise keeps the old behaviour.

Fixes #84, #85.
Ping #197.

Current behaviour

  • -fshared-llvm=True

    • executables are linked against the shared library, and required to compile llvm-general
    • GHCi and TH work
  • -fshared-llvm=False (default)

    • executables are statically linked
    • GHCi and TH fail in strange and mysterious ways, e.g.:
ghc: libLLVMSupport.a: unhandled ELF relocation(RelA) type 42

or

    ghc:
    lookupSymbol failed in relocateSection (RELOC_GOT)
    /usr/local/homebrew/Cellar/llvm35/3.5.1/lib/llvm-3.5/lib/libLLVMSupport.a: unknown symbol `___dso_handle'

or maybe

    <no location info>:
        ghc: panic! (the 'impossible' happened)
      (GHC version 7.10.3 for x86_64-apple-darwin):
    	Dynamic linker not initialised

    Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

New behaviour

  • -fshared-llvm=True

    • same as above
  • -fshared-llvm=False (default)

    • executables are statically linked
    • GHCi and TH work, if the shared library is available. If not, it still fails, but you get the more reasonable error message:
can't load .so/.DLL for: libLLVM-3.5.1.dylib (dlopen(libLLVM-3.5.1.dylib, 5): image not found)

Enables llvm-general to be used out-of-the-box with GHCi and TemplateHaskell. Note that the LLVM shared library is only required if you use GHCi/TH; regular compiles work as usual. Since cabal dependencies can not specify flags, this also makes llvm-general easier to work with as a dependency.
extraGHCiLibs was introduced in Cabal-1.22. Before GHC-8.0 there is no direct way to test which wersion of the Cabal library we are compiling against, but we can work around this limitation with a little bit of TH trickery.
@tmcdonell
Copy link
Author

@bscarlet any comment on this?

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

Successfully merging this pull request may close these issues.

1 participant