CC_NO_CLANG should be set according to the value of CC after overridden. I have linked /usr/bin/cc to /usr/bin/clang and I built perf with a gcc cross-compiler:
$ ARCH=arm64 CROSS_COMPILE=aarch64-calvin-linux-gnu- make -C \ ../linux/tools/perf/ O=$(pwd) It worked well. But when I tried to rebuild that with FIXDEP=1: $ ARCH=arm64 CROSS_COMPILE=aarch64-calvin-linux-gnu- make -C \ ../linux/tools/perf/ O=$(pwd) FIXDEP=1 Every .o files were rebuilt since EXTRA_WARNINGS was changed due to false value of CC_NO_CLANG. Things worked in first build because submake of Makefile.perf inherited CC from first make and CC_NO_CLANG was rectified in submake. Signed-off-by: Calvin Zhang <zhq2...@mail.ustc.edu.cn> --- tools/scripts/Makefile.include | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include index a7974638561c..dc887669828b 100644 --- a/tools/scripts/Makefile.include +++ b/tools/scripts/Makefile.include @@ -39,8 +39,6 @@ EXTRA_WARNINGS += -Wundef EXTRA_WARNINGS += -Wwrite-strings 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 # variable named by $(1), unless the variable has been set by # environment or command line. This is necessary for CC and AR @@ -59,6 +57,8 @@ $(call allow-override,LD,$(CROSS_COMPILE)ld) $(call allow-override,CXX,$(CROSS_COMPILE)g++) $(call allow-override,STRIP,$(CROSS_COMPILE)strip) +CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?) + ifeq ($(CC_NO_CLANG), 1) EXTRA_WARNINGS += -Wstrict-aliasing=3 endif -- 2.18.4