edk2: Fix cross-compile

deep-merge env in mkDerivation to preserve GCC5 prefix

  The shallow `//` merge in edk2.mkDerivation allowed consumers' `env`
  attrs to completely overwrite the base `env` containing GCC5_*_PREFIX,
  causing cross-compilation failures (e.g. x86_64 -> aarch64 OVMF) with
  `gcc: error: unrecognized command-line option '-mlittle-endian'`.

  Exclude `env` from the consumer attrs spread and explicitly deep-merge
  it, ensuring GCC5_*_PREFIX is always set as a base while consumer `env`
  keys (NIX_CFLAGS_COMPILE, PYTHON_COMMAND, etc.) are merged on top.

  Fixes regression from c7b9734f4a ("edk2: move env variable(s) into
  env for structuredAttrs").

Signed-off-by: Brian McGillion <bmg.avoin@gmail.com>
This commit is contained in:
Brian McGillion 2026-03-07 09:55:35 +04:00
parent 1d784f7a68
commit cdf448de60
No known key found for this signature in database

View file

@ -182,8 +182,6 @@ stdenv.mkDerivation (finalAttrs: {
++ attrs.nativeBuildInputs or [ ];
strictDeps = true;
env.${"GCC5_${targetArch}_PREFIX"} = stdenv.cc.targetPrefix;
prePatch = ''
rm -rf BaseTools
ln -sv ${buildPackages.edk2}/BaseTools BaseTools
@ -211,7 +209,14 @@ stdenv.mkDerivation (finalAttrs: {
// removeAttrs attrs [
"nativeBuildInputs"
"depsBuildBuild"
"env"
]
// {
env = {
${"GCC5_${targetArch}_PREFIX"} = stdenv.cc.targetPrefix;
}
// (attrs.env or { });
}
);
};
})