Executables in binary distributions produced by Hadrian contain the build directory in RPATH
While working on bgamari/ghcs.nix>, I found that nix
failed its output linting phase due to RPATH entries referring to the build directory:
patching script interpreter paths in /nix/store/djrafmmk6lr8yr58zw7d19bikav05w1z-ghc-9.0.1
checking for references to /build/ in /nix/store/djrafmmk6lr8yr58zw7d19bikav05w1z-ghc-9.0.1...
RPATH of binary /nix/store/djrafmmk6lr8yr58zw7d19bikav05w1z-ghc-9.0.1/lib/ghc-9.0.1/bin/ghc contains a forbidden reference to /build/
builder for '/nix/store/lfxcz00hp0rslmz2x48kgc6s30g7qx10-ghc-9.0.1.drv' failed with exit code 1
Examining Hadrian's output from a local build tree confirms this:
$ objdump -x _build/stage1/bin/ghc | grep RUNPATH
RUNPATH /opt/exp/ghc/ghc-landing/_build/stage1/lib/../lib/x86_64-linux-ghc-9.1.20210303:/nix/store/pk73wc0x32y2bmbiqiddb084w398ab6y-ncurses-6.2/lib:/nix/store/fphpbj8jpyibz0l2xspidg6s7zm7xyb5-gmp-6.2.0/lib:/nix/store/35v0m2ih9q4x3crhxiyr3pxc8ckn73gi-elfutils-0.180/lib:/nix/store/saghih5p46g1nm8vmvxc5vw5pfj1nc79-numactl-2.0.13/lib:$ORIGIN/../lib/x86_64-linux-ghc-9.1.20210303:$ORIGIN/../../../lib/x86_64-linux-ghc-9.1.20210303:/nix/store/ykig055slngj7raqgdqsg0d94bbyhyrk-ghc-shell-for-ghc-buildenv-9.2-0/lib64:/nix/store/ykig055slngj7raqgdqsg0d94bbyhyrk-ghc-shell-for-ghc-buildenv-9.2-0/lib:/nix/store/s0mblhs5vmjza9dmipn74rwqflxy1fw7-libffi-3.3/lib:/nix/store/9df65igwjmf2wbw0gbrrgair6piqjgmi-glibc-2.31/lib:/nix/store/vran8acwir59772hj4vscr7zribvp7l5-gcc-9.3.0-lib/lib
By contrast, if we look at the same executable from the make
build system we see that RUNPATH
is relative to $ORIGIN
:
RUNPATH $ORIGIN/../haskeline-0.8.1.0:$ORIGIN/../ghc-9.0.0.20201227:$ORIGIN/../terminfo-0.4.1.4:$ORIGIN/../process-1.6.10.0:$ORIGIN/../hpc-0.6.1.0:$ORIGIN/../ghci-9.0.0.20201227:$ORIGIN/../ghc-heap-9.0.0.20201227:$ORIGIN/../ghc-boot-9.0.0.20201227:$ORIGIN/../exceptions-0.10.4:$ORIGIN/../template-haskell-2.17.0.0:$ORIGIN/../pretty-1.1.3.6:$ORIGIN/../ghc-boot-th-9.0.0.20201227:$ORIGIN/../stm-2.5.0.0:$ORIGIN/../mtl-2.2.2:$ORIGIN/../transformers-0.5.6.2:$ORIGIN/../directory-1.3.6.1:$ORIGIN/../unix-2.7.2.2:$ORIGIN/../time-1.9.3:$ORIGIN/../filepath-1.4.2.1:$ORIGIN/../binary-0.8.8.0:$ORIGIN/../containers-0.6.2.1:$ORIGIN/../bytestring-0.10.12.0:$ORIGIN/../deepseq-1.4.4.0:$ORIGIN/../array-0.5.4.0:$ORIGIN/../base-4.15.0.0:$ORIGIN/../ghc-bignum-1.0:$ORIGIN/../ghc-prim-0.7.0:$ORIGIN/../rts