]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
x86/clang: allow integrated assembler usage
authorRoger Pau Monne <roger.pau@citrix.com>
Fri, 23 Feb 2018 14:11:00 +0000 (14:11 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 26 Feb 2018 17:48:44 +0000 (17:48 +0000)
If the required features are present.

Modify as-option-add to add an option in case the test fails, and use
it to detect whether the required clang integrated assembler features
are present.

This patch has been tested with clang 3.5, clang 6, gcc 6.4.0 without
retpoline support and gcc 7.3.1 with retpoline support.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Config.mk
xen/Rules.mk
xen/arch/x86/Rules.mk

index ab0528663007e34b5755c580efcbacf468ae7bc1..b5ca57ce908d90698bfa3dcb7a115111910117a3 100644 (file)
--- a/Config.mk
+++ b/Config.mk
@@ -163,13 +163,14 @@ as-insn = $(if $(shell echo 'void _(void) { asm volatile ( $(2) ); }' \
                        | $(filter-out -M% %.d -include %/include/xen/config.h,$(1)) \
                               -c -x c -o /dev/null - 2>&1),$(4),$(3))
 
-# as-option-add: Add an option to compilation flags, but only if insn is
-#                supported by assembler.
-# Usage: $(call as-option-add,CFLAGS,CC,"insn",option-yes)
-as-option-add = $(eval $(call as-option-add-closure,$(1),$(2),$(3),$(4)))
+# as-option-add: Conditionally add options to flags
+# Usage: $(call as-option-add,CFLAGS,CC,"insn",option-yes,option-no)
+as-option-add = $(eval $(call as-option-add-closure,$(1),$(2),$(3),$(4),$(5)))
 define as-option-add-closure
     ifeq ($$(call as-insn,$$($(2)) $$($(1)),$(3),y,n),y)
         $(1) += $(4)
+    else
+        $(1) += $(5)
     endif
 endef
 
index ef26b8d1bb0aa7bab4eca45ddea80f04e951d326..5337e206ee17b00e2ec5925ca49a382c71c11876 100644 (file)
@@ -70,8 +70,12 @@ 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
+ifeq ($(clang),y)
+$(call as-option-add,CFLAGS,CC,".L0:\n.L1:\n.skip (.L1 - .L0)",,\
+                     -no-integrated-as)
+endif
 
 ALL_OBJS := $(ALL_OBJS-y)
 
index 4561713368ec785234c43118c9ed4c9d179ada77..9897deaab9bda94862fa2cb3ec0611524acd113f 100644 (file)
@@ -44,3 +44,18 @@ endif
 
 # Set up the assembler include path properly for older toolchains.
 CFLAGS += -Wa,-I$(BASEDIR)/include
+
+ifeq ($(clang),y)
+# Note: Any test which adds -no-integrated-as will cause subsequent tests to
+# succeed, and not trigger further additions.
+
+# Check whether clang asm()-s support .include.
+$(call as-option-add,CFLAGS,CC,".include \"asm/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\n.endm\"); asm volatile (\".macro FOO\n.endm",\
+                     -no-integrated-as)
+endif