summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorPaul Cercueil <paul@crapouillou.net>2015-04-18 00:35:04 +0300
committerMichal Marek <mmarek@suse.cz>2015-04-27 15:21:10 +0300
commitee4eb20dbce91751c248399e8a0cf9b8813adf5a (patch)
tree75fcc453aaac8d5c752c0be269dc917938cd6854 /Makefile
parentb787f68c36d49bb1d9236f403813641efa74a031 (diff)
downloadlinux-ee4eb20dbce91751c248399e8a0cf9b8813adf5a.tar.xz
Makefile: Fix detection of clang when cross-compiling
When the host's C compiler is clang, and when attempting to cross-compile Linux e.g. to MIPS with mipsel-linux-gcc, the Makefile would incorrectly detect the use of clang, which resulted in clang-specific flags being passed to mipsel-linux-gcc. This can be verified under Debian by installing the "clang" package, and then using it as the default compiler with: sudo update-alternatives --config cc This patch moves the detection of clang after the $(CC) variable is initialized to the name of the cross-compiler, so that the check applies to the cross-compiler and not the host's C compiler. v2: Move the detection of clang after the inclusion of the arch/*/Makefile (as they might set $(CROSS_COMPILE)) Signed-off-by: Paul Cercueil <paul@crapouillou.net> Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile16
1 files changed, 7 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 7ff1239f9cd2..2d225aa4d7e3 100644
--- a/Makefile
+++ b/Makefile
@@ -336,15 +336,6 @@ endif
export KBUILD_MODULES KBUILD_BUILTIN
export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD
-ifneq ($(CC),)
-ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1)
-COMPILER := clang
-else
-COMPILER := gcc
-endif
-export COMPILER
-endif
-
# We need some generic definitions (do not try to remake the file).
scripts/Kbuild.include: ;
include scripts/Kbuild.include
@@ -671,6 +662,13 @@ endif
endif
KBUILD_CFLAGS += $(stackp-flag)
+ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1)
+COMPILER := clang
+else
+COMPILER := gcc
+endif
+export COMPILER
+
ifeq ($(COMPILER),clang)
KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
KBUILD_CPPFLAGS += $(call cc-option,-Wno-unknown-warning-option,)