tweag / rules_haskell

Haskell rules for Bazel.
https://haskell.build
Apache License 2.0
266 stars 81 forks source link

Absolute runpaths in ELF libraries generated by `cabal_package` #1130

Closed thufschmitt closed 4 years ago

thufschmitt commented 5 years ago

Quite similar to #1127 , although this issue is triggered in a different context by a different rule, so probably worth a different issue

Describe the bug

cabal_package generates .so files that contain absolute references to the sandbox root in their ELF header

To Reproduce

bazel build //tests/binary-with-prebuilt/...
readelf -d bazel-bin/external/stackage/streaming-0.2.2.0/_install/lib/libHSstreaming-0.2.2.0-ghc8.6.5.so| grep .cache/bazel

On my machine, this gives me

$ readelf -d bazel-bin/external/stackage/streaming-0.2.2.0/_install/lib/libHSstreaming-0.2.2.0-ghc8.6.5.so| grep .cache/bazel     06:43:34
 0x000000000000001d (RUNPATH)            Library runpath: [/nix/store/44zyylbbhabj2d62f7lbb6wmjlllcv10-ghc-8.6.5/lib/ghc-8.6.5/array-0.5.3.0:/nix/store/44zyylbbhabj2d62f7lbb6wmjlllcv10-ghc-8.6.5/lib/ghc-8.6.5/base-4.12.0.0:/home/regnat/.cache/bazel/_bazel_regnat/9b6df921bb6e07dc34fcea21f9031196/sandbox/linux-sandbox/15/execroot/rules_haskell/bazel-out/k8-fastbuild/bin/external/stackage/base-orphans-0.8.1/_install/lib:/nix/store/44zyylbbhabj2d62f7lbb6wmjlllcv10-ghc-8.6.5/lib/ghc-8.6.5/containers-0.6.0.1:/nix/store/44zyylbbhabj2d62f7lbb6wmjlllcv10-ghc-8.6.5/lib/ghc-8.6.5/deepseq-1.4.4.0:/nix/store/44zyylbbhabj2d62f7lbb6wmjlllcv10-ghc-8.6.5/lib/ghc-8.6.5/ghc-prim-0.5.3:/nix/store/44zyylbbhabj2d62f7lbb6wmjlllcv10-ghc-8.6.5/lib/ghc-8.6.5/integer-gmp-1.0.2.0:/nix/store/vdw4zkdvdcpca3bn0z7i3a2na48pr38a-gmp-6.1.2/lib:/home/regnat/.cache/bazel/_bazel_regnat/9b6df921bb6e07dc34fcea21f9031196/sandbox/linux-sandbox/15/execroot/rules_haskell/bazel-out/k8-fastbuild/bin/external/stackage/mmorph-1.1.2/_install/lib:/nix/store/44zyylbbhabj2d62f7lbb6wmjlllcv10-ghc-8.6.5/lib/ghc-8.6.5/mtl-2.2.2:/nix/store/44zyylbbhabj2d62f7lbb6wmjlllcv10-ghc-8.6.5/lib/ghc-8.6.5/rts:/nix/store/rr52rxkzn8w4pidxp8g49649yysa726h-libffi-3.2.1/lib:/home/regnat/.cache/bazel/_bazel_regnat/9b6df921bb6e07dc34fcea21f9031196/sandbox/linux-sandbox/15/execroot/rules_haskell/bazel-out/k8-fastbuild/bin/external/stackage/semigroups-0.18.5/_install/lib:/nix/store/44zyylbbhabj2d62f7lbb6wmjlllcv10-ghc-8.6.5/lib/ghc-8.6.5/stm-2.5.0.0:/nix/store/44zyylbbhabj2d62f7lbb6wmjlllcv10-ghc-8.6.5/lib/ghc-8.6.5/transformers-0.5.6.2:/home/regnat/.cache/bazel/_bazel_regnat/9b6df921bb6e07dc34fcea21f9031196/sandbox/linux-sandbox/15/execroot/rules_haskell/bazel-out/k8-fastbuild/bin/external/stackage/transformers-base-0.4.5.2/_install/lib:/home/regnat/.cache/bazel/_bazel_regnat/9b6df921bb6e07dc34fcea21f9031196/sandbox/linux-sandbox/15/execroot/rules_haskell/bazel-out/k8-fastbuild/bin/external/stackage/transformers-compat-0.6.2/_install/lib:/nix/store/iykxb0bmfjmi7s53kfg6pjbfpd8jmza6-glibc-2.27/lib:/nix/store/pjx3f50x0qziyivs7rbg5s12p99nn2np-gcc-7.4.0-lib/lib:/home/regnat/.cache/bazel/_bazel_regnat/9b6df921bb6e07dc34fcea21f9031196/sandbox/linux-sandbox/15/execroot/rules_haskell/bazel-out/k8-fastbuild/bin/_solib_k8/_U@rules_Uhaskell_S_Shaskell_Ctoolchain-libraries___Uexternal_Srules_Uhaskell_Ughc_Unixpkgs_Uhaskell_Utoolchain_Slib_Sghc-8.6.5_Scontainers-0.6.0.1:/home/regnat/.cache/bazel/_bazel_regnat/9b6df921bb6e07dc34fcea21f9031196/sandbox/linux-sandbox/15/execroot/rules_haskell/bazel-out/k8-fastbuild/bin/_solib_k8/_U@rules_Uhaskell_S_Shaskell_Ctoolchain-libraries___Uexternal_Srules_Uhaskell_Ughc_Unixpkgs_Uhaskell_Utoolchain_Slib_Sghc-8.6.5_Sdeepseq-1.4.4.0:/home/regnat/.cache/bazel/_bazel_regnat/9b6df921bb6e07dc34fcea21f9031196/sandbox/linux-sandbox/15/execroot/rules_haskell/bazel-out/k8-fastbuild/bin/_solib_k8/_U@stackage_S_S_Cmmorph___Uexternal_Sstackage_Smmorph-1.1.2_S_Uinstall_Slib:/home/regnat/.cache/bazel/_bazel_regnat/9b6df921bb6e07dc34fcea21f9031196/sandbox/linux-sandbox/15/execroot/rules_haskell/bazel-out/k8-fastbuild/bin/_solib_k8/_U@rules_Uhaskell_S_Shaskell_Ctoolchain-libraries___Uexternal_Srules_Uhaskell_Ughc_Unixpkgs_Uhaskell_Utoolchain_Slib_Sghc-8.6.5_Smtl-2.2.2:/home/regnat/.cache/bazel/_bazel_regnat/9b6df921bb6e07dc34fcea21f9031196/sandbox/linux-sandbox/15/execroot/rules_haskell/bazel-out/k8-fastbuild/bin/_solib_k8/_U@stackage_S_S_Csemigroups___Uexternal_Sstackage_Ssemigroups-0.18.5_S_Uinstall_Slib:/home/regnat/.cache/bazel/_bazel_regnat/9b6df921bb6e07dc34fcea21f9031196/sandbox/linux-sandbox/15/execroot/rules_haskell/bazel-out/k8-fastbuild/bin/_solib_k8/_U@stackage_S_S_Ctransformers-base___Uexternal_Sstackage_Stransformers-base-0.4.5.2_S_Uinstall_Slib:/home/regnat/.cache/bazel/_bazel_regnat/9b6df921bb6e07dc34fcea21f9031196/sandbox/linux-sandbox/15/execroot/rules_haskell/bazel-out/k8-fastbuild/bin/_solib_k8/_U@stackage_S_S_Cbase-orphans___Uexternal_Sstackage_Sbase-orphans-0.8.1_S_Uinstall_Slib:/home/regnat/.cache/bazel/_bazel_regnat/9b6df921bb6e07dc34fcea21f9031196/sandbox/linux-sandbox/15/execroot/rules_haskell/bazel-out/k8-fastbuild/bin/_solib_k8/_U@rules_Uhaskell_S_Shaskell_Ctoolchain-libraries___Uexternal_Srules_Uhaskell_Ughc_Unixpkgs_Uhaskell_Utoolchain_Slib_Sghc-8.6.5_Sstm-2.5.0.0:/home/regnat/.cache/bazel/_bazel_regnat/9b6df921bb6e07dc34fcea21f9031196/sandbox/linux-sandbox/15/execroot/rules_haskell/bazel-out/k8-fastbuild/bin/_solib_k8/_U@rules_Uhaskell_S_Shaskell_Ctoolchain-libraries___Uexternal_Srules_Uhaskell_Ughc_Unixpkgs_Uhaskell_Utoolchain_Slib_Sghc-8.6.5_Sarray-0.5.3.0:/home/regnat/.cache/bazel/_bazel_regnat/9b6df921bb6e07dc34fcea21f9031196/sandbox/linux-sandbox/15/execroot/rules_haskell/bazel-out/k8-fastbuild/bin/_solib_k8/_U@stackage_S_S_Ctransformers-compat___Uexternal_Sstackage_Stransformers-compat-0.6.2_S_Uinstall_Slib:/home/regnat/.cache/bazel/_bazel_regnat/9b6df921bb6e07dc34fcea21f9031196/sandbox/linux-sandbox/15/execroot/rules_haskell/bazel-out/k8-fastbuild/bin/_solib_k8/_U@rules_Uhaskell_S_Shaskell_Ctoolchain-libraries___Uexternal_Srules_Uhaskell_Ughc_Unixpkgs_Uhaskell_Utoolchain_Slib_Sghc-8.6.5_Stransformers-0.5.6.2:/home/regnat/.cache/bazel/_bazel_regnat/9b6df921bb6e07dc34fcea21f9031196/sandbox/linux-sandbox/15/execroot/rules_haskell/bazel-out/k8-fastbuild/bin/_solib_k8/_U@rules_Uhaskell_S_Shaskell_Ctoolchain-libraries___Uexternal_Srules_Uhaskell_Ughc_Unixpkgs_Uhaskell_Utoolchain_Slib_Sghc-8.6.5_Sbase-4.12.0.0:/home/regnat/.cache/bazel/_bazel_regnat/9b6df921bb6e07dc34fcea21f9031196/sandbox/linux-sandbox/15/execroot/rules_haskell/bazel-out/k8-fastbuild/bin/_solib_k8/_U@rules_Uhaskell_S_Shaskell_Ctoolchain-libraries___Uexternal_Srules_Uhaskell_Ughc_Unixpkgs_Uhaskell_Utoolchain_Slib_Sghc-8.6.5_Sinteger-gmp-1.0.2.0:/home/regnat/.cache/bazel/_bazel_regnat/9b6df921bb6e07dc34fcea21f9031196/sandbox/linux-sandbox/15/execroot/rules_haskell/bazel-out/k8-fastbuild/bin/_solib_k8/_U@rules_Uhaskell_S_Shaskell_Ctoolchain-libraries___Uexternal_Srules_Uhaskell_Ughc_Unixpkgs_Uhaskell_Utoolchain_Slib_Sghc-8.6.5_Sghc-prim-0.5.3]

Expected behavior

Empty result: The so file shouldn't keep any reference to the cache directory

Environment

aherrmann commented 4 years ago

This is fixed by https://github.com/tweag/rules_haskell/pull/1325