diff options
author | Bernardo Meurer <bernardo@meurer.org> | 2022-07-28 00:30:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-28 00:30:49 -0700 |
commit | 88c63ca65a30eb83bd2a00d183a9f11819be43ad (patch) | |
tree | 28deb0ec736374e6a61478ede77500b1537eb751 /pkgs/development/compilers/gcc | |
parent | 0049ace2ece4a4555c5582c3b5a74a548cfb60e9 (diff) | |
parent | eece5d0dc0bbd7eaab1f09e608f89449f745003b (diff) | |
download | nixpkgs-88c63ca65a30eb83bd2a00d183a9f11819be43ad.tar nixpkgs-88c63ca65a30eb83bd2a00d183a9f11819be43ad.tar.gz nixpkgs-88c63ca65a30eb83bd2a00d183a9f11819be43ad.tar.bz2 nixpkgs-88c63ca65a30eb83bd2a00d183a9f11819be43ad.tar.lz nixpkgs-88c63ca65a30eb83bd2a00d183a9f11819be43ad.tar.xz nixpkgs-88c63ca65a30eb83bd2a00d183a9f11819be43ad.tar.zst nixpkgs-88c63ca65a30eb83bd2a00d183a9f11819be43ad.zip |
Merge pull request #182513 from trofi/strip-for-host-and-target
gcc: enable stripping for cross-compilers
Diffstat (limited to 'pkgs/development/compilers/gcc')
-rw-r--r-- | pkgs/development/compilers/gcc/10/default.nix | 16 | ||||
-rw-r--r-- | pkgs/development/compilers/gcc/11/default.nix | 16 | ||||
-rw-r--r-- | pkgs/development/compilers/gcc/12/default.nix | 16 | ||||
-rw-r--r-- | pkgs/development/compilers/gcc/4.8/default.nix | 16 | ||||
-rw-r--r-- | pkgs/development/compilers/gcc/4.9/default.nix | 16 | ||||
-rw-r--r-- | pkgs/development/compilers/gcc/6/default.nix | 16 | ||||
-rw-r--r-- | pkgs/development/compilers/gcc/7/default.nix | 16 | ||||
-rw-r--r-- | pkgs/development/compilers/gcc/8/default.nix | 16 | ||||
-rw-r--r-- | pkgs/development/compilers/gcc/9/default.nix | 16 | ||||
-rw-r--r-- | pkgs/development/compilers/gcc/builder.sh | 5 | ||||
-rw-r--r-- | pkgs/development/compilers/gcc/common/strip-attributes.nix | 53 |
11 files changed, 116 insertions, 86 deletions
diff --git a/pkgs/development/compilers/gcc/10/default.nix b/pkgs/development/compilers/gcc/10/default.nix index aead3fa21ff..1c223fa82f4 100644 --- a/pkgs/development/compilers/gcc/10/default.nix +++ b/pkgs/development/compilers/gcc/10/default.nix @@ -24,9 +24,6 @@ , libcCross ? null , threadsCross ? null # for MinGW , crossStageStatic ? false -, # Strip kills static libs of other archs (hence no cross) - stripped ? stdenv.hostPlatform.system == stdenv.buildPlatform.system - && stdenv.targetPlatform.system == stdenv.hostPlatform.system , gnused ? null , cloog # unused; just for compat with gcc4, as we override the parameter on some places , buildPackages @@ -86,7 +83,7 @@ let majorVersion = "10"; in stdenv.mkDerivation ({ - pname = "${crossNameAddon}${name}${if stripped then "" else "-debug"}"; + pname = "${crossNameAddon}${name}"; inherit version; builder = ../builder.sh; @@ -231,9 +228,11 @@ stdenv.mkDerivation ({ (targetPlatform == hostPlatform && hostPlatform == buildPlatform) (if profiledCompiler then "profiledbootstrap" else "bootstrap"); - dontStrip = !stripped; - - installTargets = optional stripped "install-strip"; + inherit + (import ../common/strip-attributes.nix { inherit stdenv; }) + stripDebugList + stripDebugListTarget + preFixup; # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; @@ -274,8 +273,7 @@ stdenv.mkDerivation ({ meta = { homepage = "https://gcc.gnu.org/"; license = lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ - description = "GNU Compiler Collection, version ${version}" - + (if stripped then "" else " (with debugging info)"); + description = "GNU Compiler Collection, version ${version}"; longDescription = '' The GNU Compiler Collection includes compiler front ends for C, C++, diff --git a/pkgs/development/compilers/gcc/11/default.nix b/pkgs/development/compilers/gcc/11/default.nix index 1522569cccc..ca3a89af180 100644 --- a/pkgs/development/compilers/gcc/11/default.nix +++ b/pkgs/development/compilers/gcc/11/default.nix @@ -24,9 +24,6 @@ , libcCross ? null , threadsCross ? null # for MinGW , crossStageStatic ? false -, # Strip kills static libs of other archs (hence no cross) - stripped ? stdenv.hostPlatform.system == stdenv.buildPlatform.system - && stdenv.targetPlatform.system == stdenv.hostPlatform.system , gnused ? null , cloog # unused; just for compat with gcc4, as we override the parameter on some places , buildPackages @@ -92,7 +89,7 @@ let majorVersion = "11"; in stdenv.mkDerivation ({ - pname = "${crossNameAddon}${name}${if stripped then "" else "-debug"}"; + pname = "${crossNameAddon}${name}"; inherit version; builder = ../builder.sh; @@ -239,9 +236,11 @@ stdenv.mkDerivation ({ (targetPlatform == hostPlatform && hostPlatform == buildPlatform) (if profiledCompiler then "profiledbootstrap" else "bootstrap"); - dontStrip = !stripped; - - installTargets = optional stripped "install-strip"; + inherit + (import ../common/strip-attributes.nix { inherit stdenv; }) + stripDebugList + stripDebugListTarget + preFixup; # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; @@ -282,8 +281,7 @@ stdenv.mkDerivation ({ meta = { homepage = "https://gcc.gnu.org/"; license = lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ - description = "GNU Compiler Collection, version ${version}" - + (if stripped then "" else " (with debugging info)"); + description = "GNU Compiler Collection, version ${version}"; longDescription = '' The GNU Compiler Collection includes compiler front ends for C, C++, diff --git a/pkgs/development/compilers/gcc/12/default.nix b/pkgs/development/compilers/gcc/12/default.nix index 2279a8b5ccc..6fdc31079a8 100644 --- a/pkgs/development/compilers/gcc/12/default.nix +++ b/pkgs/development/compilers/gcc/12/default.nix @@ -24,9 +24,6 @@ , libcCross ? null , threadsCross ? null # for MinGW , crossStageStatic ? false -, # Strip kills static libs of other archs (hence no cross) - stripped ? stdenv.hostPlatform.system == stdenv.buildPlatform.system - && stdenv.targetPlatform.system == stdenv.hostPlatform.system , gnused ? null , cloog # unused; just for compat with gcc4, as we override the parameter on some places , buildPackages @@ -89,7 +86,7 @@ let majorVersion = "12"; in stdenv.mkDerivation ({ - pname = "${crossNameAddon}${name}${if stripped then "" else "-debug"}"; + pname = "${crossNameAddon}${name}"; inherit version; builder = ../builder.sh; @@ -234,9 +231,11 @@ stdenv.mkDerivation ({ (targetPlatform == hostPlatform && hostPlatform == buildPlatform) (if profiledCompiler then "profiledbootstrap" else "bootstrap"); - dontStrip = !stripped; - - installTargets = optional stripped "install-strip"; + inherit + (import ../common/strip-attributes.nix { inherit stdenv; }) + stripDebugList + stripDebugListTarget + preFixup; # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; @@ -277,8 +276,7 @@ stdenv.mkDerivation ({ meta = { homepage = "https://gcc.gnu.org/"; license = lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ - description = "GNU Compiler Collection, version ${version}" - + (if stripped then "" else " (with debugging info)"); + description = "GNU Compiler Collection, version ${version}"; longDescription = '' The GNU Compiler Collection includes compiler front ends for C, C++, diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix index 473bd39e406..bc93d6e1358 100644 --- a/pkgs/development/compilers/gcc/4.8/default.nix +++ b/pkgs/development/compilers/gcc/4.8/default.nix @@ -28,9 +28,6 @@ , libcCross ? null , threadsCross ? null # for MinGW , crossStageStatic ? false -, # Strip kills static libs of other archs (hence no cross) - stripped ? stdenv.hostPlatform == stdenv.buildPlatform - && stdenv.targetPlatform == stdenv.hostPlatform , gnused ? null , buildPackages }: @@ -124,7 +121,7 @@ in assert x11Support -> (filter (x: x == null) ([ gtk2 libart_lgpl ] ++ xlibs)) == []; stdenv.mkDerivation ({ - pname = "${crossNameAddon}${name}${if stripped then "" else "-debug"}"; + pname = "${crossNameAddon}${name}"; inherit version; builder = ../builder.sh; @@ -238,12 +235,14 @@ stdenv.mkDerivation ({ (targetPlatform == hostPlatform && hostPlatform == buildPlatform) (if profiledCompiler then "profiledbootstrap" else "bootstrap"); - dontStrip = !stripped; + inherit + (import ../common/strip-attributes.nix { inherit stdenv; }) + stripDebugList + stripDebugListTarget + preFixup; doCheck = false; # requires a lot of tools, causes a dependency cycle for stdenv - installTargets = optional stripped "install-strip"; - # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; @@ -297,8 +296,7 @@ stdenv.mkDerivation ({ meta = { homepage = "https://gcc.gnu.org/"; license = lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ - description = "GNU Compiler Collection, version ${version}" - + (if stripped then "" else " (with debugging info)"); + description = "GNU Compiler Collection, version ${version}"; longDescription = '' The GNU Compiler Collection includes compiler front ends for C, C++, diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix index 9d9dae41c45..cc675de2254 100644 --- a/pkgs/development/compilers/gcc/4.9/default.nix +++ b/pkgs/development/compilers/gcc/4.9/default.nix @@ -28,9 +28,6 @@ , libcCross ? null , threadsCross ? null # for MinGW , crossStageStatic ? false -, # Strip kills static libs of other archs (hence no cross) - stripped ? stdenv.hostPlatform == stdenv.buildPlatform - && stdenv.targetPlatform == stdenv.hostPlatform , gnused ? null , buildPackages }: @@ -140,7 +137,7 @@ in assert x11Support -> (filter (x: x == null) ([ gtk2 libart_lgpl ] ++ xlibs)) == []; stdenv.mkDerivation ({ - pname = "${crossNameAddon}${name}${if stripped then "" else "-debug"}"; + pname = "${crossNameAddon}${name}"; inherit version; builder = ../builder.sh; @@ -258,12 +255,14 @@ stdenv.mkDerivation ({ (targetPlatform == hostPlatform && hostPlatform == buildPlatform) (if profiledCompiler then "profiledbootstrap" else "bootstrap"); - dontStrip = !stripped; + inherit + (import ../common/strip-attributes.nix { inherit stdenv; }) + stripDebugList + stripDebugListTarget + preFixup; doCheck = false; # requires a lot of tools, causes a dependency cycle for stdenv - installTargets = optional stripped "install-strip"; - # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; @@ -316,8 +315,7 @@ stdenv.mkDerivation ({ meta = { homepage = "https://gcc.gnu.org/"; license = lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ - description = "GNU Compiler Collection, version ${version}" - + (if stripped then "" else " (with debugging info)"); + description = "GNU Compiler Collection, version ${version}"; longDescription = '' The GNU Compiler Collection includes compiler front ends for C, C++, diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix index a5be86ca052..d108dc11f18 100644 --- a/pkgs/development/compilers/gcc/6/default.nix +++ b/pkgs/development/compilers/gcc/6/default.nix @@ -31,9 +31,6 @@ , libcCross ? null , threadsCross ? null # for MinGW , crossStageStatic ? false -, # Strip kills static libs of other archs (hence no cross) - stripped ? stdenv.hostPlatform.system == stdenv.buildPlatform.system - && stdenv.targetPlatform.system == stdenv.hostPlatform.system , gnused ? null , cloog # unused; just for compat with gcc4, as we override the parameter on some places , buildPackages @@ -121,7 +118,7 @@ in assert x11Support -> (filter (x: x == null) ([ gtk2 libart_lgpl ] ++ xlibs)) == []; stdenv.mkDerivation ({ - pname = "${crossNameAddon}${name}${if stripped then "" else "-debug"}"; + pname = "${crossNameAddon}${name}"; inherit version; builder = ../builder.sh; @@ -270,12 +267,14 @@ stdenv.mkDerivation ({ (targetPlatform == hostPlatform && hostPlatform == buildPlatform) (if profiledCompiler then "profiledbootstrap" else "bootstrap"); - dontStrip = !stripped; + inherit + (import ../common/strip-attributes.nix { inherit stdenv; }) + stripDebugList + stripDebugListTarget + preFixup; doCheck = false; # requires a lot of tools, causes a dependency cycle for stdenv - installTargets = optional stripped "install-strip"; - # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; @@ -328,8 +327,7 @@ stdenv.mkDerivation ({ meta = { homepage = "https://gcc.gnu.org/"; license = lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ - description = "GNU Compiler Collection, version ${version}" - + (if stripped then "" else " (with debugging info)"); + description = "GNU Compiler Collection, version ${version}"; longDescription = '' The GNU Compiler Collection includes compiler front ends for C, C++, diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix index 7a9a6938fe7..e4e1f2038de 100644 --- a/pkgs/development/compilers/gcc/7/default.nix +++ b/pkgs/development/compilers/gcc/7/default.nix @@ -21,9 +21,6 @@ , libcCross ? null , threadsCross ? null # for MinGW , crossStageStatic ? false -, # Strip kills static libs of other archs (hence no cross) - stripped ? stdenv.hostPlatform.system == stdenv.buildPlatform.system - && stdenv.targetPlatform.system == stdenv.hostPlatform.system , gnused ? null , cloog # unused; just for compat with gcc4, as we override the parameter on some places , buildPackages @@ -94,7 +91,7 @@ let majorVersion = "7"; in stdenv.mkDerivation ({ - pname = "${crossNameAddon}${name}${if stripped then "" else "-debug"}"; + pname = "${crossNameAddon}${name}"; inherit version; builder = ../builder.sh; @@ -237,12 +234,14 @@ stdenv.mkDerivation ({ (targetPlatform == hostPlatform && hostPlatform == buildPlatform) (if profiledCompiler then "profiledbootstrap" else "bootstrap"); - dontStrip = !stripped; + inherit + (import ../common/strip-attributes.nix { inherit stdenv; }) + stripDebugList + stripDebugListTarget + preFixup; doCheck = false; # requires a lot of tools, causes a dependency cycle for stdenv - installTargets = optional stripped "install-strip"; - # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; @@ -282,8 +281,7 @@ stdenv.mkDerivation ({ meta = { homepage = "https://gcc.gnu.org/"; license = lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ - description = "GNU Compiler Collection, version ${version}" - + (if stripped then "" else " (with debugging info)"); + description = "GNU Compiler Collection, version ${version}"; longDescription = '' The GNU Compiler Collection includes compiler front ends for C, C++, diff --git a/pkgs/development/compilers/gcc/8/default.nix b/pkgs/development/compilers/gcc/8/default.nix index 427244016ae..7e94ec61c6b 100644 --- a/pkgs/development/compilers/gcc/8/default.nix +++ b/pkgs/development/compilers/gcc/8/default.nix @@ -21,9 +21,6 @@ , libcCross ? null , threadsCross ? null # for MinGW , crossStageStatic ? false -, # Strip kills static libs of other archs (hence no cross) - stripped ? stdenv.hostPlatform.system == stdenv.buildPlatform.system - && stdenv.targetPlatform.system == stdenv.hostPlatform.system , gnused ? null , cloog # unused; just for compat with gcc4, as we override the parameter on some places , buildPackages @@ -78,7 +75,7 @@ let majorVersion = "8"; in stdenv.mkDerivation ({ - pname = "${crossNameAddon}${name}${if stripped then "" else "-debug"}"; + pname = "${crossNameAddon}${name}"; inherit version; builder = ../builder.sh; @@ -218,9 +215,11 @@ stdenv.mkDerivation ({ (targetPlatform == hostPlatform && hostPlatform == buildPlatform) (if profiledCompiler then "profiledbootstrap" else "bootstrap"); - dontStrip = !stripped; - - installTargets = optional stripped "install-strip"; + inherit + (import ../common/strip-attributes.nix { inherit stdenv; }) + stripDebugList + stripDebugListTarget + preFixup; # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; @@ -261,8 +260,7 @@ stdenv.mkDerivation ({ meta = { homepage = "https://gcc.gnu.org/"; license = lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ - description = "GNU Compiler Collection, version ${version}" - + (if stripped then "" else " (with debugging info)"); + description = "GNU Compiler Collection, version ${version}"; longDescription = '' The GNU Compiler Collection includes compiler front ends for C, C++, diff --git a/pkgs/development/compilers/gcc/9/default.nix b/pkgs/development/compilers/gcc/9/default.nix index 60256036445..707ead542f0 100644 --- a/pkgs/development/compilers/gcc/9/default.nix +++ b/pkgs/development/compilers/gcc/9/default.nix @@ -24,9 +24,6 @@ , libcCross ? null , threadsCross ? null # for MinGW , crossStageStatic ? false -, # Strip kills static libs of other archs (hence no cross) - stripped ? stdenv.hostPlatform.system == stdenv.buildPlatform.system - && stdenv.targetPlatform.system == stdenv.hostPlatform.system , gnused ? null , cloog # unused; just for compat with gcc4, as we override the parameter on some places , buildPackages @@ -89,7 +86,7 @@ let majorVersion = "9"; in stdenv.mkDerivation ({ - pname = "${crossNameAddon}${name}${if stripped then "" else "-debug"}"; + pname = "${crossNameAddon}${name}"; inherit version; builder = ../builder.sh; @@ -233,9 +230,11 @@ stdenv.mkDerivation ({ (targetPlatform == hostPlatform && hostPlatform == buildPlatform) (if profiledCompiler then "profiledbootstrap" else "bootstrap"); - dontStrip = !stripped; - - installTargets = optional stripped "install-strip"; + inherit + (import ../common/strip-attributes.nix { inherit stdenv; }) + stripDebugList + stripDebugListTarget + preFixup; # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; @@ -276,8 +275,7 @@ stdenv.mkDerivation ({ meta = { homepage = "https://gcc.gnu.org/"; license = lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ - description = "GNU Compiler Collection, version ${version}" - + (if stripped then "" else " (with debugging info)"); + description = "GNU Compiler Collection, version ${version}"; longDescription = '' The GNU Compiler Collection includes compiler front ends for C, C++, diff --git a/pkgs/development/compilers/gcc/builder.sh b/pkgs/development/compilers/gcc/builder.sh index 187bf840682..a9b33d9a3e4 100644 --- a/pkgs/development/compilers/gcc/builder.sh +++ b/pkgs/development/compilers/gcc/builder.sh @@ -147,11 +147,6 @@ if test "$noSysDirs" = "1"; then fi fi -if [ -n "${targetConfig-}" ]; then - # if stripping gcc, include target directory too - stripDebugList="${stripDebugList-lib lib32 lib64 libexec bin sbin} $targetConfig" -fi - eval "$oldOpts" providedPreConfigure="$preConfigure"; diff --git a/pkgs/development/compilers/gcc/common/strip-attributes.nix b/pkgs/development/compilers/gcc/common/strip-attributes.nix new file mode 100644 index 00000000000..997c068cba6 --- /dev/null +++ b/pkgs/development/compilers/gcc/common/strip-attributes.nix @@ -0,0 +1,53 @@ +{ stdenv }: + +{ + # Note [Cross-compiler stripping] + # gcc requires delicate stripping as it installs ELF files for both + # HOST and TARGET platforms. It requires according strip tool otherwise + # strip could remove sections it's not aware of. + # Example ARM breakage by x86_64 strip: https://bugs.gentoo.org/697428 + # + # Let's recap the file layout for directories with object files for a + # cross-compiler (host != target): + # `- bin: HOST + # lib/*.{a,o}: HOST + # `- gcc/<TARGET>/<VERSION>/*.{a,o}: TARGET + # `- plugin/: HOST + # `- lib{,32,64,x32}: symlink to lib or identical layout + # `- libexec/: HOST + # `- <TARGET>/: TARGET + # + # (host == target) has identical directory layout. + + # The rest of stripDebugList{Host,Target} will be populated in + # postInstall. + stripDebugList = [ "bin" "libexec" ]; + stripDebugListTarget = [ stdenv.targetPlatform.config ]; + + preFixup = '' + # Populate most delicated lib/ part of stripDebugList{,Target} + updateDebugListPaths() { + local oldOpts + oldOpts="$(shopt -p nullglob)" || true + shopt -s nullglob + + pushd $out + + local -ar hostFiles=( + lib{,32,64}/*.{a.o} + lib{,32,64}/gcc/${stdenv.targetPlatform.config}/*/plugin + ) + local -ar targetFiles=( + lib{,32,64}/gcc/${stdenv.targetPlatform.config}/*/*.{a.o} + ) + + stripDebugList="$stripDebugList ''${hostFiles[*]}" + stripDebugListTarget="$stripDebugListTarget ''${targetFiles[*]}" + + popd + + eval "$oldOpts" + } + updateDebugListPaths + ''; +} |