From 2abf285e2be0810c49bd8e5834fe34298bf83c26 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Wed, 5 Apr 2023 22:15:10 -0700 Subject: [PATCH 1/2] stdenv/linux: add is{From,BuiltBy} assertions for patchelf --- pkgs/stdenv/linux/default.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index ddfbc11b6405..d53a1902b448 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -322,6 +322,7 @@ in assert isFromBootstrapFiles prevStage.gcc-unwrapped; assert isFromBootstrapFiles prevStage.coreutils; assert isFromBootstrapFiles prevStage.gnugrep; + assert isBuiltByBootstrapFilesCompiler prevStage.patchelf; stageFun prevStage { name = "bootstrap-stage-xgcc"; overrides = final: prev: { @@ -399,6 +400,7 @@ in assert isBuiltByBootstrapFilesCompiler prevStage.gcc-unwrapped; assert isFromBootstrapFiles prevStage.coreutils; assert isFromBootstrapFiles prevStage.gnugrep; + assert isFromBootstrapFiles prevStage.patchelf; stageFun prevStage { name = "bootstrap-stage2"; @@ -476,6 +478,7 @@ in assert isBuiltByBootstrapFilesCompiler prevStage.gcc-unwrapped; assert isFromBootstrapFiles prevStage.coreutils; assert isFromBootstrapFiles prevStage.gnugrep; + assert isBuiltByNixpkgsCompiler prevStage.patchelf; assert lib.all isBuiltByNixpkgsCompiler (with prevStage; [ gmp isl_0_20 libmpc mpfr ]); stageFun prevStage { name = "bootstrap-stage3"; @@ -516,6 +519,7 @@ in assert isBuiltByNixpkgsCompiler prevStage.gcc-unwrapped; assert isFromBootstrapFiles prevStage.coreutils; assert isFromBootstrapFiles prevStage.gnugrep; + assert isBuiltByNixpkgsCompiler prevStage.patchelf; stageFun prevStage { name = "bootstrap-stage4"; @@ -576,6 +580,7 @@ in assert isBuiltByNixpkgsCompiler prevStage.gcc-unwrapped; assert isBuiltByNixpkgsCompiler prevStage.coreutils; assert isBuiltByNixpkgsCompiler prevStage.gnugrep; + assert isBuiltByNixpkgsCompiler prevStage.patchelf; { inherit config overlays; stdenv = import ../generic rec { @@ -665,5 +670,6 @@ in assert isBuiltByNixpkgsCompiler prevStage.gcc-unwrapped; assert isBuiltByNixpkgsCompiler prevStage.coreutils; assert isBuiltByNixpkgsCompiler prevStage.gnugrep; + assert isBuiltByNixpkgsCompiler prevStage.patchelf; { inherit (prevStage) config overlays stdenv; }) ] From 1847b1bc153c1f128c4b37447b4bbb48875b72e3 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Wed, 5 Apr 2023 22:15:42 -0700 Subject: [PATCH 2/2] stdenv/linux: fix patchelf confusion The stage before `xgcc` creates the first compiled patchelf (i.e. not from bootstrapFiles). The `xgcc` stage was inadvertently switching *back* to using the patchelf *from* the bootstrapFiles. The first commit in this PR adds self-checking comments (assertions) to make it clear where each stage's patchelf comes from. The second commit fixes the bug, and updates the self-checking comments. --- pkgs/stdenv/linux/default.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index d53a1902b448..6bf114a730cf 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -326,8 +326,7 @@ in stageFun prevStage { name = "bootstrap-stage-xgcc"; overrides = final: prev: { - inherit (prevStage) ccWrapperStdenv coreutils gnugrep gettext bison texinfo zlib gnum4 perl; - patchelf = bootstrapTools; + inherit (prevStage) ccWrapperStdenv coreutils gnugrep gettext bison texinfo zlib gnum4 perl patchelf; ${localSystem.libc} = getLibc prevStage; gmp = prev.gmp.override { cxx = false; }; gcc-unwrapped = @@ -400,7 +399,7 @@ in assert isBuiltByBootstrapFilesCompiler prevStage.gcc-unwrapped; assert isFromBootstrapFiles prevStage.coreutils; assert isFromBootstrapFiles prevStage.gnugrep; - assert isFromBootstrapFiles prevStage.patchelf; + assert isBuiltByBootstrapFilesCompiler prevStage.patchelf; stageFun prevStage { name = "bootstrap-stage2";