From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
Julien Grall <julien@xen.org>, Wei Liu <wl@xen.org>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
George Dunlap <george.dunlap@citrix.com>,
Paul Durrant <Paul.Durrant@citrix.com>,
Roger Pau Monne <roger.pau@citrix.com>
Subject: [Xen-devel] [PATCH v5 03/10] x86: determine HAVE_AS_* just once
Date: Tue, 24 Mar 2020 13:33:14 +0100 [thread overview]
Message-ID: <2c83b876-6fd8-1315-3b28-b45e877187aa@suse.com> (raw)
In-Reply-To: <6fa81b4d-528d-5c33-50c5-a18396b4383a@suse.com>
With the exception of HAVE_AS_QUOTED_SYM, populate the results into a
generated header instead of (at least once per [sub]directory) into
CFLAGS. This results in proper rebuilds (via make dependencies) in case
the compiler used changes between builds. It additionally eases
inspection of which assembler features were actually found usable.
Some trickery is needed to avoid header generation itself to try to
include the to-be/not-yet-generated header.
Since the definitions in generated/config.h, previously having been
command line options, might even affect xen/config.h or its descendants,
move adding of the -include option for the latter after inclusion of the
per-arch Rules.mk. Use the occasion to also move the most general -I
option to the common Rules.mk.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v5: Re-base.
v4: New.
---
An alternative to the $(MAKECMDGOALS) trickery would be to make
generation of generated/config.h part of the asm-offsets.s rule, instead
of adding it as a dependency there. Not sure whether either is truly
better than the other.
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -55,7 +55,7 @@ endif
CFLAGS += -nostdinc -fno-builtin -fno-common
CFLAGS += -Werror -Wredundant-decls -Wno-pointer-arith
$(call cc-option-add,CFLAGS,CC,-Wvla)
-CFLAGS += -pipe -D__XEN__ -include $(BASEDIR)/include/xen/config.h
+CFLAGS += -pipe -D__XEN__ -I$(BASEDIR)/include
CFLAGS-$(CONFIG_DEBUG_INFO) += -g
CFLAGS += '-D__OBJECT_FILE__="$@"'
@@ -95,6 +95,9 @@ SPECIAL_DATA_SECTIONS := rodata $(foreac
include $(BASEDIR)/arch/$(TARGET_ARCH)/Rules.mk
+# Allow the arch to use -include ahead of this one.
+CFLAGS += -include xen/config.h
+
include Makefile
define gendep
--- a/xen/arch/arm/Rules.mk
+++ b/xen/arch/arm/Rules.mk
@@ -6,8 +6,6 @@
# 'make clean' before rebuilding.
#
-CFLAGS += -I$(BASEDIR)/include
-
$(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS))
$(call cc-option-add,CFLAGS,CC,-Wnested-externs)
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -225,7 +225,8 @@ endif
efi/boot.init.o efi/runtime.o efi/compat.o efi/buildid.o efi/relocs-dummy.o: $(BASEDIR)/arch/x86/efi/built_in.o
efi/boot.init.o efi/runtime.o efi/compat.o efi/buildid.o efi/relocs-dummy.o: ;
-asm-offsets.s: $(TARGET_SUBARCH)/asm-offsets.c $(BASEDIR)/include/asm-x86/asm-macros.h
+asm-offsets.s: $(TARGET_SUBARCH)/asm-offsets.c $(BASEDIR)/include/asm-x86/asm-macros.h \
+ $(BASEDIR)/include/generated/config.h
$(CC) $(filter-out -Wa$(comma)% -flto,$(CFLAGS)) -S -o $@ $<
asm-macros.i: CFLAGS += -D__ASSEMBLY__ -P
@@ -241,6 +242,45 @@ $(BASEDIR)/include/asm-x86/asm-macros.h:
echo '#endif' >>$@.new
$(call move-if-changed,$@.new,$@)
+# There are multiple invocations of this Makefile, one each for asm-offset.s,
+# $(TARGET), built_in.o, and several more from the rules building $(TARGET)
+# and $(TARGET).efi. The 2nd and 3rd may race with one another, and we don't
+# want to re-generate config.h in that case anyway, so guard the logic
+# accordingly. (We do want to have the FORCE dependency on the rule, to be
+# sure we pick up changes when the compiler used has changed.)
+ifeq ($(MAKECMDGOALS),asm-offsets.s)
+
+as-ISA-list := CLWB EPT FSGSBASE INVPCID RDRAND RDSEED SSE4_2 VMX XSAVEOPT
+
+CLWB-insn := clwb (%rax)
+EPT-insn := invept (%rax),%rax
+FSGSBASE-insn := rdfsbase %rax
+INVPCID-insn := invpcid (%rax),%rax
+RDRAND-insn := rdrand %eax
+RDSEED-insn := rdseed %eax
+SSE4_2-insn := crc32 %eax,%eax
+VMX-insn := vmcall
+XSAVEOPT-insn := xsaveopt (%rax)
+
+# GAS's idea of true is -1. Clang's idea is 1.
+NEGATIVE_TRUE-insn := .if ((1 > 0) > 0); .error \"\"; .endif
+
+# Check to see whether the assembler supports the .nops directive.
+NOPS_DIRECTIVE-insn := .L1: .L2: .nops (.L2 - .L1),9
+
+as-features-list := $(as-ISA-list) NEGATIVE_TRUE NOPS_DIRECTIVE
+
+$(BASEDIR)/include/generated/config.h: FORCE
+ echo '/* Generated header, do not edit. */' >$@.new
+ $(foreach f,$(as-features-list), \
+ $(if $($(f)-insn),,$(error $(f)-insn is empty)) \
+ echo '#$(call as-insn,$(CC) $(CFLAGS),"$($(f)-insn)", \
+ define, \
+ undef) HAVE_AS_$(f) /* $($(f)-insn) */' >>$@.new;)
+ $(call move-if-changed,$@.new,$@)
+
+endif
+
efi.lds: AFLAGS += -DEFI
xen.lds efi.lds: xen.lds.S
$(CC) -P -E -Ui386 $(filter-out -Wa$(comma)%,$(AFLAGS)) -o $@ $<
--- a/xen/arch/x86/Rules.mk
+++ b/xen/arch/x86/Rules.mk
@@ -3,7 +3,7 @@
XEN_IMG_OFFSET := 0x200000
-CFLAGS += -I$(BASEDIR)/include
+CFLAGS += $(if $(filter asm-macros.% %/generated/config.h,$@),,-include generated/config.h)
CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-generic
CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-default
CFLAGS += -DXEN_IMG_OFFSET=$(XEN_IMG_OFFSET)
@@ -38,26 +38,9 @@ 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)
-$(call as-option-add,CFLAGS,CC,"crc32 %eax$$(comma)%eax",-DHAVE_AS_SSE4_2)
-$(call as-option-add,CFLAGS,CC,"invept (%rax)$$(comma)%rax",-DHAVE_AS_EPT)
-$(call as-option-add,CFLAGS,CC,"rdrand %eax",-DHAVE_AS_RDRAND)
-$(call as-option-add,CFLAGS,CC,"rdfsbase %rax",-DHAVE_AS_FSGSBASE)
-$(call as-option-add,CFLAGS,CC,"xsaveopt (%rax)",-DHAVE_AS_XSAVEOPT)
-$(call as-option-add,CFLAGS,CC,"rdseed %eax",-DHAVE_AS_RDSEED)
-$(call as-option-add,CFLAGS,CC,"clwb (%rax)",-DHAVE_AS_CLWB)
$(call as-option-add,CFLAGS,CC,".equ \"x\"$$(comma)1", \
-U__OBJECT_LABEL__ -DHAVE_AS_QUOTED_SYM \
'-D__OBJECT_LABEL__=$(subst $(BASEDIR)/,,$(CURDIR))/$$@')
-$(call as-option-add,CFLAGS,CC,"invpcid (%rax)$$(comma)%rax",-DHAVE_AS_INVPCID)
-
-# GAS's idea of true is -1. Clang's idea is 1
-$(call as-option-add,CFLAGS,CC,\
- ".if ((1 > 0) < 0); .error \"\";.endif",,-DHAVE_AS_NEGATIVE_TRUE)
-
-# Check to see whether the assmbler supports the .nop directive.
-$(call as-option-add,CFLAGS,CC,\
- ".L1: .L2: .nops (.L2 - .L1)$$(comma)9",-DHAVE_AS_NOPS_DIRECTIVE)
CFLAGS += -mno-red-zone -fpic -fno-asynchronous-unwind-tables
--- a/xen/include/Makefile
+++ b/xen/include/Makefile
@@ -64,7 +64,7 @@ compat/%.h: compat/%.i Makefile $(BASEDI
mv -f $@.new $@
compat/%.i: compat/%.c Makefile
- $(CPP) $(filter-out -Wa$(comma)% -M% %.d -include %/include/xen/config.h,$(CFLAGS)) $(cppflags-y) -o $@ $<
+ $(CPP) $(filter-out -Wa$(comma)% -M% %.d -include %/config.h,$(CFLAGS)) $(cppflags-y) -o $@ $<
compat/%.c: public/%.h xlat.lst Makefile $(BASEDIR)/tools/compat-build-source.py
mkdir -p $(@D)
--- a/xen/scripts/Kbuild.include
+++ b/xen/scripts/Kbuild.include
@@ -10,7 +10,7 @@ DEPS_INCLUDE = $(addsuffix .d2, $(basena
# as-insn: Check whether assembler supports an instruction.
# Usage: cflags-y += $(call as-insn,CC FLAGS,"insn",option-yes,option-no)
as-insn = $(if $(shell echo 'void _(void) { asm volatile ( $(2) ); }' \
- | $(filter-out -M% %.d -include %/include/xen/config.h,$(1)) \
+ | $(filter-out -M% %.d -include %/config.h,$(1)) \
-c -x c -o /dev/null - 2>&1),$(4),$(3))
# as-option-add: Conditionally add options to flags
next prev parent reply other threads:[~2020-03-24 12:33 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-24 12:26 [Xen-devel] [PATCH v5 00/10] x86emul: further work Jan Beulich
2020-03-24 12:29 ` [Xen-devel] [PATCH v5 02/10] x86emul: support AVX512_BF16 insns Jan Beulich
2020-03-24 12:29 ` [Xen-devel] [PATCH v5 02/10] x86emul: support MOVDIRI insn Jan Beulich
2020-03-25 20:58 ` Andrew Cooper
2020-03-26 9:20 ` Jan Beulich
2020-03-24 12:30 ` [Xen-devel] [PATCH v5 01/10] x86emul: support AVX512_BF16 insns Jan Beulich
2020-03-25 20:02 ` Andrew Cooper
2020-03-27 18:20 ` Andrew Cooper
2020-03-30 6:40 ` Jan Beulich
2020-03-24 12:33 ` Jan Beulich [this message]
2020-03-25 21:12 ` [Xen-devel] [PATCH v5 03/10] x86: determine HAVE_AS_* just once Andrew Cooper
2020-03-26 9:50 ` Jan Beulich
2020-03-26 13:42 ` Anthony PERARD
2020-03-26 14:20 ` Jan Beulich
2020-04-09 12:24 ` Jan Beulich
2020-03-24 12:33 ` [Xen-devel] [PATCH v5 04/10] x86: move back clang no integrated assembler tests Jan Beulich
2020-03-24 12:34 ` [Xen-devel] [PATCH v5 05/10] x86emul: support MOVDIR64B insn Jan Beulich
2020-03-25 11:19 ` Paul Durrant
2020-03-25 11:46 ` Jan Beulich
2020-04-02 23:12 ` Andrew Cooper
2020-04-03 7:57 ` Jan Beulich
2020-04-03 15:13 ` Andrew Cooper
2020-04-03 15:25 ` Jan Beulich
2020-03-24 12:34 ` [Xen-devel] [PATCH v5 06/10] x86emul: support ENQCMD insn Jan Beulich
2020-03-24 12:35 ` [Xen-devel] [PATCH v5 07/10] x86/HVM: scale MPERF values reported to guests (on AMD) Jan Beulich
2020-03-24 12:36 ` [Xen-devel] [PATCH v5 08/10] x86emul: support RDPRU Jan Beulich
2020-03-24 12:37 ` [Xen-devel] [PATCH v5 09/10] x86/HVM: don't needlessly intercept APERF/MPERF/TSC MSR reads Jan Beulich
2020-03-27 2:24 ` Tian, Kevin
2020-03-24 12:37 ` [Xen-devel] [PATCH v5 10/10] x86emul: support MCOMMIT Jan Beulich
2020-04-02 23:47 ` Andrew Cooper
2020-04-03 8:00 ` Jan Beulich
2020-04-03 15:00 ` Andrew Cooper
2020-04-03 15:09 ` Jan Beulich
2020-04-03 15:25 ` Andrew Cooper
2020-03-24 12:43 ` [Xen-devel] [PATCH v5 00/10] x86emul: further work Jan Beulich
2020-03-25 10:59 ` Paul Durrant
2020-03-25 11:41 ` Andrew Cooper
2020-03-25 11:45 ` Jan Beulich
2020-03-26 11:49 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2c83b876-6fd8-1315-3b28-b45e877187aa@suse.com \
--to=jbeulich@suse.com \
--cc=Paul.Durrant@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=julien@xen.org \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).