nxp: imx93-evk: fix cross-build of mkimage host tools

When building the imx93 SD image from x86_64, imx93-boot used target pkgs for
the imx-mkimage derivation and its native tools (git, dtc, xxd). mkimage runs on
the build machine, but Nix tried to cross-compile git for aarch64 and failed
with "linker `cc` not found" while building libgitcore, blocking flash.bin and
the SD image.

Build mkimage with buildPackages (host tools) while keeping firmware inputs
(ATF, U-Boot, OP-TEE, etc.) from target pkgs.
This commit is contained in:
Govind Singh 2026-06-05 08:20:07 +04:00
parent e678820fd5
commit d66213a72e

View file

@ -1,8 +1,8 @@
{
pkgs,
}:
with pkgs;
let
bp = pkgs.buildPackages;
imx93-atf = pkgs.callPackage ./imx93-atf.nix { };
imx93-firmware = pkgs.callPackage ./imx93-firmware.nix { };
@ -17,7 +17,8 @@ let
shortRev = builtins.substring 0 8 src.rev;
in
{
imx93-boot = pkgs.stdenv.mkDerivation rec {
# mkimage runs on the build machine; use buildPackages when cross-compiling.
imx93-boot = bp.stdenv.mkDerivation {
inherit src;
name = "imx93-mkimage";
version = "lf-6.12.3";
@ -25,28 +26,22 @@ in
postPatch = ''
substituteInPlace Makefile \
--replace 'git rev-parse --short=8 HEAD' 'echo ${shortRev}'
substituteInPlace Makefile \
--replace 'CC = gcc' 'CC = clang'
substituteInPlace iMX93/soc.mak \
--replace 'xxd' "${pkgs.vim.xxd}/bin/xxd"
--replace 'xxd' "${bp.vim.xxd}/bin/xxd"
substituteInPlace scripts/fspi_fcb_gen.sh \
--replace 'xxd' "${pkgs.vim.xxd}/bin/xxd"
--replace 'xxd' "${bp.vim.xxd}/bin/xxd"
substituteInPlace scripts/fspi_packer.sh \
--replace 'xxd' "${pkgs.vim.xxd}/bin/xxd"
--replace 'xxd' "${bp.vim.xxd}/bin/xxd"
patchShebangs scripts
'';
nativeBuildInputs = [
clang
git
dtc
];
buildInputs = [
git
glibc.static
zlib
zlib.static
bp.stdenv.cc
bp.git
bp.dtc
bp.glibc.static
bp.zlib
bp.zlib.static
];
buildPhase = ''