Skip to content

Commit dd4a49a

Browse files
committed
Make: Detect arm-embedded architecture cross compilation target
test/mk/compiler.mk has logic for detecting the target architecture, taking into account both the host architecture and, if present, the cross prefix. Previously, cross-compilation for embedded Arm targets was not recognized, and the host architecture (e.g. AArch64 or x86_64) chosen as the target architecture. This would lead to compilation failures because the makefiles would later set MLK_FORCE_XXX based on the arch, contradicting the actual target of the (cross)-compilation. This commit fixes the issue by betecting arm embedded cross compilation targets. This commit also modifies the Makefiles to not fall back to the host architecture as the target architecture if a cross prefix is set but not recognized. Signed-off-by: Hanno Becker <[email protected]>
1 parent e28499d commit dd4a49a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

test/mk/compiler.mk

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
ifndef _COMPILER_MK
1414
_COMPILER_MK :=
1515

16-
# Normalize architecture names
16+
17+
# Override ARCH for cross-compilation based on CROSS_PREFIX
18+
ifeq ($(CROSS_PREFIX),)
1719
ARCH := $(shell uname -m)
20+
# Normalize architecture names
1821
ifeq ($(ARCH),arm64)
1922
ARCH := aarch64
2023
endif
21-
22-
# Override ARCH for cross-compilation based on CROSS_PREFIX
23-
ifneq ($(CROSS_PREFIX),)
24+
else # CROSS_PREFIX
2425
ifneq ($(findstring x86_64, $(CROSS_PREFIX)),)
2526
ARCH := x86_64
2627
else ifneq ($(findstring aarch64_be, $(CROSS_PREFIX)),)
@@ -33,6 +34,10 @@ else ifneq ($(findstring riscv32, $(CROSS_PREFIX)),)
3334
ARCH := riscv32
3435
else ifneq ($(findstring powerpc64le, $(CROSS_PREFIX)),)
3536
ARCH := powerpc64le
37+
else ifneq ($(findstring arm-none-eabi-, $(CROSS_PREFIX)),)
38+
ARCH := arm
39+
else
40+
ARCH := unknown
3641
endif
3742
endif # CROSS_PREFIX
3843

0 commit comments

Comments
 (0)