From 7621636030c887b4d7d000813a7be61869a16cf7 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Thu, 29 Jun 2023 08:48:07 -0700 Subject: [PATCH] gcc: use Nix instead of bash for conditional Now that we use the standard builder, the commands produced by pre-configure.nix are wrapped in a bash function. Inside of a bash function, `export foo=` will still add `foo` to the environment of any child processes forked after that point, but those variables will *not* be visible to bash code which is outside of the function-scope in which the `export` occurs. Weird crap like this is yet another reason why we need to move away from using bash for logic. Let's switch. --- .../compilers/gcc/common/builder.nix | 27 ++++++++++++------- .../compilers/gcc/common/pre-configure.nix | 13 --------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/pkgs/development/compilers/gcc/common/builder.nix b/pkgs/development/compilers/gcc/common/builder.nix index 72a06383c92b..e73542263df2 100644 --- a/pkgs/development/compilers/gcc/common/builder.nix +++ b/pkgs/development/compilers/gcc/common/builder.nix @@ -1,5 +1,6 @@ { lib , stdenv +, enableMultilib }: originalAttrs: (stdenv.mkDerivation (finalAttrs: originalAttrs // { @@ -188,16 +189,22 @@ originalAttrs: (stdenv.mkDerivation (finalAttrs: originalAttrs // { preInstall = '' mkdir -p "$out/''${targetConfig}/lib" mkdir -p "''${!outputLib}/''${targetConfig}/lib" - # Make ‘lib64’ symlinks to ‘lib’. - if [ -n "$linkLib64toLib" ]; then - ln -s lib "$out/''${targetConfig}/lib64" - ln -s lib "''${!outputLib}/''${targetConfig}/lib64" - fi - # Make ‘lib32’ symlinks to ‘lib’. - if [ -n "$linkLib32toLib" ]; then - ln -s lib "$out/''${targetConfig}/lib32" - ln -s lib "''${!outputLib}/''${targetConfig}/lib32" - fi + '' + + # Make `lib64` symlinks to `lib`. + lib.optionalString (!enableMultilib && stdenv.hostPlatform.is64bit && !stdenv.hostPlatform.isMips64n32) '' + ln -s lib "$out/''${targetConfig}/lib64" + ln -s lib "''${!outputLib}/''${targetConfig}/lib64" + '' + + # On mips platforms, gcc follows the IRIX naming convention: + # + # $PREFIX/lib = mips32 + # $PREFIX/lib32 = mips64n32 + # $PREFIX/lib64 = mips64 + # + # Make `lib32` symlinks to `lib`. + lib.optionalString (!enableMultilib && stdenv.targetPlatform.isMips64n32) '' + ln -s lib "$out/''${targetConfig}/lib32" + ln -s lib "''${!outputLib}/''${targetConfig}/lib32" ''; postInstall = '' diff --git a/pkgs/development/compilers/gcc/common/pre-configure.nix b/pkgs/development/compilers/gcc/common/pre-configure.nix index e386693b22c7..933a132ce4d1 100644 --- a/pkgs/development/compilers/gcc/common/pre-configure.nix +++ b/pkgs/development/compilers/gcc/common/pre-configure.nix @@ -148,16 +148,3 @@ in lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) '' echo 'SHLIB_LC=${SHLIB_LC}' >> libgcc/Makefile.in '') -+ lib.optionalString (!enableMultilib && hostPlatform.is64bit && !hostPlatform.isMips64n32) '' - export linkLib64toLib=1 -'' - -# On mips platforms, gcc follows the IRIX naming convention: -# -# $PREFIX/lib = mips32 -# $PREFIX/lib32 = mips64n32 -# $PREFIX/lib64 = mips64 -# -+ lib.optionalString (!enableMultilib && targetPlatform.isMips64n32) '' - export linkLib32toLib=1 -''