Unverified Commit cdf448de authored by Brian McGillion's avatar Brian McGillion
Browse files

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 c7b9734f ("edk2: move env variable(s) into
  env for structuredAttrs").

Signed-off-by: default avatarBrian McGillion <bmg.avoin@gmail.com>
parent 1d784f7a
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -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 { });
        }
      );
  };
})