* [XEN PATCH] xen/build: introduce CLANG_FLAGS for testing other CFLAGS
@ 2020-05-29 15:43 Anthony PERARD
2020-05-29 17:40 ` Andrew Cooper
0 siblings, 1 reply; 2+ messages in thread
From: Anthony PERARD @ 2020-05-29 15:43 UTC (permalink / raw)
To: xen-devel
Cc: Stefano Stabellini, Julien Grall, Wei Liu, Andrew Cooper,
Ian Jackson, George Dunlap, Jan Beulich, Anthony PERARD,
Roger Pau Monné
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@citrix.com>
---
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 30c3568a4791..2e897f222cc9 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 62b7c9700776..1f7211623399 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)
--
Anthony PERARD
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [XEN PATCH] xen/build: introduce CLANG_FLAGS for testing other CFLAGS
2020-05-29 15:43 [XEN PATCH] xen/build: introduce CLANG_FLAGS for testing other CFLAGS Anthony PERARD
@ 2020-05-29 17:40 ` Andrew Cooper
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cooper @ 2020-05-29 17:40 UTC (permalink / raw)
To: Anthony PERARD, xen-devel
Cc: Stefano Stabellini, Julien Grall, Wei Liu, Ian Jackson,
George Dunlap, Jan Beulich, Roger Pau Monné
On 29/05/2020 16:43, Anthony PERARD wrote:
> 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@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-29 17:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-29 15:43 [XEN PATCH] xen/build: introduce CLANG_FLAGS for testing other CFLAGS Anthony PERARD
2020-05-29 17:40 ` Andrew Cooper
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.