gcc: add common/checksum.nix
This commit adds `gcc/common/checksum.nix`, which contains code common to both gcc11 and gcc12, implementing the `enableChecksum` feature. When gcc's built-in bootstrap (`--enable-bootstrap`) is used, gcc compiles itself three times and compares a hash of the unlinked `.o` files from the second and third compilation. The `enableChecksum=true` parameter performs the same comparison as part of the `postInstall` phase. Notably, `enableChecksum=true` can be used with `enableBootstrap=false`. Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
This commit is contained in:
parent
fed2300bea
commit
96588eb3de
@ -28,6 +28,8 @@
|
||||
, buildPackages
|
||||
, libxcrypt
|
||||
, disableGdbPlugin ? !enablePlugin
|
||||
, nukeReferences
|
||||
, callPackage
|
||||
}:
|
||||
|
||||
# Make sure we get GNU sed.
|
||||
@ -312,4 +314,5 @@ lib.pipe (stdenv.mkDerivation ({
|
||||
))
|
||||
[
|
||||
(callPackage ../common/libgcc.nix { inherit langC langCC langJit; })
|
||||
(callPackage ../common/checksum.nix { inherit langC langCC; })
|
||||
]
|
||||
|
@ -29,6 +29,8 @@
|
||||
, buildPackages
|
||||
, libxcrypt
|
||||
, disableGdbPlugin ? !enablePlugin
|
||||
, nukeReferences
|
||||
, callPackage
|
||||
}:
|
||||
|
||||
# Make sure we get GNU sed.
|
||||
@ -177,6 +179,7 @@ let majorVersion = "12";
|
||||
mpfr
|
||||
name
|
||||
noSysDirs
|
||||
nukeReferences
|
||||
patchelf
|
||||
perl
|
||||
profiledCompiler
|
||||
@ -347,5 +350,6 @@ lib.pipe (stdenv.mkDerivation ({
|
||||
))
|
||||
[
|
||||
(callPackage ../common/libgcc.nix { inherit langC langCC langJit; })
|
||||
(callPackage ../common/checksum.nix { inherit langC langCC; })
|
||||
]
|
||||
|
||||
|
39
pkgs/development/compilers/gcc/common/checksum.nix
Normal file
39
pkgs/development/compilers/gcc/common/checksum.nix
Normal file
@ -0,0 +1,39 @@
|
||||
{ lib
|
||||
, stdenv
|
||||
, nukeReferences
|
||||
, langC
|
||||
, langCC
|
||||
}:
|
||||
|
||||
let
|
||||
enableChecksum = (with stdenv; buildPlatform == hostPlatform && hostPlatform == targetPlatform) && langC && langCC;
|
||||
in
|
||||
(pkg: pkg.overrideAttrs (previousAttrs: lib.optionalAttrs enableChecksum {
|
||||
outputs = previousAttrs.outputs ++ lib.optionals enableChecksum [ "checksum" ];
|
||||
# This is a separate phase because gcc assembles its phase scripts
|
||||
# in bash instead of nix (we should fix that).
|
||||
preFixupPhases = (previousAttrs.preFixupPhases or []) ++ [ "postInstallSaveChecksumPhase" ];
|
||||
#
|
||||
# gcc uses an auxiliary utility `genchecksum` to md5-hash (most of) its
|
||||
# `.o` and `.a` files prior to linking (in case the linker is
|
||||
# nondeterministic). Since we want to compare across gccs built from two
|
||||
# separate derivations, we wrap `genchecksum` with a `nuke-references`
|
||||
# call. We also stash copies of the inputs to `genchecksum` in
|
||||
# `$checksum/inputs/` -- this is extremely helpful for debugging since
|
||||
# it's hard to get Nix to not delete the $NIX_BUILD_TOP of a successful
|
||||
# build.
|
||||
#
|
||||
postInstallSaveChecksumPhase = ''
|
||||
mv gcc/build/genchecksum gcc/build/.genchecksum-wrapped
|
||||
cat > gcc/build/genchecksum <<\EOF
|
||||
#!${runtimeShell}
|
||||
${nukeReferences}/bin/nuke-refs $@
|
||||
for INPUT in "$@"; do install -Dt $INPUT $checksum/inputs/; done
|
||||
exec build/.genchecksum-wrapped $@
|
||||
EOF
|
||||
chmod +x gcc/build/genchecksum
|
||||
rm gcc/*-checksum.*
|
||||
make -C gcc cc1-checksum.o cc1plus-checksum.o
|
||||
install -Dt $checksum/checksums/ gcc/cc*-checksum.o
|
||||
'';
|
||||
}))
|
@ -331,8 +331,6 @@ in
|
||||
gmp = prev.gmp.override { cxx = false; };
|
||||
gcc-unwrapped =
|
||||
(prev.gcc-unwrapped.override (commonGccOverrides // {
|
||||
enablePlugins = false;
|
||||
|
||||
# The most logical name for this package would be something like
|
||||
# "gcc-stage1". Unfortunately "stage" is already reserved for the
|
||||
# layers of stdenv, so using "stage" in the name of this package
|
||||
|
Loading…
Reference in New Issue
Block a user