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

gcc: deduplicate boilerplate

Changed files
+75 -68
pkgs
+6 -7
pkgs/development/compilers/gcc/10/default.nix
···
, 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.
···
in
-
stdenv.mkDerivation ({
+
lib.pipe (stdenv.mkDerivation ({
pname = "${crossNameAddon}${name}";
inherit version;
···
}
-
// 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; })
+
]
+1 -6
pkgs/development/compilers/gcc/11/default.nix
···
};
}
-
// 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; })
]
+1 -6
pkgs/development/compilers/gcc/12/default.nix
···
};
}
-
// 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; })
]
+1 -6
pkgs/development/compilers/gcc/13/default.nix
···
};
}
-
// 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; })
]
+6 -7
pkgs/development/compilers/gcc/4.8/default.nix
···
, crossStageStatic ? false
, gnused ? null
, buildPackages
+
, callPackage
}:
assert langJava -> zip != null && unzip != null
···
# 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;
···
};
}
-
// 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; })
+
]
+6 -7
pkgs/development/compilers/gcc/4.9/default.nix
···
, crossStageStatic ? false
, gnused ? null
, buildPackages
+
, callPackage
}:
assert langJava -> zip != null && unzip != null
···
# 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;
···
};
}
-
// 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) {
···
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; })
+
]
+6 -7
pkgs/development/compilers/gcc/6/default.nix
···
, 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
···
# 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;
···
};
}
-
// 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) {
···
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; })
+
]
+6 -7
pkgs/development/compilers/gcc/7/default.nix
···
, 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.
···
in
-
stdenv.mkDerivation ({
+
lib.pipe (stdenv.mkDerivation ({
pname = "${crossNameAddon}${name}";
inherit version;
···
};
}
-
// 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; })
+
]
+6 -7
pkgs/development/compilers/gcc/8/default.nix
···
, 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.
···
in
-
stdenv.mkDerivation ({
+
lib.pipe (stdenv.mkDerivation ({
pname = "${crossNameAddon}${name}";
inherit version;
···
};
}
-
// 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; })
+
]
+5 -5
pkgs/development/compilers/gcc/9/default.nix
···
, 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
···
in
-
stdenv.mkDerivation ({
+
lib.pipe (stdenv.mkDerivation ({
pname = "${crossNameAddon}${name}";
inherit version;
···
};
}
-
// 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; })
+
]
+31 -3
pkgs/development/compilers/gcc/common/libgcc.nix
···
{ 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" ];
···
+ ''
patchelf --set-rpath "" $libgcc/lib/libgcc_s.so.1
'');
-
}))
+
}))))
+