mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
xen/build: have the root Makefile generates the CFLAGS
Instead of generating the CFLAGS in Rules.mk everytime we enter a new
subdirectory, we are going to generate most of them a single time, and
export the result in the environment so that Rules.mk can use it. The
only flags left to be generated are the ones that depend on the
targets, but the variable $(c_flags) takes care of that.
Arch specific CFLAGS are generated by a new file "arch/*/arch.mk"
which is included by the root Makefile.
We export the *FLAGS via the environment variables XEN_*FLAGS because
Rules.mk still includes Config.mk and would add duplicated flags to
CFLAGS.
When running Rules.mk in the root directory (xen/), the variable
`root-make-done' is set, so `need-config' will remain undef and so the
root Makefile will not generate the cflags again.
We can't use CFLAGS in subdirectories to add flags to particular
targets, instead start to use CFLAGS-y. Idem for AFLAGS.
So there are two different CFLAGS-y, the one in xen/Makefile (and
arch.mk), and the one in subdirs that Rules.mk is going to use.
We can't add to XEN_CFLAGS because it is exported, so making change to
it might be propagated to subdirectory which isn't intended.
Some style change are introduced in this patch:
when LDFLAGS_DIRECT is included in LDFLAGS
use of CFLAGS-$(CONFIG_INDIRECT_THUNK) instead of ifeq().
The LTO change hasn't been tested properly, as LTO is marked as
broken.
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <jgrall@amazon.com>
This commit is contained in:
1 parent
aa14feb672
commit
2740d96efd
15 files changed
+210
-189
No files matched your search
@@ -118,6 +118,64 @@ $(KCONFIG_CONFIG):
|
||||
include/config/%.conf include/config/%.conf.cmd: $(KCONFIG_CONFIG)
|
||||
$(MAKE) $(kconfig) syncconfig
|
||||
|
||||
ifeq ($(CONFIG_DEBUG),y)
|
||||
CFLAGS += -O1
|
||||
else
|
||||
CFLAGS += -O2
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_FRAME_POINTER),y)
|
||||
CFLAGS += -fno-omit-frame-pointer
|
||||
else
|
||||
CFLAGS += -fomit-frame-pointer
|
||||
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-$(CONFIG_DEBUG_INFO) += -g
|
||||
|
||||
ifneq ($(CONFIG_CC_IS_CLANG),y)
|
||||
# Clang doesn't understand this command line argument, and doesn't appear to
|
||||
# have a suitable alternative. The resulting compiled binary does function,
|
||||
# but has an excessively large symbol table.
|
||||
CFLAGS += -Wa,--strip-local-absolute
|
||||
endif
|
||||
|
||||
AFLAGS += -D__ASSEMBLY__
|
||||
|
||||
CFLAGS += $(CFLAGS-y)
|
||||
# allow extra CFLAGS externally via EXTRA_CFLAGS_XEN_CORE
|
||||
CFLAGS += $(EXTRA_CFLAGS_XEN_CORE)
|
||||
|
||||
# Most CFLAGS are safe for assembly files:
|
||||
# -std=gnu{89,99} gets confused by #-prefixed end-of-line comments
|
||||
# -flto makes no sense and annoys clang
|
||||
AFLAGS += $(filter-out -std=gnu% -flto,$(CFLAGS)) $(AFLAGS-y)
|
||||
|
||||
# LDFLAGS are only passed directly to $(LD)
|
||||
LDFLAGS += $(LDFLAGS_DIRECT) $(LDFLAGS-y)
|
||||
|
||||
ifeq ($(CONFIG_UBSAN),y)
|
||||
CFLAGS_UBSAN := -fsanitize=undefined
|
||||
else
|
||||
CFLAGS_UBSAN :=
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_LTO),y)
|
||||
CFLAGS += -flto
|
||||
LDFLAGS-$(CONFIG_CC_IS_CLANG) += -plugin LLVMgold.so
|
||||
endif
|
||||
|
||||
include $(BASEDIR)/arch/$(TARGET_ARCH)/arch.mk
|
||||
|
||||
# define new variables to avoid the ones defined in Config.mk
|
||||
export XEN_CFLAGS := $(CFLAGS)
|
||||
export XEN_AFLAGS := $(AFLAGS)
|
||||
export XEN_LDFLAGS := $(LDFLAGS)
|
||||
export CFLAGS_UBSAN
|
||||
|
||||
endif # need-config
|
||||
|
||||
.PHONY: build install uninstall clean distclean MAP
|
||||
|
||||
+18
-55
@@ -38,59 +38,17 @@ ALL_OBJS-y += $(BASEDIR)/arch/$(TARGET_ARCH)/built_in.o
|
||||
ALL_OBJS-$(CONFIG_CRYPTO) += $(BASEDIR)/crypto/built_in.o
|
||||
|
||||
# Initialise some variables
|
||||
CFLAGS_UBSAN :=
|
||||
|
||||
ifeq ($(CONFIG_DEBUG),y)
|
||||
CFLAGS += -O1
|
||||
else
|
||||
CFLAGS += -O2
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_FRAME_POINTER),y)
|
||||
CFLAGS += -fno-omit-frame-pointer
|
||||
else
|
||||
CFLAGS += -fomit-frame-pointer
|
||||
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-$(CONFIG_DEBUG_INFO) += -g
|
||||
|
||||
ifneq ($(CONFIG_CC_IS_CLANG),y)
|
||||
# Clang doesn't understand this command line argument, and doesn't appear to
|
||||
# have an suitable alternative. The resulting compiled binary does function,
|
||||
# but has an excessively large symbol table.
|
||||
CFLAGS += -Wa,--strip-local-absolute
|
||||
endif
|
||||
|
||||
AFLAGS += -D__ASSEMBLY__
|
||||
CFLAGS-y :=
|
||||
AFLAGS-y :=
|
||||
|
||||
ALL_OBJS := $(ALL_OBJS-y)
|
||||
|
||||
CFLAGS += $(CFLAGS-y)
|
||||
# allow extra CFLAGS externally via EXTRA_CFLAGS_XEN_CORE
|
||||
CFLAGS += $(EXTRA_CFLAGS_XEN_CORE)
|
||||
|
||||
# Most CFLAGS are safe for assembly files:
|
||||
# -std=gnu{89,99} gets confused by #-prefixed end-of-line comments
|
||||
# -flto makes no sense and annoys clang
|
||||
AFLAGS += $(filter-out -std=gnu% -flto,$(CFLAGS))
|
||||
|
||||
# LDFLAGS are only passed directly to $(LD)
|
||||
LDFLAGS += $(LDFLAGS_DIRECT)
|
||||
|
||||
LDFLAGS += $(LDFLAGS-y)
|
||||
|
||||
SPECIAL_DATA_SECTIONS := rodata $(foreach a,1 2 4 8 16, \
|
||||
$(foreach w,1 2 4, \
|
||||
rodata.str$(w).$(a)) \
|
||||
rodata.cst$(a)) \
|
||||
$(foreach r,rel rel.ro,data.$(r).local)
|
||||
|
||||
include $(BASEDIR)/arch/$(TARGET_ARCH)/Rules.mk
|
||||
|
||||
include Makefile
|
||||
|
||||
define gendep
|
||||
@@ -107,7 +65,7 @@ $(foreach o,$(filter-out %/,$(obj-y) $(obj-bin-y) $(extra-y)),$(eval $(call gend
|
||||
subdir-y := $(subdir-y) $(filter %/, $(obj-y))
|
||||
obj-y := $(patsubst %/, %/built_in.o, $(obj-y))
|
||||
|
||||
$(filter %.init.o,$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS += -DINIT_SECTIONS_ONLY
|
||||
$(filter %.init.o,$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS-y += -DINIT_SECTIONS_ONLY
|
||||
|
||||
ifeq ($(CONFIG_COVERAGE),y)
|
||||
ifeq ($(CONFIG_CC_IS_CLANG),y)
|
||||
@@ -115,19 +73,16 @@ ifeq ($(CONFIG_CC_IS_CLANG),y)
|
||||
else
|
||||
COV_FLAGS := -fprofile-arcs -ftest-coverage
|
||||
endif
|
||||
$(filter-out %.init.o $(nocov-y),$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS += $(COV_FLAGS)
|
||||
$(filter-out %.init.o $(nocov-y),$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS-y += $(COV_FLAGS)
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_UBSAN),y)
|
||||
CFLAGS_UBSAN += -fsanitize=undefined
|
||||
# Any -fno-sanitize= options need to come after any -fsanitize= options
|
||||
$(filter-out %.init.o $(noubsan-y),$(obj-y) $(obj-bin-y) $(extra-y)): \
|
||||
CFLAGS += $(filter-out -fno-%,$(CFLAGS_UBSAN)) $(filter -fno-%,$(CFLAGS_UBSAN))
|
||||
CFLAGS-y += $(filter-out -fno-%,$(CFLAGS_UBSAN)) $(filter -fno-%,$(CFLAGS_UBSAN))
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_LTO),y)
|
||||
CFLAGS += -flto
|
||||
LDFLAGS-$(CONFIG_CC_IS_CLANG) += -plugin LLVMgold.so
|
||||
# Would like to handle all object files as bitcode, but objects made from
|
||||
# pure asm are in a different format and have to be collected separately.
|
||||
# Mirror the directory tree, collecting them as built_in_bin.o.
|
||||
@@ -140,10 +95,18 @@ obj-bin-y :=
|
||||
endif
|
||||
|
||||
# Always build obj-bin files as binary even if they come from C source.
|
||||
$(obj-bin-y): CFLAGS := $(filter-out -flto,$(CFLAGS))
|
||||
$(obj-bin-y): XEN_CFLAGS := $(filter-out -flto,$(XEN_CFLAGS))
|
||||
|
||||
c_flags = -MMD -MP -MF $(@D)/.$(@F).d $(CFLAGS) '-D__OBJECT_FILE__="$@"'
|
||||
a_flags = -MMD -MP -MF $(@D)/.$(@F).d $(AFLAGS)
|
||||
# Calculation of flags, first the generic flags, then the arch specific flags,
|
||||
# and last the flags modified for a target or a directory.
|
||||
|
||||
c_flags = -MMD -MP -MF $(@D)/.$(@F).d $(XEN_CFLAGS) '-D__OBJECT_FILE__="$@"'
|
||||
a_flags = -MMD -MP -MF $(@D)/.$(@F).d $(XEN_AFLAGS)
|
||||
|
||||
include $(BASEDIR)/arch/$(TARGET_ARCH)/Rules.mk
|
||||
|
||||
c_flags += $(CFLAGS-y)
|
||||
a_flags += $(CFLAGS-y) $(AFLAGS-y)
|
||||
|
||||
built_in.o: $(obj-y) $(extra-y)
|
||||
ifeq ($(obj-y),)
|
||||
@@ -152,7 +115,7 @@ else
|
||||
ifeq ($(CONFIG_LTO),y)
|
||||
$(LD_LTO) -r -o $@ $(filter-out $(extra-y),$^)
|
||||
else
|
||||
$(LD) $(LDFLAGS) -r -o $@ $(filter-out $(extra-y),$^)
|
||||
$(LD) $(XEN_LDFLAGS) -r -o $@ $(filter-out $(extra-y),$^)
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -160,7 +123,7 @@ built_in_bin.o: $(obj-bin-y) $(extra-y)
|
||||
ifeq ($(obj-bin-y),)
|
||||
$(CC) $(a_flags) -c -x assembler /dev/null -o $@
|
||||
else
|
||||
$(LD) $(LDFLAGS) -r -o $@ $(filter-out $(extra-y),$^)
|
||||
$(LD) $(XEN_LDFLAGS) -r -o $@ $(filter-out $(extra-y),$^)
|
||||
endif
|
||||
|
||||
# Force execution of pattern rules (for which PHONY cannot be directly used).
|
||||
|
||||
@@ -95,24 +95,24 @@ prelink_lto.o: $(ALL_OBJS)
|
||||
|
||||
# Link it with all the binary objects
|
||||
prelink.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_lto.o
|
||||
$(LD) $(LDFLAGS) -r -o $@ $^
|
||||
$(LD) $(XEN_LDFLAGS) -r -o $@ $^
|
||||
else
|
||||
prelink.o: $(ALL_OBJS)
|
||||
$(LD) $(LDFLAGS) -r -o $@ $^
|
||||
$(LD) $(XEN_LDFLAGS) -r -o $@ $^
|
||||
endif
|
||||
|
||||
$(TARGET)-syms: prelink.o xen.lds
|
||||
$(LD) $(LDFLAGS) -T xen.lds -N prelink.o \
|
||||
$(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o \
|
||||
$(BASEDIR)/common/symbols-dummy.o -o $(@D)/.$(@F).0
|
||||
$(NM) -pa --format=sysv $(@D)/.$(@F).0 \
|
||||
| $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort >$(@D)/.$(@F).0.S
|
||||
$(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).0.o
|
||||
$(LD) $(LDFLAGS) -T xen.lds -N prelink.o \
|
||||
$(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o \
|
||||
$(@D)/.$(@F).0.o -o $(@D)/.$(@F).1
|
||||
$(NM) -pa --format=sysv $(@D)/.$(@F).1 \
|
||||
| $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort >$(@D)/.$(@F).1.S
|
||||
$(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).1.o
|
||||
$(LD) $(LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \
|
||||
$(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \
|
||||
$(@D)/.$(@F).1.o -o $@
|
||||
$(NM) -pa --format=sysv $(@D)/$(@F) \
|
||||
| $(BASEDIR)/tools/symbols --xensyms --sysv --sort \
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
########################################
|
||||
# arm-specific definitions
|
||||
|
||||
#
|
||||
# If you change any of these configuration options then you must
|
||||
# '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)
|
||||
|
||||
# Prevent floating-point variables from creeping into Xen.
|
||||
CFLAGS-$(CONFIG_ARM_32) += -msoft-float
|
||||
CFLAGS-$(CONFIG_ARM_32) += -mcpu=cortex-a15
|
||||
|
||||
CFLAGS-$(CONFIG_ARM_64) += -mcpu=generic
|
||||
CFLAGS-$(CONFIG_ARM_64) += -mgeneral-regs-only # No fp registers etc
|
||||
|
||||
ifneq ($(filter command line environment,$(origin CONFIG_EARLY_PRINTK)),)
|
||||
$(error You must use 'make menuconfig' to enable/disable early printk now)
|
||||
endif
|
||||
@@ -0,0 +1,18 @@
|
||||
########################################
|
||||
# arm-specific definitions
|
||||
|
||||
CFLAGS += -I$(BASEDIR)/include
|
||||
|
||||
$(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS))
|
||||
$(call cc-option-add,CFLAGS,CC,-Wnested-externs)
|
||||
|
||||
# Prevent floating-point variables from creeping into Xen.
|
||||
CFLAGS-$(CONFIG_ARM_32) += -msoft-float
|
||||
CFLAGS-$(CONFIG_ARM_32) += -mcpu=cortex-a15
|
||||
|
||||
CFLAGS-$(CONFIG_ARM_64) += -mcpu=generic
|
||||
CFLAGS-$(CONFIG_ARM_64) += -mgeneral-regs-only # No fp registers etc
|
||||
|
||||
ifneq ($(filter command line environment,$(origin CONFIG_EARLY_PRINTK)),)
|
||||
$(error You must use 'make menuconfig' to enable/disable early printk now)
|
||||
endif
|
||||
@@ -1,4 +1,4 @@
|
||||
CFLAGS += -fshort-wchar
|
||||
CFLAGS-y += -fshort-wchar
|
||||
|
||||
obj-y += boot.init.o runtime.o
|
||||
obj-$(CONFIG_ACPI) += efi-dom0.init.o
|
||||
+12
-12
@@ -121,32 +121,32 @@ prelink-efi_lto.o: $(ALL_OBJS) efi/runtime.o efi/compat.o
|
||||
|
||||
# Link it with all the binary objects
|
||||
prelink.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_lto.o
|
||||
$(LD) $(LDFLAGS) -r -o $@ $^
|
||||
$(LD) $(XEN_LDFLAGS) -r -o $@ $^
|
||||
|
||||
prelink-efi.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink-efi_lto.o efi/boot.init.o
|
||||
$(LD) $(LDFLAGS) -r -o $@ $^
|
||||
$(LD) $(XEN_LDFLAGS) -r -o $@ $^
|
||||
else
|
||||
prelink.o: $(ALL_OBJS)
|
||||
$(LD) $(LDFLAGS) -r -o $@ $^
|
||||
$(LD) $(XEN_LDFLAGS) -r -o $@ $^
|
||||
|
||||
prelink-efi.o: $(ALL_OBJS) efi/boot.init.o efi/runtime.o efi/compat.o
|
||||
$(LD) $(LDFLAGS) -r -o $@ $(filter-out %/efi/built_in.o,$^)
|
||||
$(LD) $(XEN_LDFLAGS) -r -o $@ $(filter-out %/efi/built_in.o,$^)
|
||||
endif
|
||||
|
||||
$(TARGET)-syms: prelink.o xen.lds
|
||||
$(LD) $(LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \
|
||||
$(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \
|
||||
$(BASEDIR)/common/symbols-dummy.o -o $(@D)/.$(@F).0
|
||||
$(NM) -pa --format=sysv $(@D)/.$(@F).0 \
|
||||
| $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort \
|
||||
>$(@D)/.$(@F).0.S
|
||||
$(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).0.o
|
||||
$(LD) $(LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \
|
||||
$(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \
|
||||
$(@D)/.$(@F).0.o -o $(@D)/.$(@F).1
|
||||
$(NM) -pa --format=sysv $(@D)/.$(@F).1 \
|
||||
| $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort $(syms-warn-dup-y) \
|
||||
>$(@D)/.$(@F).1.S
|
||||
$(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).1.o
|
||||
$(LD) $(LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \
|
||||
$(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \
|
||||
$(@D)/.$(@F).1.o -o $@
|
||||
$(NM) -pa --format=sysv $(@D)/$(@F) \
|
||||
| $(BASEDIR)/tools/symbols --xensyms --sysv --sort \
|
||||
@@ -159,7 +159,7 @@ note.o: $(TARGET)-syms
|
||||
--rename-section=.data=.note.gnu.build-id -S $@.bin $@
|
||||
rm -f $@.bin
|
||||
|
||||
EFI_LDFLAGS = $(patsubst -m%,-mi386pep,$(LDFLAGS)) --subsystem=10
|
||||
EFI_LDFLAGS = $(patsubst -m%,-mi386pep,$(XEN_LDFLAGS)) --subsystem=10
|
||||
EFI_LDFLAGS += --image-base=$(1) --stack=0,0 --heap=0,0 --strip-debug
|
||||
EFI_LDFLAGS += --section-alignment=0x200000 --file-alignment=0x20
|
||||
EFI_LDFLAGS += --major-image-version=$(XEN_VERSION)
|
||||
@@ -168,7 +168,7 @@ EFI_LDFLAGS += --major-os-version=2 --minor-os-version=0
|
||||
EFI_LDFLAGS += --major-subsystem-version=2 --minor-subsystem-version=0
|
||||
|
||||
# Check if the compiler supports the MS ABI.
|
||||
export XEN_BUILD_EFI := $(shell $(CC) $(CFLAGS) -c efi/check.c -o efi/check.o 2>/dev/null && echo y)
|
||||
export XEN_BUILD_EFI := $(shell $(CC) $(XEN_CFLAGS) -c efi/check.c -o efi/check.o 2>/dev/null && echo y)
|
||||
# Check if the linker supports PE.
|
||||
XEN_BUILD_PE := $(if $(XEN_BUILD_EFI),$(shell $(LD) -mi386pep --subsystem=10 -o efi/check.efi efi/check.o 2>/dev/null && echo y))
|
||||
CFLAGS-$(XEN_BUILD_EFI) += -DXEN_BUILD_EFI
|
||||
@@ -178,7 +178,7 @@ $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A ALT_
|
||||
|
||||
ifneq ($(build_id_linker),)
|
||||
ifeq ($(call ld-ver-build-id,$(LD) $(filter -m%,$(EFI_LDFLAGS))),y)
|
||||
CFLAGS += -DBUILD_ID_EFI
|
||||
CFLAGS-y += -DBUILD_ID_EFI
|
||||
EFI_LDFLAGS += $(build_id_linker)
|
||||
note_file := efi/buildid.o
|
||||
# NB: this must be the last input in the linker call, because inputs following
|
||||
@@ -225,7 +225,7 @@ 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
|
||||
$(CC) $(filter-out -Wa$(comma)% -flto,$(c_flags)) -S -o $@ $<
|
||||
|
||||
asm-macros.i: CFLAGS += -D__ASSEMBLY__ -P
|
||||
asm-macros.i: CFLAGS-y += -D__ASSEMBLY__ -P
|
||||
|
||||
$(BASEDIR)/include/asm-x86/asm-macros.h: asm-macros.i Makefile
|
||||
echo '#if 0' >$@.new
|
||||
@@ -238,7 +238,7 @@ $(BASEDIR)/include/asm-x86/asm-macros.h: asm-macros.i Makefile
|
||||
echo '#endif' >>$@.new
|
||||
$(call move-if-changed,$@.new,$@)
|
||||
|
||||
efi.lds: AFLAGS += -DEFI
|
||||
efi.lds: AFLAGS-y += -DEFI
|
||||
xen.lds efi.lds: xen.lds.S
|
||||
$(CC) -P -E -Ui386 $(filter-out -Wa$(comma)%,$(a_flags)) -o $@ $<
|
||||
sed -e 's/.*\.lds\.o:/$(@F):/g' <.$(@F).d >.$(@F).d.new
|
||||
|
||||
+6
-85
@@ -1,89 +1,10 @@
|
||||
########################################
|
||||
# x86-specific definitions
|
||||
|
||||
XEN_IMG_OFFSET := 0x200000
|
||||
|
||||
CFLAGS += -I$(BASEDIR)/include
|
||||
CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-generic
|
||||
CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-default
|
||||
CFLAGS += -DXEN_IMG_OFFSET=$(XEN_IMG_OFFSET)
|
||||
CFLAGS += '-D__OBJECT_LABEL__=$(subst /,$$,$(subst -,_,$(subst $(BASEDIR)/,,$(CURDIR))/$@))'
|
||||
|
||||
# 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)
|
||||
ifneq ($(filter -DHAVE_AS_QUOTED_SYM,$(XEN_CFLAGS)),)
|
||||
object_label_flags = '-D__OBJECT_LABEL__=$(subst $(BASEDIR)/,,$(CURDIR))/$@'
|
||||
else
|
||||
object_label_flags = '-D__OBJECT_LABEL__=$(subst /,$$,$(subst -,_,$(subst $(BASEDIR)/,,$(CURDIR))/$@))'
|
||||
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
|
||||
|
||||
# Xen doesn't use SSE interally. If the compiler supports it, also skip the
|
||||
# SSE setup for variadic function calls.
|
||||
CFLAGS += -mno-sse $(call cc-option,$(CC),-mskip-rax-setup)
|
||||
|
||||
# Compile with thunk-extern, indirect-branch-register if avaiable.
|
||||
ifeq ($(CONFIG_INDIRECT_THUNK),y)
|
||||
CFLAGS += -mindirect-branch=thunk-extern -mindirect-branch-register
|
||||
CFLAGS += -fno-jump-tables
|
||||
endif
|
||||
|
||||
# If supported by the compiler, reduce stack alignment to 8 bytes. But allow
|
||||
# this to be overridden elsewhere.
|
||||
$(call cc-option-add,CFLAGS-stack-boundary,CC,-mpreferred-stack-boundary=3)
|
||||
CFLAGS += $(CFLAGS-stack-boundary)
|
||||
|
||||
ifeq ($(CONFIG_UBSAN),y)
|
||||
# Don't enable alignment sanitisation. x86 has efficient unaligned accesses,
|
||||
# and various things (ACPI tables, hypercall pages, stubs, etc) are wont-fix.
|
||||
# It also causes an as-yet-unidentified crash on native boot before the
|
||||
# console starts.
|
||||
$(call cc-option-add,CFLAGS_UBSAN,CC,-fno-sanitize=alignment)
|
||||
endif
|
||||
|
||||
# Set up the assembler include path properly for older toolchains.
|
||||
CFLAGS += -Wa,-I$(BASEDIR)/include
|
||||
|
||||
c_flags += $(object_label_flags) $(CFLAGS-stack-boundary)
|
||||
a_flags += $(object_label_flags) $(CFLAGS-stack-boundary)
|
||||
@@ -0,0 +1,84 @@
|
||||
########################################
|
||||
# x86-specific definitions
|
||||
|
||||
export XEN_IMG_OFFSET := 0x200000
|
||||
|
||||
CFLAGS += -I$(BASEDIR)/include
|
||||
CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-generic
|
||||
CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-default
|
||||
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)
|
||||
$(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",-DHAVE_AS_QUOTED_SYM)
|
||||
$(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
|
||||
|
||||
# Xen doesn't use SSE interally. If the compiler supports it, also skip the
|
||||
# SSE setup for variadic function calls.
|
||||
CFLAGS += -mno-sse $(call cc-option,$(CC),-mskip-rax-setup)
|
||||
|
||||
# Compile with thunk-extern, indirect-branch-register if avaiable.
|
||||
CFLAGS-$(CONFIG_INDIRECT_THUNK) += -mindirect-branch=thunk-extern
|
||||
CFLAGS-$(CONFIG_INDIRECT_THUNK) += -mindirect-branch-register
|
||||
CFLAGS-$(CONFIG_INDIRECT_THUNK) += -fno-jump-tables
|
||||
|
||||
# If supported by the compiler, reduce stack alignment to 8 bytes. But allow
|
||||
# this to be overridden elsewhere.
|
||||
$(call cc-option-add,CFLAGS-stack-boundary,CC,-mpreferred-stack-boundary=3)
|
||||
export CFLAGS-stack-boundary
|
||||
|
||||
ifeq ($(CONFIG_UBSAN),y)
|
||||
# Don't enable alignment sanitisation. x86 has efficient unaligned accesses,
|
||||
# and various things (ACPI tables, hypercall pages, stubs, etc) are wont-fix.
|
||||
# It also causes an as-yet-unidentified crash on native boot before the
|
||||
# console starts.
|
||||
$(call cc-option-add,CFLAGS_UBSAN,CC,-fno-sanitize=alignment)
|
||||
endif
|
||||
|
||||
# Set up the assembler include path properly for older toolchains.
|
||||
CFLAGS += -Wa,-I$(BASEDIR)/include
|
||||
@@ -1,4 +1,4 @@
|
||||
CFLAGS += -fshort-wchar
|
||||
CFLAGS-y += -fshort-wchar
|
||||
|
||||
%.o: %.ihex
|
||||
$(OBJCOPY) -I ihex -O binary $< $@
|
||||
|
||||
@@ -3,10 +3,10 @@ nocov-y += libelf.o
|
||||
|
||||
SECTIONS := text data $(SPECIAL_DATA_SECTIONS)
|
||||
|
||||
CFLAGS += -Wno-pointer-sign
|
||||
CFLAGS-y += -Wno-pointer-sign
|
||||
|
||||
libelf.o: libelf-temp.o Makefile
|
||||
$(OBJCOPY) $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s)) $< $@
|
||||
|
||||
libelf-temp.o: libelf-tools.o libelf-loader.o libelf-dominfo.o #libelf-relocate.o
|
||||
$(LD) $(LDFLAGS) -r -o $@ $^
|
||||
$(LD) $(XEN_LDFLAGS) -r -o $@ $^
|
||||
@@ -5,10 +5,10 @@ SECTIONS := text data $(SPECIAL_DATA_SECTIONS)
|
||||
obj-y += libfdt.o
|
||||
nocov-y += libfdt.o
|
||||
|
||||
CFLAGS += -I$(BASEDIR)/include/xen/libfdt/
|
||||
CFLAGS-y += -I$(BASEDIR)/include/xen/libfdt/
|
||||
|
||||
libfdt.o: libfdt-temp.o Makefile
|
||||
$(OBJCOPY) $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s)) $< $@
|
||||
|
||||
libfdt-temp.o: $(LIBFDT_OBJS)
|
||||
$(LD) $(LDFLAGS) -r -o $@ $^
|
||||
$(LD) $(XEN_LDFLAGS) -r -o $@ $^
|
||||
@@ -64,7 +64,7 @@ compat/%.h: compat/%.i Makefile $(BASEDIR)/tools/compat-build-header.py
|
||||
mv -f $@.new $@
|
||||
|
||||
compat/%.i: compat/%.c Makefile
|
||||
$(CPP) $(filter-out -Wa$(comma)% -include %/include/xen/config.h,$(CFLAGS)) $(cppflags-y) -o $@ $<
|
||||
$(CPP) $(filter-out -Wa$(comma)% -include %/include/xen/config.h,$(XEN_CFLAGS)) $(cppflags-y) -o $@ $<
|
||||
|
||||
compat/%.c: public/%.h xlat.lst Makefile $(BASEDIR)/tools/compat-build-source.py
|
||||
mkdir -p $(@D)
|
||||
|
||||
@@ -4,7 +4,7 @@ obj-y += flask_op.o
|
||||
|
||||
obj-y += ss/
|
||||
|
||||
CFLAGS += -I./include
|
||||
CFLAGS-y += -I./include
|
||||
|
||||
AWK = awk
|
||||
|
||||
|
||||
@@ -8,4 +8,4 @@ obj-y += services.o
|
||||
obj-y += conditional.o
|
||||
obj-y += mls.o
|
||||
|
||||
CFLAGS += -I../include
|
||||
CFLAGS-y += -I../include
|
||||