[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] xen/build: introduce CLANG_FLAGS for testing other CFLAGS
commit fa0854478d0b2b64680e558db760851f6f1c6d16 Author: Anthony PERARD <anthony.perard@xxxxxxxxxx> AuthorDate: Fri May 29 16:43:43 2020 +0100 Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CommitDate: Fri May 29 18:58:21 2020 +0100 xen/build: introduce CLANG_FLAGS for testing other CFLAGS Commit 534519f0514f ("xen: Have Kconfig check $(CC)'s version") introduced the use of CLANG_FLAGS in Kconfig which is used when testing for other CFLAGS via $(cc-option ...) but CLANG_FLAGS doesn't exist in the Xen build system. (It's a Linux/Kbuild variable that haven't been added yet.) The missing CLANG_FLAGS isn't an issue for $(cc-option ..) but it would be when $(as-instr ..) gets imported from Kbuild to tests assembly instruction. We need to know if we are going to use clang's assembler or not. CLANG_FLAGS needs to be calculated before we call Kconfig. So, this patch adds CLANG_FLAGS which may contain two flags which are needed for further testing of $(CC)'s capabilities: -no-integrated-as This flags isn't new, but simply tested earlier so that it can be used in Kconfig. The flags is only added for x86 builds like before. -Werror=unknown-warning-option The one is new and is to make sure that the warning is enabled, even though it is by default but could be disabled in a particular build of clang, see Linux's commit e8de12fb7cde ("kbuild: Check for unknown options with cc-option usage in Kconfig and clang") It is present in clang 3.0.0, according Linux's commit 589834b3a009 ("kbuild: Add -Werror=unknown-warning-option to CLANG_FLAGS"). (The "note" that say that the flags was only added once wasn't true when tested on CentOS 6, so the patch uses $(or) and the flag will only be added once.) Fixes: 534519f0514f ("xen: Have Kconfig check $(CC)'s version") Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx> Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- xen/Makefile | 31 +++++++++++++++++++++++++++++-- xen/arch/x86/arch.mk | 24 ------------------------ 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/xen/Makefile b/xen/Makefile index 286f374b54..d53d1f7b5e 100644 --- a/xen/Makefile +++ b/xen/Makefile @@ -48,6 +48,7 @@ default: build .PHONY: dist dist: install +include scripts/Kbuild.include ifneq ($(root-make-done),y) # section to run before calling Rules.mk, but only once. @@ -124,11 +125,37 @@ ifneq ($(filter %config,$(MAKECMDGOALS)),) config-build := y endif +# CLANG_FLAGS needs to be calculated before calling Kconfig +ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) +CLANG_FLAGS := + +ifeq ($(TARGET_ARCH),x86) +# The tests to select whether the integrated assembler is usable need to happen +# before testing any assembler features, or else the result of the tests would +# be stale if the integrated assembler is not used. + +# Older clang's built-in assembler doesn't understand .skip with labels: +# https://bugs.llvm.org/show_bug.cgi?id=27369 +t1 = $(call as-insn,$(CC),".L0: .L1: .skip (.L1 - .L0)",,-no-integrated-as) + +# Check whether clang asm()-s support .include. +t2 = $(call as-insn,$(CC) -I$(BASEDIR)/include,".include \"asm-x86/indirect_thunk_asm.h\"",,-no-integrated-as) + +# Check whether clang keeps .macro-s between asm()-s: +# https://bugs.llvm.org/show_bug.cgi?id=36110 +t3 = $(call as-insn,$(CC),".macro FOO;.endm"$(close); asm volatile $(open)".macro FOO;.endm",-no-integrated-as) + +CLANG_FLAGS += $(call or,$(t1),$(t2),$(t3)) +endif + +CLANG_FLAGS += -Werror=unknown-warning-option +CFLAGS += $(CLANG_FLAGS) +export CLANG_FLAGS +endif + export root-make-done := y endif # root-make-done -include scripts/Kbuild.include - # Shorthand for kconfig kconfig = -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=$(ARCH) SRCARCH=$(SRCARCH) HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" diff --git a/xen/arch/x86/arch.mk b/xen/arch/x86/arch.mk index 9927a42061..04e967436b 100644 --- a/xen/arch/x86/arch.mk +++ b/xen/arch/x86/arch.mk @@ -11,30 +11,6 @@ CFLAGS += -DXEN_IMG_OFFSET=$(XEN_IMG_OFFSET) # Prevent floating-point variables from creeping into Xen. CFLAGS += -msoft-float -ifeq ($(CONFIG_CC_IS_CLANG),y) -# Note: Any test which adds -no-integrated-as will cause subsequent tests to -# succeed, and not trigger further additions. -# -# The tests to select whether the integrated assembler is usable need to happen -# before testing any assembler features, or else the result of the tests would -# be stale if the integrated assembler is not used. - -# Older clang's built-in assembler doesn't understand .skip with labels: -# https://bugs.llvm.org/show_bug.cgi?id=27369 -$(call as-option-add,CFLAGS,CC,".L0: .L1: .skip (.L1 - .L0)",,\ - -no-integrated-as) - -# Check whether clang asm()-s support .include. -$(call as-option-add,CFLAGS,CC,".include \"asm-x86/indirect_thunk_asm.h\"",,\ - -no-integrated-as) - -# Check whether clang keeps .macro-s between asm()-s: -# https://bugs.llvm.org/show_bug.cgi?id=36110 -$(call as-option-add,CFLAGS,CC,\ - ".macro FOO;.endm"$$(close); asm volatile $$(open)".macro FOO;.endm",\ - -no-integrated-as) -endif - $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS)) $(call cc-option-add,CFLAGS,CC,-Wnested-externs) $(call as-option-add,CFLAGS,CC,"vmcall",-DHAVE_AS_VMX) -- generated by git-patchbot for /home/xen/git/xen.git#master
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |