aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile77
1 files changed, 39 insertions, 38 deletions
diff --git a/Makefile b/Makefile
index efb942ad0b55..60753f2a477b 100644
--- a/Makefile
+++ b/Makefile
@@ -132,7 +132,7 @@ ifneq ($(KBUILD_OUTPUT),)
132# check that the output directory actually exists 132# check that the output directory actually exists
133saved-output := $(KBUILD_OUTPUT) 133saved-output := $(KBUILD_OUTPUT)
134KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \ 134KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \
135 && /bin/pwd) 135 && pwd)
136$(if $(KBUILD_OUTPUT),, \ 136$(if $(KBUILD_OUTPUT),, \
137 $(error failed to create output directory "$(saved-output)")) 137 $(error failed to create output directory "$(saved-output)"))
138 138
@@ -474,6 +474,38 @@ ifneq ($(KBUILD_SRC),)
474 $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) 474 $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
475endif 475endif
476 476
477ifeq ($(cc-name),clang)
478ifneq ($(CROSS_COMPILE),)
479CLANG_TARGET := --target=$(notdir $(CROSS_COMPILE:%-=%))
480GCC_TOOLCHAIN := $(realpath $(dir $(shell which $(LD)))/..)
481endif
482ifneq ($(GCC_TOOLCHAIN),)
483CLANG_GCC_TC := --gcc-toolchain=$(GCC_TOOLCHAIN)
484endif
485KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
486KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
487KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
488KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
489KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
490KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
491KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
492# Quiet clang warning: comparison of unsigned expression < 0 is always false
493KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
494# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
495# source of a reference will be _MergedGlobals and not on of the whitelisted names.
496# See modpost pattern 2
497KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
498KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
499KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
500KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
501else
502
503# These warnings generated too much noise in a regular build.
504# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
505KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
506KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
507endif
508
477ifeq ($(config-targets),1) 509ifeq ($(config-targets),1)
478# =========================================================================== 510# ===========================================================================
479# *config targets only - make sure prerequisites are updated, and descend 511# *config targets only - make sure prerequisites are updated, and descend
@@ -684,38 +716,6 @@ ifdef CONFIG_CC_STACKPROTECTOR
684endif 716endif
685KBUILD_CFLAGS += $(stackp-flag) 717KBUILD_CFLAGS += $(stackp-flag)
686 718
687ifeq ($(cc-name),clang)
688ifneq ($(CROSS_COMPILE),)
689CLANG_TARGET := --target=$(notdir $(CROSS_COMPILE:%-=%))
690GCC_TOOLCHAIN := $(realpath $(dir $(shell which $(LD)))/..)
691endif
692ifneq ($(GCC_TOOLCHAIN),)
693CLANG_GCC_TC := --gcc-toolchain=$(GCC_TOOLCHAIN)
694endif
695KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
696KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
697KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
698KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
699KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
700KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
701KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
702# Quiet clang warning: comparison of unsigned expression < 0 is always false
703KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
704# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
705# source of a reference will be _MergedGlobals and not on of the whitelisted names.
706# See modpost pattern 2
707KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
708KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
709KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
710KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
711else
712
713# These warnings generated too much noise in a regular build.
714# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
715KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
716KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
717endif
718
719ifdef CONFIG_FRAME_POINTER 719ifdef CONFIG_FRAME_POINTER
720KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls 720KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
721else 721else
@@ -1009,7 +1009,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
1009 1009
1010PHONY += $(vmlinux-dirs) 1010PHONY += $(vmlinux-dirs)
1011$(vmlinux-dirs): prepare scripts 1011$(vmlinux-dirs): prepare scripts
1012 $(Q)$(MAKE) $(build)=$@ 1012 $(Q)$(MAKE) $(build)=$@ need-builtin=1
1013 1013
1014define filechk_kernel.release 1014define filechk_kernel.release
1015 echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" 1015 echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
@@ -1337,8 +1337,9 @@ package-dir := scripts/package
1337 $(Q)$(MAKE) $(build)=$(package-dir) $@ 1337 $(Q)$(MAKE) $(build)=$(package-dir) $@
1338%pkg: include/config/kernel.release FORCE 1338%pkg: include/config/kernel.release FORCE
1339 $(Q)$(MAKE) $(build)=$(package-dir) $@ 1339 $(Q)$(MAKE) $(build)=$(package-dir) $@
1340rpm: include/config/kernel.release FORCE 1340rpm: rpm-pkg
1341 $(Q)$(MAKE) $(build)=$(package-dir) $@ 1341 @echo " WARNING: \"rpm\" target will be removed after Linux 4.18"
1342 @echo " Please use \"rpm-pkg\" instead."
1342 1343
1343 1344
1344# Brief documentation of the typical targets used 1345# Brief documentation of the typical targets used
@@ -1546,9 +1547,9 @@ clean: $(clean-dirs)
1546 $(call cmd,rmdirs) 1547 $(call cmd,rmdirs)
1547 $(call cmd,rmfiles) 1548 $(call cmd,rmfiles)
1548 @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ 1549 @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
1549 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ 1550 \( -name '*.[aios]' -o -name '*.ko' -o -name '.*.cmd' \
1550 -o -name '*.ko.*' -o -name '*.dtb' -o -name '*.dtb.S' \ 1551 -o -name '*.ko.*' -o -name '*.dtb' -o -name '*.dtb.S' \
1551 -o -name '*.dwo' \ 1552 -o -name '*.dwo' -o -name '*.lst' \
1552 -o -name '*.su' \ 1553 -o -name '*.su' \
1553 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ 1554 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
1554 -o -name '*.symtypes' -o -name 'modules.order' \ 1555 -o -name '*.symtypes' -o -name 'modules.order' \