Summary: | Compile static with dev-lang/ghc (-fPIC) | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | merlin |
Component: | Current packages | Assignee: | Gentoo's Haskell Language team <haskell> |
Status: | RESOLVED INVALID | ||
Severity: | normal | ||
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- |
Description
merlin
2016-11-13 20:38:02 UTC
This problem is at least known.. quoting from the GHC docs: In principle you can use -shared without -dynamic in the link step. That means to statically link the rts all the base libraries into your new shared library. This would make a very big, but standalone shared library. On most platforms however that would require all the static libraries to have been built with -fPIC so that the code is suitable to include into a shared library and we do not do that at the moment. You can use the HCFLAGS variable to set Haskell-only compiler flags, but I would be surprised if that seeps down into the GHC build system itself. There is no difference between: - build a shared C library of static C libraries - build a shared haskell library of static haskell libraries As Michael said you can do the both things by building everything explicitly as -fPIC. In theory you just need to set HFLAGS=-fPIC. I've made it pass HCFLAGS to ghc itself as well (at least 7.10.3 has it) https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-lang/ghc/ghc-7.10.3.ebuild#n495 I don't remember how much I tested it last time. I have vague recollection that it worked. After HCFLAGS change you'll need to rebuild ghc and all the libraries you want as PIC. There might be a few fixes upstream i've forgot to pull to apply -fPIC properly on all artifacts ghc tries to build but things should work. Side note: you necessarily don't have to link statically into a shared library. You can pull all shared libs in a single directory and use -runpath on an executable to pull things in. Something like https://trofi.github.io/posts/144-ghc-and-static-linkage.html Does it make any sense? |