Bootstrap of ghc doesn’t do DESTDIR correctly, propagates build dir
Summary
The bootstrap of ghc doesn’t do DESTDIR
correctly, embeds the build directory into the ghc
binary, and propagates the build directory to binaries built using bootstrapped ghc.
This is embedded in the ghc
binary in several places:
vi /opt/local/lib/ghc-8.10.4/bin/ghc
^@/opt/local/var/macports/build/_opt_local_ports_lang_ghc/ghc/work/src/ghc-8.10.4/rts/dist/build^@
Also:
fgrep "/opt/local/var/macports/build" /opt/local/lib/ghc-8.10.4/bin/ghc
Binary file /opt/local/lib/ghc-8.10.4/bin/ghc matches
Looking at binaries built with this bootstrapped ghc
shows that the issue propagates.
Here is the binary for pandoc
, built using cabal
3.4.0.0 and this ghc-8.10.4
binary:
fgrep "/opt/local/var/macports/build/_opt_local_ports_lang_ghc/ghc/work/src/ghc-8.10.4/rts" /opt/local/bin/pandoc
Binary file /opt/local/bin/pandoc matches
Steps to reproduce
The Portfile simply implements ghc's basic quick start build instructions.
Expected behavior
No build directories in the ghc
binary, or binaries built using it.
Environment
- GHC version used: 8.10.4
Optional:
- Operating System: macOS
- Show closed items
Activity
-
Newest first Oldest first
-
Show all activity Show comments only Show history only
- ghc-triage-bot added needs triage label
added needs triage label
- Author
Note: this issue also exists with the distributed version of
ghc
. None of therpath
's embedded in the distributed version actually excist.install the prebuilt version without bootstrapping
sudo port install ghc +prebuilt
otool -l /opt/local/lib/ghc-8.10.4/bin/ghc
… Load command 60 cmd LC_RPATH cmdsize 88 path /Users/builder/Desktop/builds/V164sjj5/0/ghc/ghc/compiler/stage2/build (offset 12) Load command 61 cmd LC_RPATH cmdsize 96 path /Users/builder/Desktop/builds/V164sjj5/0/ghc/ghc/libraries/base/dist-install/build (offset 12) Load command 62 cmd LC_RPATH cmdsize 104 path /Users/builder/Desktop/builds/V164sjj5/0/ghc/ghc/libraries/bytestring/dist-install/build (offset 12) Load command 63 cmd LC_RPATH cmdsize 112 path /Users/builder/Desktop/builds/V164sjj5/0/ghc/ghc/libraries/containers/containers/dist-install/build (offset 12) Load command 64 cmd LC_RPATH cmdsize 104 path /Users/builder/Desktop/builds/V164sjj5/0/ghc/ghc/libraries/directory/dist-install/build (offset 12) Load command 65 cmd LC_RPATH cmdsize 104 path /Users/builder/Desktop/builds/V164sjj5/0/ghc/ghc/libraries/exceptions/dist-install/build (offset 12) Load command 66 cmd LC_RPATH cmdsize 104 path /Users/builder/Desktop/builds/V164sjj5/0/ghc/ghc/libraries/filepath/dist-install/build (offset 12) Load command 67 cmd LC_RPATH cmdsize 104 path /Users/builder/Desktop/builds/V164sjj5/0/ghc/ghc/libraries/ghc-boot-th/dist-install/build (offset 12) Load command 68 cmd LC_RPATH cmdsize 104 path /Users/builder/Desktop/builds/V164sjj5/0/ghc/ghc/libraries/ghc-boot/dist-install/build (offset 12) Load command 69 cmd LC_RPATH cmdsize 104 path /Users/builder/Desktop/builds/V164sjj5/0/ghc/ghc/libraries/ghc-prim/dist-install/build (offset 12) Load command 70 cmd LC_RPATH cmdsize 96 path /Users/builder/Desktop/builds/V164sjj5/0/ghc/ghc/libraries/ghci/dist-install/build (offset 12) Load command 71 cmd LC_RPATH cmdsize 104 path /Users/builder/Desktop/builds/V164sjj5/0/ghc/ghc/libraries/haskeline/dist-install/build (offset 12) Load command 72 cmd LC_RPATH cmdsize 104 path /Users/builder/Desktop/builds/V164sjj5/0/ghc/ghc/libraries/integer-gmp/dist-install/build (offset 12) Load command 73 cmd LC_RPATH cmdsize 104 path /Users/builder/Desktop/builds/V164sjj5/0/ghc/ghc/libraries/process/dist-install/build (offset 12) Load command 74 cmd LC_RPATH cmdsize 96 path /Users/builder/Desktop/builds/V164sjj5/0/ghc/ghc/libraries/time/dist-install/build (offset 12) Load command 75 cmd LC_RPATH cmdsize 104 path /Users/builder/Desktop/builds/V164sjj5/0/ghc/ghc/libraries/transformers/dist-install/build (offset 12) Load command 76 cmd LC_RPATH cmdsize 96 path /Users/builder/Desktop/builds/V164sjj5/0/ghc/ghc/libraries/unix/dist-install/build (offset 12) Load command 77 cmd LC_RPATH cmdsize 80 path /Users/builder/Desktop/builds/V164sjj5/0/ghc/ghc/rts/dist/build (offset 12)
- Author
Deleting these
rpath
's by brute-force works, but should be unnecessary with a workingDESTDIR
process:find /opt/local/lib/ghc-8.10.4/bin -type f | while read -r; do otool -l ${REPLY} | grep -A 3 LC_RPATH | grep path | grep -E -o -e '(/Users/builder/Desktop/builds/V164sjj5[^ ]+)' | xargs -I{} sudo install_name_tool -delete_rpath {} ${REPLY}; done
- Developer
I think this was fixed in 9e0c0c3a
Thanks for reporting the issue and sorry for the trouble.
- Andreas Klebinger added hadrian label
added hadrian label
- Andreas Klebinger removed needs triage label
removed needs triage label
- Andreas Klebinger changed milestone to %9.2.1
changed milestone to %9.2.1
- Maintainer
Does this require a backport to the 9.0 branch?
Edit: I will just give it backport-needed for now. To me it sounds like something that should be fixed for 9.0 and should be reasonably easy to backport.
Edited by Andreas Klebinger - Andreas Klebinger added 1 deleted label
added 1 deleted label
- Author
Thanks.
Another issue with
DESTDIR
is that it doesn't appear possible [?] to install binaries into aDESTDIR
directory using a specifiedPREFIX
for their final install location. E.g., settingghc
's--prefix=/opt/local
option causesghc
to copy the binaries to/opt/local
, which is exactly what you don't want especially for a package manager like MacPorts or brew.With
DESTDIR
, the binaries should be copied to${DESTDIR}
, but created with with the prefix e.g./opt/local
.In MacPorts, we hack around this by setting
--prefix=${DESTDIR}
, then do backflips to convert all the appearances of${DESTDIR}
within the binaries to the actual prefix, e.g./opt/local
. - Developer
@essandess I can't see why this would happen just reading the Makefile, it seems we do respect
DESTDIR
. I will try and reproduce this. - Matthew Pickering added Phigh label
added Phigh label
- Maintainer
Any word on this, @mpickering?
- Developer
Something isn't right here still with the rpaths.
GHC-8.10.2, built with Make.
0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN/../haskeline-0.8.0.1:$ORIGIN/../ghc-8.10.2:$ORIGIN/../terminfo-0.4.1.4:$ORIGIN/../process-1.6.9.0:$ORIGIN/../hpc-0.6.1.0:$ORIGIN/../ghci-8.10.2:$ORIGIN/../ghc-heap-8.10.2:$ORIGIN/../ghc-boot-8.10.2:$ORIGIN/../exceptions-0.10.4:$ORIGIN/../template-haskell-2.16.0.0:$ORIGIN/../pretty-1.1.3.6:$ORIGIN/../ghc-boot-th-8.10.2:$ORIGIN/../stm-2.5.0.0:$ORIGIN/../mtl-2.2.2:$ORIGIN/../transformers-0.5.6.2:$ORIGIN/../directory-1.3.6.0:$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.10.0:$ORIGIN/../deepseq-1.4.4.0:$ORIGIN/../array-0.5.4.0:$ORIGIN/../base-4.14.1.0:$ORIGIN/../integer-gmp-1.0.3.0:$ORIGIN/../ghc-prim-0.6.1:$ORIGIN/../rts:/nix/store/pk73wc0x32y2bmbiqiddb084w398ab6y-ncurses-6.2/lib:/nix/store/fphpbj8jpyibz0l2xspidg6s7zm7xyb5-gmp-6.2.0/lib:/nix/store/s0mblhs5vmjza9dmipn74rwqflxy1fw7-libffi-3.3/lib:/nix/store/9df65igwjmf2wbw0gbrrgair6piqjgmi-glibc-2.31/lib]
A local bindist I built, there are references to the
ghc-shell-for-ghc-buildenv
in the rpath still.0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN/../lib/x86_64-linux-ghc-9.3.20210513:$ORIGIN/../../../lib/x86_64-linux-ghc-9.3.20210513:/nix/store/d8pljv2gkkcva500wzvybq48cjfji66s-ghc-shell-for-ghc-buildenv-9.1-0/lib64:/nix/store/d8pljv2gkkcva500wzvybq48cjfji66s-ghc-shell-for-ghc-buildenv-9.1-0/lib:/nix/store/pk73wc0x32y2bmbiqiddb084w398ab6y-ncurses-6.2/lib:/nix/store/s0mblhs5vmjza9dmipn74rwqflxy1fw7-libffi-3.3/lib:/nix/store/fphpbj8jpyibz0l2xspidg6s7zm7xyb5-gmp-6.2.0/lib:/nix/store/saghih5p46g1nm8vmvxc5vw5pfj1nc79-numactl-2.0.13/lib:/nix/store/9df65igwjmf2wbw0gbrrgair6piqjgmi-glibc-2.31/lib:/nix/store/vran8acwir59772hj4vscr7zribvp7l5-gcc-9.3.0-lib/lib]
- Developer
The rpaths from my build are because of
NIX_LDFLAGS
.. so probably not an issue. - Developer
I can now see that
DESTDIR
is not honoured at all by themake install
command. - Maintainer
The patch from #19646 (comment 344216) is present in %9.2.1.
- Ben Gamari added Phighest label and removed Phigh label
- Ben Gamari changed milestone to %Make removal
changed milestone to %Make removal
- Zubin added 1 deleted label
added 1 deleted label