|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [XEN PATCH v3 15/23] xen/build: have the root Makefile generates the CFLAGS
On Wed, Feb 26, 2020 at 11:33:47AM +0000, Anthony PERARD wrote:
> 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 generates are the one that depends on the targets,
^ be generated ^ ones ^ depend
I think (albeit I'm not a native speaker).
> 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().
>
> There is on FIXME added about LTO build, but since LTO is marked as
> BROKEN, this commit doesn't attempt to filter -flto flags out of the
> CFLAGS.
>
> Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
> ---
>
> Notes:
> v3:
> - squash "xen/build: introduce ccflags-y and CFLAGS_$@" here, with
> those changes:
> - rename ccflags-y to simply CFLAGS-y and start using AFLAGS-y in
> subdirs.
> - remove CFLAGS_$@, we don't need it yet.
> - fix build of xen.lds and efi.lds which needed -D to be a_flags
> - remove arch_ccflags, and modify c_flags directly
> with that change, reorder c_flags, so that target specific flags are
> last.
> - remove HAVE_AS_QUOTED_SYM from envvar and check XEN_CFLAGS to find if
> it's there when adding -D__OBJECT_LABEL__.
> - fix missing some flags in AFLAGS
> (like -fshort-wchar in xen/arch/x86/efi/Makefile,
> and -D__OBJECT_LABEL__ and CFLAGS-stack-boundary)
> - keep COV_FLAGS generation in Rules.mk since it doesn't invovle to
> call CC
> - fix clang test for "asm()-s support .include." (in a new patch done
> ahead)
> - include Kconfig.include in xen/Makefile because as-option-add is
> defined there now.
>
> xen/Makefile | 60 ++++++++++++++++++++++++
> xen/Rules.mk | 74 ++++++++----------------------
> xen/arch/arm/Makefile | 10 ++--
> xen/arch/arm/Rules.mk | 93 --------------------------------------
> xen/arch/arm/arch.mk | 88 ++++++++++++++++++++++++++++++++++++
> xen/arch/arm/efi/Makefile | 2 +-
> xen/arch/x86/Makefile | 24 +++++-----
> xen/arch/x86/Rules.mk | 91 +++----------------------------------
> xen/arch/x86/arch.mk | 84 ++++++++++++++++++++++++++++++++++
> xen/arch/x86/efi/Makefile | 2 +-
> xen/common/libelf/Makefile | 4 +-
> xen/common/libfdt/Makefile | 4 +-
> xen/include/Makefile | 2 +-
> xen/xsm/flask/Makefile | 2 +-
> xen/xsm/flask/ss/Makefile | 2 +-
> 15 files changed, 283 insertions(+), 259 deletions(-)
> create mode 100644 xen/arch/arm/arch.mk
> create mode 100644 xen/arch/x86/arch.mk
>
> diff --git a/xen/Makefile b/xen/Makefile
> index a6120e577e9b..da017dc29d36 100644
> --- a/xen/Makefile
> +++ b/xen/Makefile
> @@ -94,6 +94,8 @@ config: FORCE
>
> else # !config-build
>
> +include scripts/Kbuild.include
> +
> ifeq ($(need-config),y)
> include include/config/auto.conf
> # Read in dependencies to all Kconfig* files, make sure to run syncconfig if
> @@ -113,6 +115,64 @@ $(KCONFIG_CONFIG):
> include/config/%.conf include/config/%.conf.cmd: $(KCONFIG_CONFIG)
> $(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=$(ARCH)
> SRCARCH=$(SRCARCH) HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" syncconfig
>
> +ifeq ($(CONFIG_DEBUG),y)
> +CFLAGS += -O1
> +else
> +CFLAGS += -O2
> +endif
Long term we might want to make the optimization level selectable in
Kconfig IMO.
> +
> +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,
^ a
> +# but has an excessively large symbol table.
> +CFLAGS += -Wa,--strip-local-absolute
This is not really related to clang, but to the assembler. If clang is
used with -no-integrated-as it's quite likely that the GNU assembler
will be used, and hence this option would be available.
Can we use cc-option-add here in order to detect whether the build
toolchain support the option?
Ideally this should be done after the integrated assembler tests
performed in x86/Rules.mk.
> +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))
> +
> +# LDFLAGS are only passed directly to $(LD)
> +LDFLAGS += $(LDFLAGS_DIRECT) $(LDFLAGS-y)
> +
> +ifeq ($(CONFIG_UBSAN),y)
> +CFLAGS_UBSAN := -fsanitize=undefined
> +else
> +CFLAGS_UBSAN :=
Do you need to define this to empty so it can be exported below? Isn't
it enough to just not set it at all?
> +endif
> +
> +ifeq ($(CONFIG_LTO),y)
> +CFLAGS += -flto
> +LDFLAGS-$(CONFIG_CC_IS_CLANG) += -plugin LLVMgold.so
> +endif
> +
> +include $(BASEDIR)/arch/$(TARGET_ARCH)/arch.mk
The strip-local-absolute check should be done after this AFAICT.
> +
> +# define new variables to avoid the ones defines in Config.mk
> +export XEN_CFLAGS := $(CFLAGS)
> +export XEN_AFLAGS := $(AFLAGS)
> +export XEN_LDFLAGS := $(LDFLAGS)
> +export CFLAGS_UBSAN
You might want to rename this to XEN_CFLAGS_UBSAN for coherency with
the rest of the exported variables?
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |