[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v4 2/4] x86/clang: restore integrated assembler usage with indirect thunks



If the required features are meet by the integrated clang assembler
(support for .includes and propagation of .macro-s between asm()-s)
do not disable it.

Only switch off the non integrated assembler for assembly file, like
it was done prior to "x86: Support indirect thunks from assembly
code".

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Cc: George Dunlap <George.Dunlap@xxxxxxxxxxxxx>
Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Cc: Jan Beulich <jbeulich@xxxxxxxx>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>
Cc: Tim Deegan <tim@xxxxxxx>
Cc: Wei Liu <wei.liu2@xxxxxxxxxx>
---
Changes since v3:
 - Do not modify how the thunk is included, clang upstream (and 6) has
   been fixed to propagate .macro-s between asm()-s.

Changes since v1:
 - Use as-insn to check if the assembler supports .include.
 - Open code a check for whether the assembler forgets .macro-s
   between asm()-s.
---
 Config.mk             |  6 +++---
 xen/Rules.mk          |  5 +++--
 xen/arch/x86/Rules.mk | 14 ++++++++++++++
 3 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/Config.mk b/Config.mk
index 51adc27d83..87472195be 100644
--- a/Config.mk
+++ b/Config.mk
@@ -157,9 +157,9 @@ ifndef XEN_HAS_CHECKPOLICY
 endif
 
 # as-insn: Check whether assembler supports an instruction.
-# Usage: cflags-y += $(call as-insn "insn",option-yes,option-no)
+# Usage: cflags-y += $(call as-insn cc FLAGS,"insn",option-yes,option-no)
 as-insn = $(if $(shell echo 'void _(void) { asm volatile ( $(2) ); }' \
-                       | $(1) $(filter-out -M% %.d -include 
%/include/xen/config.h,$(AFLAGS)) \
+                       | $(filter-out -M% %.d -include 
%/include/xen/config.h,$(1)) \
                               -c -x c -o /dev/null - 2>&1),$(4),$(3))
 
 # as-insn-check: Add an option to compilation flags, but only if insn is
@@ -167,7 +167,7 @@ as-insn = $(if $(shell echo 'void _(void) { asm volatile ( 
$(2) ); }' \
 # Usage: $(call as-insn-check CFLAGS,CC,"nop",-DHAVE_GAS_NOP)
 as-insn-check = $(eval $(call as-insn-check-closure,$(1),$(2),$(3),$(4)))
 define as-insn-check-closure
-    ifeq ($$(call as-insn,$$($(2)),$(3),y,n),y)
+    ifeq ($$(call as-insn,$$($(2)) $$(AFLAGS),$(3),y,n),y)
         $(1) += $(4)
     endif
 endef
diff --git a/xen/Rules.mk b/xen/Rules.mk
index da3c35ba36..322e11dba2 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -70,8 +70,9 @@ endif
 
 AFLAGS-y                += -D__ASSEMBLY__
 
-# Clang's built-in assembler can't handle embedded .include's
-CFLAGS-$(clang)         += -no-integrated-as
+# Older clang's built-in assembler doesn't understand .skip with labels:
+# https://bugs.llvm.org/show_bug.cgi?id=27369
+AFLAGS-$(clang)         += -no-integrated-as
 
 ALL_OBJS := $(ALL_OBJS-y)
 
diff --git a/xen/arch/x86/Rules.mk b/xen/arch/x86/Rules.mk
index 1dc5c3785a..ceb026dc79 100644
--- a/xen/arch/x86/Rules.mk
+++ b/xen/arch/x86/Rules.mk
@@ -44,3 +44,17 @@ endif
 
 # Set up the assembler include path properly for older toolchains.
 CFLAGS += -Wa,-I$(BASEDIR)/include
+
+ifeq ($(clang),y)
+    # Check whether clang asm()-s support .include.
+    ifeq ($(call as-insn,$(CC) $(CFLAGS),".include 
\"asm/indirect_thunk_asm.h\"",y,n),n)
+        CFLAGS += -no-integrated-as
+    # Check whether clang keeps .macro-s between asm()-s:
+    # https://bugs.llvm.org/show_bug.cgi?id=36110
+    else ifeq ($(if $(shell echo 'void _(void) { asm volatile ( ".macro 
FOO\n.endm" ); \
+                                                 asm volatile ( ".macro 
FOO\n.endm" ); }' \
+                       | $(CC) $(filter-out -M% %.d -include 
%/include/xen/config.h,$(CFLAGS)) \
+                              -c -x c -o /dev/null - 2>&1),n,y),y)
+        CFLAGS += -no-integrated-as
+    endif
+endif
-- 
2.16.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.