Introduction I'm actually trying to create a shared library written in Haskell that is compatible with C (can be used from C code without knowing that it is written in Haskell), but I want all Haskell dependencies to be statically linked, now I can dynamically bind all dependencies (for each package, including the base and ghc-prim packages. In this experiment, see here .
I tried to solve this by writing a Dockerfile where I build GHC 8.2.2 from scratch with the replaced mk / build.mk file with this content (I just did the same thing I saw in different problems like this ), but when I trying to establish a connection with --make -static -shared -fPIC , I get a lot of similar errors about combining "ghc-prim", an example of the latter:
/usr/bin/ld.gold: error: /ghc-8.2.2-fpic/lib/ghc-8.2.2/ghc-prim-0.5.1.1/libHSghc-prim-0.5.1.1.a(Classes.o): requires dynamic R_X86_64_PC32 reloc against 'stg_ap_0_fast' which may overflow at runtime; recompile with -fPIC
What should I do to build GHC with -fPIC and link my library with Haskell static dependencies?
Dockerfile deployed from debian:stretch , here is a quote from the last most important part of it:
# ... apt-get update ... installing build-essential and other stuff ... # see https:
And here is the whole my-build.mk file:
SRC_HC_OPTS = -H64m -O EXTRA_HC_OPTS = -fPIC SRC_CC_OPTS = -fPIC -O GhcStage1HcOpts = -fasm -O0 GhcStage2HcOpts = -fasm -O0 GhcLibHcOpts = -fasm -O2 GhcLibWays = v dyn DYNAMIC_GHC_PROGRAMS = YES DYNAMIC_BY_DEFAULT = NO SplitObjs = NO HADDOCK_DOCS = NO BUILD_DOCBOOK_HTML = NO BUILD_DOCBOOK_PS = NO BUILD_DOCBOOK_PDF = NO V = 1 LATEX_DOCS = NO HSCOLOUR_SRCS = NO BeConservative = YES
source share