tweag / clodl

Turn dynamically linked ELF binaries and libraries into self-contained closures.
BSD 3-Clause "New" or "Revised" License
164 stars 6 forks source link

clodl fails on executables built with ghc-8.10.2 #34

Open facundominguez opened 3 years ago

facundominguez commented 3 years ago
ERROR: /home/centos/clodl/BUILD:54:16: Linking of rule '//:libclotest_wrapper.so' failed (Exit 1) gcc failed: error executing command /nix/store/8pbwywcj6vbswz7xmy2dh716x8blgh8w-gcc-wrapper-9.3.0/
bin/gcc @bazel-out/k8-fastbuild/bin/libclotest_wrapper.so-2.params

Use --sandbox_debug to see verbose messages from the sandbox
/nix/store/p792j5f44l3f0xi7ai5jllwnxqwnka88-binutils-2.31.1/bin/ld.gold: error: bazel-out/k8-fastbuild/bin/_solib_k8/_U_S_S_Clibclotest_Uwrapper.so___Uclotest_UUsolib/libhello-hs.so: unsupported E
LF file type 2
collect2: error: ld returned 1 exit status
Target //:clotest failed to build
Use --verbose_failures to see the command lines of failed build steps.

Seems related to this: https://github.com/tweag/rules_haskell/issues/1418

GHC is passing -no-pie to the linker when building the haskell binary, and the subsequent attempt to link the wrapper fails probably because of that.

facundominguez commented 3 years ago

It's rules_haskell who is adding -no-pie to the linking flags. Commenting this line makes clodl build fine: https://github.com/tweag/rules_haskell/blob/42b8b43623b82a6b7cfb151f01986735a135e0a9/haskell/private/actions/link.bzl#L113

aherrmann commented 3 years ago

Once GHC 8.8.5, 8.10.3, and 9.0.1 are released we'll be able to fix this in rules_haskell.

facundominguez commented 3 years ago

I made a temporary hack until this is fixed. https://github.com/tweag/rules_haskell/compare/fd/no-pie-hack This branch should be removed when this is closed.