Merge pull request #240247 from amjoseph-nixpkgs/libgcc-deduplicate

gcc: deduplicate boilerplate
This commit is contained in:
Adam Joseph 2023-06-29 22:26:25 +00:00 committed by GitHub
commit b1434f14da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 75 additions and 68 deletions

View File

@ -27,6 +27,7 @@
, cloog ? null # unused; just for compat with gcc4, as we override the parameter on some places
, buildPackages
, libxcrypt
, callPackage
}:
# Make sure we get GNU sed.
@ -143,7 +144,7 @@ let majorVersion = "10";
in
stdenv.mkDerivation ({
lib.pipe (stdenv.mkDerivation ({
pname = "${crossNameAddon}${name}";
inherit version;
@ -291,10 +292,8 @@ stdenv.mkDerivation ({
}
// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) {
makeFlags = [ "all-gcc" "all-target-libgcc" ];
installTargets = "install-gcc install-target-libgcc";
}
// optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
)
))
[
(callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform crossStageStatic; })
]

View File

@ -304,14 +304,9 @@ lib.pipe (stdenv.mkDerivation ({
};
}
// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) {
makeFlags = [ "all-gcc" "all-target-libgcc" ];
installTargets = "install-gcc install-target-libgcc";
}
// optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
))
[
(callPackage ../common/libgcc.nix { inherit langC langCC langJit; })
(callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform crossStageStatic; })
(callPackage ../common/checksum.nix { inherit langC langCC; })
]

View File

@ -350,15 +350,10 @@ lib.pipe (stdenv.mkDerivation ({
};
}
// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) {
makeFlags = [ "all-gcc" "all-target-libgcc" ];
installTargets = "install-gcc install-target-libgcc";
}
// optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
))
[
(callPackage ../common/libgcc.nix { inherit langC langCC langJit; })
(callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform crossStageStatic; })
(callPackage ../common/checksum.nix { inherit langC langCC; })
]

View File

@ -344,15 +344,10 @@ lib.pipe (stdenv.mkDerivation ({
};
}
// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) {
makeFlags = [ "all-gcc" "all-target-libgcc" ];
installTargets = "install-gcc install-target-libgcc";
}
// optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
))
[
(callPackage ../common/libgcc.nix { inherit langC langCC langJit; })
(callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform crossStageStatic; })
(callPackage ../common/checksum.nix { inherit langC langCC; })
]

View File

@ -29,6 +29,7 @@
, crossStageStatic ? false
, gnused ? null
, buildPackages
, callPackage
}:
assert langJava -> zip != null && unzip != null
@ -192,7 +193,7 @@ in
# We need all these X libraries when building AWT with GTK.
assert x11Support -> (filter (x: x == null) ([ gtk2 libart_lgpl ] ++ xlibs)) == [];
stdenv.mkDerivation ({
lib.pipe (stdenv.mkDerivation ({
pname = "${crossNameAddon}${name}";
inherit version;
@ -319,10 +320,8 @@ stdenv.mkDerivation ({
};
}
// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) {
makeFlags = [ "all-gcc" "all-target-libgcc" ];
installTargets = "install-gcc install-target-libgcc";
}
// optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
)
))
[
(callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform crossStageStatic; })
]

View File

