From 190346e1cf5305b1fcf548291542046da9e1c31f Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Tue, 1 Jul 2025 13:29:01 +0200 Subject: [PATCH 1/2] haskell.compiler.ghc902Binary: add missing isHadrian annotations Interestingly, this did not break anything super obvious before, but now paths between GHC and separate libraries match. --- pkgs/development/compilers/ghc/9.0.2-binary.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/development/compilers/ghc/9.0.2-binary.nix b/pkgs/development/compilers/ghc/9.0.2-binary.nix index 65f6d133287a..77e78ecb6d17 100644 --- a/pkgs/development/compilers/ghc/9.0.2-binary.nix +++ b/pkgs/development/compilers/ghc/9.0.2-binary.nix @@ -136,6 +136,7 @@ let fileToCheckFor = null; } ]; + isHadrian = true; }; aarch64-darwin = { variantSuffix = ""; @@ -158,6 +159,7 @@ let fileToCheckFor = null; } ]; + isHadrian = true; }; }; # Binary distributions for the musl libc for the respective system. @@ -179,6 +181,7 @@ let fileToCheckFor = "libncursesw.so.6"; } ]; + isHadrian = true; }; }; }; From fbbdcddadab91e4a44fa1daaf734f49cc13917ae Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Tue, 1 Jul 2025 13:40:22 +0200 Subject: [PATCH 2/2] haskell.compiler.ghc902Binary: fix (system) libffi header discovery The GHC 9.0.2 bindist expects the headers of libffi to be found under /Applications/XCode.app instead of /Library (which is the case for later GHC bindists which I copied the code from). Correctly substituting this path will prevent GHC from using the bundled and thus outdated libffi headers that are broken for some reason or other. That these bundled headers were installed was actually a bug in hadrian which created the bindists because it ignored use-system-libffi before GHC 9.2. (This was actually the issue I noticed first because it hides the actual problem: Because GHC installed these headers, GHC found some version of ffi.h and ffitarget.h instead of correctly failing due to missing headers which would indicate that package db is broken.) For the sake of completeness, we can also solve this problem by deleting these headers in postInstall. --- .../compilers/ghc/9.0.2-binary.nix | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/pkgs/development/compilers/ghc/9.0.2-binary.nix b/pkgs/development/compilers/ghc/9.0.2-binary.nix index 77e78ecb6d17..ff70b4587eb3 100644 --- a/pkgs/development/compilers/ghc/9.0.2-binary.nix +++ b/pkgs/development/compilers/ghc/9.0.2-binary.nix @@ -313,7 +313,7 @@ stdenv.mkDerivation { # To link RTS in the end we also need libffi now find . -name 'rts*.conf' \ -exec sed -e '/^[a-z-]*library-dirs/a \ ${lib.getLib libffi}/lib' \ - -e 's@/Library/Developer/.*/usr/include/ffi@${lib.getDev libffi}/include@' \ + -e 's@/.*/Developer/.*/usr/include/ffi@${lib.getDev libffi}/include@' \ -i {} \; '' + @@ -363,13 +363,23 @@ stdenv.mkDerivation { makeFlags = lib.optionals stdenv.buildPlatform.isDarwin [ "XATTR=/does-not-exist" ]; # Patch scripts to include runtime dependencies in $PATH. - postInstall = '' - for i in "$out/bin/"*; do - test ! -h "$i" || continue - isScript "$i" || continue - sed -i -e '2i export PATH="${lib.makeBinPath runtimeDeps}:$PATH"' "$i" - done - ''; + postInstall = + '' + for i in "$out/bin/"*; do + test ! -h "$i" || continue + isScript "$i" || continue + sed -i -e '2i export PATH="${lib.makeBinPath runtimeDeps}:$PATH"' "$i" + done + '' + # On Darwin, GHC doesn't install a bundled libffi.so, but instead uses the + # system one (see postUnpack). Due to a bug in Hadrian, the (bundled) libffi + # headers are installed anyways. This problem has been fixed in GHC 9.2: + # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8189. While the system + # header should shadow the GHC installed ones, remove them to be safe. + + lib.optionalString (stdenv.hostPlatform.isDarwin && binDistUsed.isHadrian or false) '' + echo Deleting redundant libffi headers: + find "$out" '(' -name ffi.h -or -name ffitarget.h ')' -print -delete + ''; # Apparently necessary for the ghc Alpine (musl) bindist: # When we strip, and then run the