From c6dd11ca39ac87899c92b13a743f104c31cadb26 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Wed, 9 Mar 2022 18:47:51 +0000 Subject: [PATCH 1/2] Revert "gcc: Always pass `--enable-shared` by default" This reverts commit 8e482321805542e08eaf8819a6ad94ea4ba20370. Since pkgsStatic.stdenv.cc can only produce static binaries, there's no reason to include that compilers e.g. libstdc++.so. --- pkgs/development/compilers/gcc/10/default.nix | 7 +------ pkgs/development/compilers/gcc/11/default.nix | 7 +------ pkgs/development/compilers/gcc/4.8/default.nix | 7 +------ pkgs/development/compilers/gcc/4.9/default.nix | 7 +------ pkgs/development/compilers/gcc/6/default.nix | 7 +------ pkgs/development/compilers/gcc/7/default.nix | 7 +------ pkgs/development/compilers/gcc/8/default.nix | 7 +------ pkgs/development/compilers/gcc/9/default.nix | 7 +------ 8 files changed, 8 insertions(+), 48 deletions(-) diff --git a/pkgs/development/compilers/gcc/10/default.nix b/pkgs/development/compilers/gcc/10/default.nix index a26aaf771af3..da2726d90905 100644 --- a/pkgs/development/compilers/gcc/10/default.nix +++ b/pkgs/development/compilers/gcc/10/default.nix @@ -8,12 +8,7 @@ , profiledCompiler ? false , langJit ? false , staticCompiler ? false -, # N.B. the defult is intentionally not from an `isStatic`. See - # https://gcc.gnu.org/install/configure.html - this is about target - # platform libraries not host platform ones unlike normal. But since - # we can't rebuild those without also rebuilding the compiler itself, - # we opt to always build everything unlike our usual policy. - enableShared ? true +, enableShared ? !stdenv.targetPlatform.isStatic , enableLTO ? !stdenv.hostPlatform.isStatic , texinfo ? null , perl ? null # optional, for texi2pod (then pod2man) diff --git a/pkgs/development/compilers/gcc/11/default.nix b/pkgs/development/compilers/gcc/11/default.nix index b78ca339fb85..c9c8e4078d05 100644 --- a/pkgs/development/compilers/gcc/11/default.nix +++ b/pkgs/development/compilers/gcc/11/default.nix @@ -8,12 +8,7 @@ , profiledCompiler ? false , langJit ? false , staticCompiler ? false -, # N.B. the defult is intentionally not from an `isStatic`. See - # https://gcc.gnu.org/install/configure.html - this is about target - # platform libraries not host platform ones unlike normal. But since - # we can't rebuild those without also rebuilding the compiler itself, - # we opt to always build everything unlike our usual policy. - enableShared ? true +, enableShared ? !stdenv.targetPlatform.isStatic , enableLTO ? !stdenv.hostPlatform.isStatic , texinfo ? null , perl ? null # optional, for texi2pod (then pod2man) diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix index bc7868cc4606..81e875f3caa0 100644 --- a/pkgs/development/compilers/gcc/4.8/default.nix +++ b/pkgs/development/compilers/gcc/4.8/default.nix @@ -8,12 +8,7 @@ , profiledCompiler ? false , langJit ? false , staticCompiler ? false -, # N.B. the defult is intentionally not from an `isStatic`. See - # https://gcc.gnu.org/install/configure.html - this is about target - # platform libraries not host platform ones unlike normal. But since - # we can't rebuild those without also rebuilding the compiler itself, - # we opt to always build everything unlike our usual policy. - enableShared ? true +, enableShared ? !stdenv.targetPlatform.isStatic , enableLTO ? !stdenv.hostPlatform.isStatic , texinfo ? null , perl ? null # optional, for texi2pod (then pod2man); required for Java diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix index bb1a3dd7d636..1a05ca7a595a 100644 --- a/pkgs/development/compilers/gcc/4.9/default.nix +++ b/pkgs/development/compilers/gcc/4.9/default.nix @@ -8,12 +8,7 @@ , profiledCompiler ? false , langJit ? false , staticCompiler ? false -, # N.B. the defult is intentionally not from an `isStatic`. See - # https://gcc.gnu.org/install/configure.html - this is about target - # platform libraries not host platform ones unlike normal. But since - # we can't rebuild those without also rebuilding the compiler itself, - # we opt to always build everything unlike our usual policy. - enableShared ? true +, enableShared ? !stdenv.targetPlatform.isStatic , enableLTO ? !stdenv.hostPlatform.isStatic , texinfo ? null , perl ? null # optional, for texi2pod (then pod2man); required for Java diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix index 7548ec56c759..0cab8e0dfaa5 100644 --- a/pkgs/development/compilers/gcc/6/default.nix +++ b/pkgs/development/compilers/gcc/6/default.nix @@ -9,12 +9,7 @@ , profiledCompiler ? false , langJit ? false , staticCompiler ? false -, # N.B. the defult is intentionally not from an `isStatic`. See - # https://gcc.gnu.org/install/configure.html - this is about target - # platform libraries not host platform ones unlike normal. But since - # we can't rebuild those without also rebuilding the compiler itself, - # we opt to always build everything unlike our usual policy. - enableShared ? true +, enableShared ? !stdenv.targetPlatform.isStatic , enableLTO ? !stdenv.hostPlatform.isStatic , texinfo ? null , flex diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix index dfac97104eb6..3f9a7856d078 100644 --- a/pkgs/development/compilers/gcc/7/default.nix +++ b/pkgs/development/compilers/gcc/7/default.nix @@ -7,12 +7,7 @@ , profiledCompiler ? false , langJit ? false , staticCompiler ? false -, # N.B. the defult is intentionally not from an `isStatic`. See - # https://gcc.gnu.org/install/configure.html - this is about target - # platform libraries not host platform ones unlike normal. But since - # we can't rebuild those without also rebuilding the compiler itself, - # we opt to always build everything unlike our usual policy. - enableShared ? true +, enableShared ? !stdenv.targetPlatform.isStatic , enableLTO ? !stdenv.hostPlatform.isStatic , texinfo ? null , perl ? null # optional, for texi2pod (then pod2man) diff --git a/pkgs/development/compilers/gcc/8/default.nix b/pkgs/development/compilers/gcc/8/default.nix index 609dfa722a65..493421d20fe9 100644 --- a/pkgs/development/compilers/gcc/8/default.nix +++ b/pkgs/development/compilers/gcc/8/default.nix @@ -7,12 +7,7 @@ , profiledCompiler ? false , langJit ? false , staticCompiler ? false -, # N.B. the defult is intentionally not from an `isStatic`. See - # https://gcc.gnu.org/install/configure.html - this is about target - # platform libraries not host platform ones unlike normal. But since - # we can't rebuild those without also rebuilding the compiler itself, - # we opt to always build everything unlike our usual policy. - enableShared ? true +, enableShared ? !stdenv.targetPlatform.isStatic , enableLTO ? !stdenv.hostPlatform.isStatic , texinfo ? null , perl ? null # optional, for texi2pod (then pod2man) diff --git a/pkgs/development/compilers/gcc/9/default.nix b/pkgs/development/compilers/gcc/9/default.nix index ea4296826661..b9b440cfb6fc 100644 --- a/pkgs/development/compilers/gcc/9/default.nix +++ b/pkgs/development/compilers/gcc/9/default.nix @@ -9,12 +9,7 @@ , profiledCompiler ? false , langJit ? false , staticCompiler ? false -, # N.B. the defult is intentionally not from an `isStatic`. See - # https://gcc.gnu.org/install/configure.html - this is about target - # platform libraries not host platform ones unlike normal. But since - # we can't rebuild those without also rebuilding the compiler itself, - # we opt to always build everything unlike our usual policy. - enableShared ? true +, enableShared ? !stdenv.targetPlatform.isStatic , enableLTO ? !stdenv.hostPlatform.isStatic , texinfo ? null , perl ? null # optional, for texi2pod (then pod2man) From 12c37aec377d672b0f7e72553283cc796fee2419 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 21 Mar 2022 19:44:32 +0000 Subject: [PATCH 2/2] pkgsStatic.stdenv.cc.cc: put static libs in $lib libtool requires the library files its .la files describe to be in the same directory as those files. We only do this for compilers without shared libraries, so that the libraries in $lib are always the libraries the package set is supposed to use. Fixes: https://github.com/NixOS/nixpkgs/issues/76873 Fixes: https://github.com/NixOS/nixpkgs/issues/108534 --- pkgs/development/compilers/gcc/10/default.nix | 2 +- pkgs/development/compilers/gcc/11/default.nix | 2 +- pkgs/development/compilers/gcc/4.8/default.nix | 2 +- pkgs/development/compilers/gcc/4.9/default.nix | 2 +- pkgs/development/compilers/gcc/6/default.nix | 2 +- pkgs/development/compilers/gcc/7/default.nix | 2 +- pkgs/development/compilers/gcc/8/default.nix | 2 +- pkgs/development/compilers/gcc/9/default.nix | 2 +- pkgs/development/compilers/gcc/builder.sh | 4 ++++ 9 files changed, 12 insertions(+), 8 deletions(-) diff --git a/pkgs/development/compilers/gcc/10/default.nix b/pkgs/development/compilers/gcc/10/default.nix index da2726d90905..3a659052b0d1 100644 --- a/pkgs/development/compilers/gcc/10/default.nix +++ b/pkgs/development/compilers/gcc/10/default.nix @@ -261,7 +261,7 @@ stdenv.mkDerivation ({ }; enableParallelBuilding = true; - inherit enableMultilib; + inherit enableMultilib enableShared; inherit (stdenv) is64bit; diff --git a/pkgs/development/compilers/gcc/11/default.nix b/pkgs/development/compilers/gcc/11/default.nix index c9c8e4078d05..79e682e88c4e 100644 --- a/pkgs/development/compilers/gcc/11/default.nix +++ b/pkgs/development/compilers/gcc/11/default.nix @@ -264,7 +264,7 @@ stdenv.mkDerivation ({ }; enableParallelBuilding = true; - inherit enableMultilib; + inherit enableShared enableMultilib; inherit (stdenv) is64bit; diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix index 81e875f3caa0..ef1a04635f9a 100644 --- a/pkgs/development/compilers/gcc/4.8/default.nix +++ b/pkgs/development/compilers/gcc/4.8/default.nix @@ -290,7 +290,7 @@ stdenv.mkDerivation ({ }; enableParallelBuilding = true; - inherit enableMultilib; + inherit enableShared enableMultilib; inherit (stdenv) is64bit; diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix index 1a05ca7a595a..289df07d0312 100644 --- a/pkgs/development/compilers/gcc/4.9/default.nix +++ b/pkgs/development/compilers/gcc/4.9/default.nix @@ -306,7 +306,7 @@ stdenv.mkDerivation ({ }; enableParallelBuilding = true; - inherit enableMultilib; + inherit enableShared enableMultilib; inherit (stdenv) is64bit; diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix index 0cab8e0dfaa5..5191c3b461be 100644 --- a/pkgs/development/compilers/gcc/6/default.nix +++ b/pkgs/development/compilers/gcc/6/default.nix @@ -320,7 +320,7 @@ stdenv.mkDerivation ({ }; enableParallelBuilding = true; - inherit enableMultilib; + inherit enableShared enableMultilib; inherit (stdenv) is64bit; diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix index 3f9a7856d078..aa1a82771715 100644 --- a/pkgs/development/compilers/gcc/7/default.nix +++ b/pkgs/development/compilers/gcc/7/default.nix @@ -272,7 +272,7 @@ stdenv.mkDerivation ({ }; enableParallelBuilding = true; - inherit enableMultilib; + inherit enableShared enableMultilib; inherit (stdenv) is64bit; diff --git a/pkgs/development/compilers/gcc/8/default.nix b/pkgs/development/compilers/gcc/8/default.nix index 493421d20fe9..e98197836955 100644 --- a/pkgs/development/compilers/gcc/8/default.nix +++ b/pkgs/development/compilers/gcc/8/default.nix @@ -254,7 +254,7 @@ stdenv.mkDerivation ({ }; enableParallelBuilding = true; - inherit enableMultilib; + inherit enableShared enableMultilib; inherit (stdenv) is64bit; diff --git a/pkgs/development/compilers/gcc/9/default.nix b/pkgs/development/compilers/gcc/9/default.nix index b9b440cfb6fc..8118d2ea6132 100644 --- a/pkgs/development/compilers/gcc/9/default.nix +++ b/pkgs/development/compilers/gcc/9/default.nix @@ -280,7 +280,7 @@ stdenv.mkDerivation ({ }; enableParallelBuilding = true; - inherit enableMultilib; + inherit enableShared enableMultilib; inherit (stdenv) is64bit; diff --git a/pkgs/development/compilers/gcc/builder.sh b/pkgs/development/compilers/gcc/builder.sh index e6d41d7b29ab..9d0514f17590 100644 --- a/pkgs/development/compilers/gcc/builder.sh +++ b/pkgs/development/compilers/gcc/builder.sh @@ -222,6 +222,10 @@ postInstall() { moveToOutput "${targetConfig+$targetConfig/}lib/lib*.dll.a" "${!outputLib}" moveToOutput "share/gcc-*/python" "${!outputLib}" + if [ -z "$enableShared" ]; then + moveToOutput "${targetConfig+$targetConfig/}lib/lib*.a" "${!outputLib}" + fi + for i in "${!outputLib}/${targetConfig}"/lib/*.{la,py}; do substituteInPlace "$i" --replace "$out" "${!outputLib}" done