haskelllinker-errorsghccabalcabal-install

Cabal install fails in Linker phase


I'm trying to install this graphing library, but cabal-install is giving me this list of errors (only showing the bottom of the list, since everything above is very long and similar):

/usr/bin/ld:
/usr/local/haskell/ghc-8.0.2-x86_64/lib/ghc-8.0.2/rts/libHSrts_thr.a(MarkWeak.thr_o):
relocation R_X86_64_32S against symbol `stg_END_TSO_QUEUE_closure' can not be
used when making a PIE object; recompile with -fPIC
/usr/bin/ld:
/usr/local/haskell/ghc-8.0.2-x86_64/lib/ghc-8.0.2/rts/libHSrts_thr.a(Evac.thr_o):
relocation R_X86_64_32 against symbol `stg_WHITEHOLE_info' can not be used
when making a PIE object; recompile with -fPIC
/usr/bin/ld:
/usr/local/haskell/ghc-8.0.2-x86_64/lib/ghc-8.0.2/rts/libCffi.a(closures.o):
relocation R_X86_64_32 against `.rodata' can not be used when making a PIE
object; recompile with -fPIC
/usr/bin/ld:
/usr/local/haskell/ghc-8.0.2-x86_64/lib/ghc-8.0.2/rts/libCffi.a(ffi64.o):
relocation R_X86_64_32S against `.rodata' can not be used when making a PIE
object; recompile with -fPIC
/usr/bin/ld: final link failed: nonrepresentable section on output
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
)

So far, I have determined that the problem is caused by the installer trying to make a Position Independent Executable (PIE). I tried to solve this by setting the DEB_BUILD_HARDENING_PIE environment variable to 0 export DEB_BUILD_HARDENING_PIE=0, but it gives the same error.

I am running Debian, ghc-8.0.2 and cabal 1.24.2.0.


Solution

  • Instead of editing the DEB_BUILD_HARDENING_PIE environment variable, I have found another way to have cabal-install not make a PIE, which seems to fix this issue.

    cabal --ghc-option="-optl-no-pie" install chart-diagrams