@ -29,6 +29,7 @@
, crossStageStatic ? false
, gnused ? null
, buildPackages
, callPackage
}:
assert langJava -> zip != null && unzip != null
@ -209,7 +210,7 @@ in
# We need all these X libraries when building AWT with GTK.
assert x11Support -> (filter (x: x == null) ([ gtk2 libart_lgpl ] ++ xlibs)) == [];
stdenv.mkDerivation ({
lib.pipe (stdenv.mkDerivation ({
pname = "${crossNameAddon}${name}";
inherit version;
@ -340,11 +341,6 @@ stdenv.mkDerivation ({
};
}
// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) {
makeFlags = [ "all-gcc" "all-target-libgcc" ];
installTargets = "install-gcc install-target-libgcc";
}
// optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
// optionalAttrs (langJava) {
@ -352,4 +348,7 @@ stdenv.mkDerivation ({
target="$(echo "$out/libexec/gcc"/*/*/ecj*)"
patchelf --set-rpath "$(patchelf --print-rpath "$target"):$out/lib" "$target"
'';}
)
))
[
(callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform crossStageStatic; })
]

View File

@ -33,6 +33,7 @@
, gnused ? null
, cloog ? null # unused; just for compat with gcc4, as we override the parameter on some places
, buildPackages
, callPackage
}:
assert langJava -> zip != null && unzip != null
@ -198,7 +199,7 @@ in
# We need all these X libraries when building AWT with GTK.
assert x11Support -> (filter (x: x == null) ([ gtk2 libart_lgpl ] ++ xlibs)) == [];
stdenv.mkDerivation ({
lib.pipe (stdenv.mkDerivation ({
pname = "${crossNameAddon}${name}";
inherit version;
@ -358,11 +359,6 @@ stdenv.mkDerivation ({
};
}
// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) {
makeFlags = [ "all-gcc" "all-target-libgcc" ];
installTargets = "install-gcc install-target-libgcc";
}
// optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
// optionalAttrs (langJava && !stdenv.hostPlatform.isDarwin) {
@ -370,4 +366,7 @@ stdenv.mkDerivation ({
target="$(echo "$out/libexec/gcc"/*/*/ecj*)"
patchelf --set-rpath "$(patchelf --print-rpath "$target"):$out/lib" "$target"
'';}
)
))
[
(callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform crossStageStatic; })
]

View File

@ -23,6 +23,7 @@
, gnused ? null
, cloog ? null # unused; just for compat with gcc4, as we override the parameter on some places
, buildPackages
, callPackage
}:
# Make sure we get GNU sed.
@ -148,7 +149,7 @@ let majorVersion = "7";
in
stdenv.mkDerivation ({
lib.pipe (stdenv.mkDerivation ({
pname = "${crossNameAddon}${name}";
inherit version;
@ -298,10 +299,8 @@ stdenv.mkDerivation ({
};
}
// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) {
makeFlags = [ "all-gcc" "all-target-libgcc" ];
installTargets = "install-gcc install-target-libgcc";
}
// optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
)
))
[
(callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform crossStageStatic; })
]

View File

@ -23,6 +23,7 @@
, gnused ? null
, cloog ? null # unused; just for compat with gcc4, as we override the parameter on some places
, buildPackages
, callPackage
}:
# Make sure we get GNU sed.
@ -129,7 +130,7 @@ let majorVersion = "8";
in
stdenv.mkDerivation ({
lib.pipe (stdenv.mkDerivation ({
pname = "${crossNameAddon}${name}";
inherit version;
@ -273,10 +274,8 @@ stdenv.mkDerivation ({
};
}
// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) {
makeFlags = [ "all-gcc" "all-target-libgcc" ];
installTargets = "install-gcc install-target-libgcc";
}
// optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
)
))
[
(callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform crossStageStatic; })
]

View File

@ -26,6 +26,7 @@
, gnused ? null
, cloog # unused; just for compat with gcc4, as we override the parameter on some places
, buildPackages
, callPackage
}:
# Note: this package is used for bootstrapping fetchurl, and thus
@ -143,7 +144,7 @@ let majorVersion = "9";
in
stdenv.mkDerivation ({
lib.pipe (stdenv.mkDerivation ({
pname = "${crossNameAddon}${name}";
inherit version;
@ -287,10 +288,9 @@ stdenv.mkDerivation ({
};
}
// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) {
makeFlags = [ "all-gcc" "all-target-libgcc" ];
installTargets = "install-gcc install-target-libgcc";
}
// optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
)
) [
(callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform crossStageStatic; })
]

View File

@ -1,16 +1,43 @@
{ lib
, stdenv
, version
, langC
, langCC
, langJit
, targetPlatform
, hostPlatform
, crossStageStatic
}:
let
drv: lib.pipe drv
([
(pkg: pkg.overrideAttrs (previousAttrs:
lib.optionalAttrs (
targetPlatform != hostPlatform &&
targetPlatform.libc == "msvcrt" &&
crossStageStatic
) {
makeFlags = [ "all-gcc" "all-target-libgcc" ];
installTargets = "install-gcc install-target-libgcc";
}))
] ++
# nixpkgs did not add the "libgcc" output until gcc11. In theory
# the following condition can be changed to `true`, but that has not
# been tested.
lib.optional (lib.versionAtLeast version "11.0")
(let
enableLibGccOutput =
(with stdenv; targetPlatform == hostPlatform) &&
!langJit &&
!stdenv.hostPlatform.isDarwin &&
!stdenv.hostPlatform.isStatic;
!stdenv.hostPlatform.isStatic
;
in
(pkg: pkg.overrideAttrs (previousAttrs: lib.optionalAttrs ((!langC) || langJit || enableLibGccOutput) {
outputs = previousAttrs.outputs ++ lib.optionals enableLibGccOutput [ "libgcc" ];
@ -97,4 +124,5 @@ in
+ ''
patchelf --set-rpath "" $libgcc/lib/libgcc_s.so.1
'');
}))
}))))