[PATCH v4] Makefile: detect HOST_ARCH properly when CROSS_COMPILE is multi-word
Jerome Forissier
jerome.forissier at linaro.org
Thu Nov 14 11:21:38 CET 2024
When CROSS_COMPILE contains multiple words, HOST_ARCH is not properly
detected and the build may fail. It typically happens when using
ccache. For example:
$ make qemu_arm64_defconfig
$ make CROSS_COMPILE="ccache aarch64-linux-gnu-"
CC lib/efi_loader/efi_helper.o
lib/efi_loader/efi_helper.c:26:15: error: operator '==' has no left operand
26 | #if HOST_ARCH == HOST_ARCH_X86_64
| ^~
[...]
Fix the issue by considering only the last word in $(CROSS_COMPILE).
Signed-off-by: Jerome Forissier <jerome.forissier at linaro.org>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Note that this patch was already proposed to fix an issue with the
sandbox build, which was addressed in a different manner [1].
Now the problem crops up again and I bisected it down to commit
7506c1566998 ("sandbox: Report host default-filename in native mode").
In any case there is no reason to have an invalid HOST_ARCH and
this patch does fix it.
[1] https://lore.kernel.org/u-boot/f06b0774-d47c-4414-9974-89d2ebbf1902@linaro.org/
diff --git a/Makefile b/Makefile
index da742ceae76..fbc876c1b83 100644
--- a/Makefile
+++ b/Makefile
@@ -21,7 +21,7 @@ include include/host_arch.h
ifeq ("", "$(CROSS_COMPILE)")
MK_ARCH="${shell uname -m}"
else
- MK_ARCH="${shell echo $(CROSS_COMPILE) | sed -n 's/^[[:space:]]*\([^\/]*\/\)*\([^-]*\)-[^[:space:]]*/\2/p'}"
+ MK_ARCH="${shell echo ${lastword $(CROSS_COMPILE)} | sed -n 's/^[[:space:]]*\([^\/]*\/\)*\([^-]*\)-[^[:space:]]*/\2/p'}"
endif
unexport HOST_ARCH
ifeq ("x86_64", $(MK_ARCH))
--
2.40.1
More information about the U-Boot
mailing list