Skip to content

Commit bd55f96

Browse files
committed
kbuild: refactor cc-cross-prefix implementation
- $(word 1, <text>) is equivalent to $(firstword <text>) - hardcode "gcc" instead of $(CC) - minimize the shell script part A little more notes in case $(filter-out -%, ...) is not clear. arch/mips/Makefile passes prefixes depending on the configuration. CROSS_COMPILE := $(call cc-cross-prefix, $(tool-archpref)-linux- \ $(tool-archpref)-linux-gnu- $(tool-archpref)-unknown-linux-gnu-) In the Kconfig stage (e.g. when you run 'make defconfig'), neither CONFIG_32BIT nor CONFIG_64BIT is defined. So, $(tool-archpref) is empty. As a result, "-linux -linux-gnu- -unknown-linux-gnu" is passed into cc-cross-prefix. The command 'which' assumes arguments starting with a hyphen as command options, then emits the following messages: Illegal option -l Illegal option -l Illegal option -u I think it is strange to define CROSS_COMPILE depending on the CONFIG options since you need to feed $(CC) to Kconfig, but it is how MIPS Makefile currently works. Anyway, it would not hurt to filter-out invalid strings beforehand. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
1 parent 8811071 commit bd55f96

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

scripts/Kbuild.include

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,10 @@ endef
7171

7272
# cc-cross-prefix
7373
# Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-)
74-
# Return first prefix where a prefix$(CC) is found in PATH.
75-
# If no $(CC) found in PATH with listed prefixes return nothing
76-
cc-cross-prefix = \
77-
$(word 1, $(foreach c,$(1), \
78-
$(shell set -e; \
79-
if (which $(strip $(c))$(CC)) > /dev/null 2>&1 ; then \
80-
echo $(c); \
81-
fi)))
74+
# Return first <prefix> where a <prefix>gcc is found in PATH.
75+
# If no gcc found in PATH with listed prefixes return nothing
76+
cc-cross-prefix = $(firstword $(foreach c, $(filter-out -%, $(1)), \
77+
$(if $(shell which $(c)gcc), $(c))))
8278

8379
# output directory for tests below
8480
TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)

0 commit comments

Comments
 (0)