提交 7a588385 编写于 作者: Y Yonghong Song 提交者: Zheng Zengkai

tools: Allow proper CC/CXX/... override with LLVM=1 in Makefile.include

stable inclusion
from stable-5.10.55
commit 475312897ea6b4b9a9a56c838aec6370c42f7315
bugzilla: 175636 https://gitee.com/openeuler/kernel/issues/I4DYWD

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=475312897ea6b4b9a9a56c838aec6370c42f7315

--------------------------------

commit f62700ce upstream.

selftests/bpf/Makefile includes tools/scripts/Makefile.include.
With the following command
  make -j60 LLVM=1 LLVM_IAS=1  <=== compile kernel
  make -j60 -C tools/testing/selftests/bpf LLVM=1 LLVM_IAS=1 V=1
some files are still compiled with gcc. This patch
fixed the case if CC/AR/LD/CXX/STRIP is allowed to be
overridden, it will be written to clang/llvm-ar/..., instead of
gcc binaries. The definition of CC_NO_CLANG is also relocated
to the place after the above CC is defined.
Signed-off-by: NYonghong Song <yhs@fb.com>
Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210413153419.3028165-1-yhs@fb.com
Cc: Anders Roxell <anders.roxell@linaro.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 8f55155a
...@@ -39,8 +39,6 @@ EXTRA_WARNINGS += -Wundef ...@@ -39,8 +39,6 @@ EXTRA_WARNINGS += -Wundef
EXTRA_WARNINGS += -Wwrite-strings EXTRA_WARNINGS += -Wwrite-strings
EXTRA_WARNINGS += -Wformat EXTRA_WARNINGS += -Wformat
CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?)
# Makefiles suck: This macro sets a default value of $(2) for the # Makefiles suck: This macro sets a default value of $(2) for the
# variable named by $(1), unless the variable has been set by # variable named by $(1), unless the variable has been set by
# environment or command line. This is necessary for CC and AR # environment or command line. This is necessary for CC and AR
...@@ -52,12 +50,22 @@ define allow-override ...@@ -52,12 +50,22 @@ define allow-override
$(eval $(1) = $(2))) $(eval $(1) = $(2)))
endef endef
ifneq ($(LLVM),)
$(call allow-override,CC,clang)
$(call allow-override,AR,llvm-ar)
$(call allow-override,LD,ld.lld)
$(call allow-override,CXX,clang++)
$(call allow-override,STRIP,llvm-strip)
else
# Allow setting various cross-compile vars or setting CROSS_COMPILE as a prefix. # Allow setting various cross-compile vars or setting CROSS_COMPILE as a prefix.
$(call allow-override,CC,$(CROSS_COMPILE)gcc) $(call allow-override,CC,$(CROSS_COMPILE)gcc)
$(call allow-override,AR,$(CROSS_COMPILE)ar) $(call allow-override,AR,$(CROSS_COMPILE)ar)
$(call allow-override,LD,$(CROSS_COMPILE)ld) $(call allow-override,LD,$(CROSS_COMPILE)ld)
$(call allow-override,CXX,$(CROSS_COMPILE)g++) $(call allow-override,CXX,$(CROSS_COMPILE)g++)
$(call allow-override,STRIP,$(CROSS_COMPILE)strip) $(call allow-override,STRIP,$(CROSS_COMPILE)strip)
endif
CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?)
ifneq ($(LLVM),) ifneq ($(LLVM),)
HOSTAR ?= llvm-ar HOSTAR ?= llvm-ar
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册