Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests-stdenv-gcc-stageCompare: cleanup #316011

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 39 additions & 19 deletions pkgs/test/stdenv/gcc-stageCompare.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,45 @@
# must remember to do the check.
#

{ stdenv
, pkgs
, lib
{ lib
, stdenv
, runCommand
, overrideCC
, wrapCCWith
}:

assert stdenv.cc.isGNU;
with pkgs;
# rebuild gcc using the "final" stdenv
let gcc-stageCompare = (gcc-unwrapped.override {
reproducibleBuild = true;
profiledCompiler = false;
stdenv = overrideCC stdenv (wrapCCWith {
cc = stdenv.cc;
});
}).overrideAttrs(_: {
NIX_OUTPATH_USED_AS_RANDOM_SEED = stdenv.cc.cc.out;
let
inherit (stdenv.cc) cc;
in

assert cc.isGNU;

# Rebuild gcc using the "final" stdenv.
let
rebuiltCC = (cc.override {
reproducibleBuild = true;
profiledCompiler = false;
stdenv = overrideCC stdenv (wrapCCWith {
inherit cc;
});
in (runCommand "gcc-stageCompare" {} ''
diff -sr ${pkgs.gcc-unwrapped.checksum}/checksums ${gcc-stageCompare.checksum}/checksums && touch $out
'').overrideAttrs (a: {
meta = (a.meta or { }) // { platforms = lib.platforms.linux; };
})
}).overrideAttrs (_: {
# TODO: do we really have to set random seed? This likely won’t work with
# content-addressed derivations, and also GCC expects random seed to be
# different for each file (but that is an issue with stdenv in general).
# https://gcc.gnu.org/onlinedocs/gcc-14.1.0/gcc/Developer-Options.html#index-frandom-seed
# >The string should be different for every file you compile.
NIX_OUTPATH_USED_AS_RANDOM_SEED = cc.out;
});

cmdArgs = {
checksumBefore = cc.checksum;
checksumAfter = rebuiltCC.checksum;
meta.platforms = lib.platforms.linux;
};
in
runCommand "gcc-stageCompare" cmdArgs ''
diff --report-identical-files --recursive -- \
"$checksumBefore"/checksums \
"$checksumAfter"/checksums
touch $out
''