Skip to content

Commit 942a9cc

Browse files
nickdesaulniersxfwdrev
authored andcommitted
BACKPORT: Makefile: move initial clang flag handling into scripts/Makefile.clang
With some of the changes we'd like to make to CROSS_COMPILE, the initial block of clang flag handling which controls things like the target triple, whether or not to use the integrated assembler and how to find GAS, and erroring on unknown warnings is becoming unwieldy. Move it into its own file under scripts/. Reviewed-by: Nathan Chancellor <[email protected]> Signed-off-by: Nick Desaulniers <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]> Bug: 209655537 [nd: conflict in MAINTAINERS] (cherry picked from commit 6f5b41a2f5a6314614e286274eb8e985248aac60) Change-Id: I350ba8aaf924f7b373d25ef67260e6373a405d12
1 parent 6cdf883 commit 942a9cc

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

MAINTAINERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4032,6 +4032,8 @@ C: irc://chat.freenode.net/clangbuiltlinux
40324032
S: Supported
40334033
K: \b(?i:clang|llvm)\b
40344034
F: Documentation/kbuild/llvm.rst
4035+
F: include/linux/compiler-clang.h
4036+
F: scripts/Makefile.clang
40354037

40364038
CLEANCACHE API
40374039
M: Konrad Rzeszutek Wilk <[email protected]>

Makefile

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -561,18 +561,7 @@ endif
561561
CC_VERSION_TEXT = $(subst $(pound),,$(shell LC_ALL=C $(CC) --version 2>/dev/null | head -n 1))
562562

563563
ifneq ($(findstring clang,$(CC_VERSION_TEXT)),)
564-
ifneq ($(CROSS_COMPILE),)
565-
CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
566-
endif
567-
ifneq ($(LLVM_IAS),1)
568-
CLANG_FLAGS += -no-integrated-as
569-
GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit))
570-
CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE))
571-
endif
572-
CLANG_FLAGS += -Werror=unknown-warning-option
573-
KBUILD_CFLAGS += $(CLANG_FLAGS)
574-
KBUILD_AFLAGS += $(CLANG_FLAGS)
575-
export CLANG_FLAGS
564+
include $(srctree)/scripts/Makefile.clang
576565
endif
577566

578567
# Include this also for config targets because some architectures need

scripts/Makefile.clang

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
ifneq ($(CROSS_COMPILE),)
2+
CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
3+
endif
4+
ifeq ($(LLVM_IAS),1)
5+
CLANG_FLAGS += -integrated-as
6+
else
7+
CLANG_FLAGS += -no-integrated-as
8+
GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit))
9+
CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE))
10+
endif
11+
CLANG_FLAGS += -Werror=unknown-warning-option
12+
KBUILD_CFLAGS += $(CLANG_FLAGS)
13+
KBUILD_AFLAGS += $(CLANG_FLAGS)
14+
export CLANG_FLAGS

0 commit comments

Comments
 (0)