It uses 'eval $(1) = $(2)' style, no real 'override' as the name shows ;-)
But you did find a bug above, we should include it again here to avoid not break the possibility of using llvm (still require to check if there are some other regressions):
include ../../../scripts/Makefile.include
And I have further found there is another cc-cross-prefix helper from:
$ grep cc-cross-prefix -ur scripts/ scripts/Makefile.compiler:# cc-cross-prefix scripts/Makefile.compiler:# Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-) scripts/Makefile.compiler:cc-cross-prefix = $(firstword $(foreach c, $(1), \
So, we are able to search the toolchains from Arnd's, local toolchains and ..., may not need to force users to use which one, I will do more tests on it.
Please don't merge this patch too, to avoid break anything, let's tune it carefully in our v2 and delay the whole stuff to v6.7.
OK. Note that in the end it might be less difficult to try to set CROSS_COMPILE *before* including the general include instead of after: we could preset CROSS_COMPILE based on the ARCH/XARCH we know at this step, as this is not expected to rely on auto-detection.
A simple tests shows, we are able to simply move the include after our customize lines:
diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 1f7c36fbe083..ed21dc393dc0 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -1,6 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 -# Makefile for nolibc tests -include ../../../scripts/Makefile.include # We need this for the "cc-option" macro. include ../../../build/Build.include
diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 228a95e65113..91a2a546954c 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -55,6 +55,12 @@ IMAGE_loongarch = arch/loongarch/boot/vmlinuz.efi IMAGE = $(IMAGE_$(XARCH)) IMAGE_NAME = $(notdir $(IMAGE))
+# CROSS_COMPILE: cross toolchain prefix by architecture +CROSS_COMPILE ?= $(CROSS_COMPILE_$(XARCH)) + +# make sure CC is prefixed with CROSS_COMPILE +include ../../../scripts/Makefile.include
Thanks, Zhangjin
Willy