Skip to content

Commit

Permalink
Make libcxxabi mapping work across multiple nixpkgs
Browse files Browse the repository at this point in the history
  • Loading branch information
angerman committed Apr 14, 2024
1 parent 4d2710e commit f5a8eb3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
22 changes: 19 additions & 3 deletions compiler/ghc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -671,11 +671,16 @@ stdenv.mkDerivation (rec {
${hadrian}/bin/hadrian ${hadrianArgs} _build/stage0/compiler/build/$a
cp _build/stage0/compiler/build/$a compiler/GHC/Builtin/$a
done
'' + lib.optionalString stdenv.isDarwin ''
'' + lib.optionalString stdenv.isDarwin && (__tryEval libcxxabi).success ''
substituteInPlace mk/system-cxx-std-lib-1.0.conf \
--replace 'dynamic-library-dirs:' 'dynamic-library-dirs: ${libcxx}/lib ${libcxxabi}/lib'
find . -name 'system*.conf*'
cat mk/system-cxx-std-lib-1.0.conf
'' + lib.optionalString stdenv.isDarwin && !(__tryEval libcxxabi).success ''
substituteInPlace mk/system-cxx-std-lib-1.0.conf \
--replace 'dynamic-library-dirs:' 'dynamic-library-dirs: ${libcxx}/lib'
find . -name 'system*.conf*'
cat mk/system-cxx-std-lib-1.0.conf
'' + lib.optionalString (installStage1 && stdenv.targetPlatform.isMusl) ''
substituteInPlace hadrian/cfg/system.config \
--replace 'cross-compiling = YES' \
Expand Down Expand Up @@ -756,11 +761,16 @@ stdenv.mkDerivation (rec {
export XATTR=$(mktemp -d)/nothing
'';
} // lib.optionalAttrs useHadrian {
postConfigure = lib.optionalString stdenv.isDarwin ''
postConfigure = lib.optionalString (stdenv.isDarwin && (__tryEval libcxxabi).success) ''
substituteInPlace mk/system-cxx-std-lib-1.0.conf \
--replace 'dynamic-library-dirs:' 'dynamic-library-dirs: ${libcxx}/lib ${libcxxabi}/lib'
find . -name 'system*.conf*'
cat mk/system-cxx-std-lib-1.0.conf
'' + lib.optionalString (stdenv.isDarwin && !(__tryEval libcxxabi).success) ''
substituteInPlace mk/system-cxx-std-lib-1.0.conf \
--replace 'dynamic-library-dirs:' 'dynamic-library-dirs: ${libcxx}/lib'
find . -name 'system*.conf*'
cat mk/system-cxx-std-lib-1.0.conf
'' + lib.optionalString (installStage1 && !haskell-nix.haskellLib.isCrossTarget && stdenv.targetPlatform.isMusl) ''
substituteInPlace hadrian/cfg/system.config \
--replace 'cross-compiling = YES' \
Expand Down Expand Up @@ -820,12 +830,18 @@ stdenv.mkDerivation (rec {
${hadrian}/bin/hadrian ${hadrianArgs} binary-dist-dir
cd _build/bindist/ghc-*
./configure --prefix=$out ${lib.concatStringsSep " " configureFlags}
${lib.optionalString stdenv.isDarwin ''
${lib.optionalString (stdenv.isDarwin && (__tryEval libcxxabi).success) ''
substituteInPlace mk/system-cxx-std-lib-1.0.conf \
--replace 'dynamic-library-dirs:' 'dynamic-library-dirs: ${libcxx}/lib ${libcxxabi}/lib'
substituteInPlace lib/package.conf.d/system-cxx-std-lib-1.0.conf \
--replace 'dynamic-library-dirs:' 'dynamic-library-dirs: ${libcxx}/lib ${libcxxabi}/lib'
''}
${lib.optionalString (stdenv.isDarwin && !(__tryEval libcxxabi).success) ''
substituteInPlace mk/system-cxx-std-lib-1.0.conf \
--replace 'dynamic-library-dirs:' 'dynamic-library-dirs: ${libcxx}/lib'
substituteInPlace lib/package.conf.d/system-cxx-std-lib-1.0.conf \
--replace 'dynamic-library-dirs:' 'dynamic-library-dirs: ${libcxx}/lib'
''}
mkdir -p utils
cp -r ../../../utils/completion utils
make install
Expand Down
6 changes: 5 additions & 1 deletion lib/system-nixpkgs-map.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ in
# -- linux
{ crypto = [ openssl ];
"c++" = [ libcxx ];
"c++abi" = [ libcxxabi ];
# at some point this happened:
#
# error: 'libcxxabi' was merged into 'libcxx'
#
"c++abi" = [ if (__tryEval libcxxabi).success then libcxxabi else libcxx ];
system-cxx-std-lib = [];
"stdc++" = gcclibs;
"stdc++-6" = gcclibs;
Expand Down

0 comments on commit f5a8eb3

Please sign in to comment.