All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Anthony PERARD <anthony.perard@citrix.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>, Wei Liu <wl@xen.org>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Jan Beulich <jbeulich@suse.com>,
	xen-devel@lists.xenproject.org,
	Daniel De Graaf <dgdegra@tycho.nsa.gov>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: Re: [Xen-devel] [XEN PATCH v3 15/23] xen/build: have the root Makefile generates the CFLAGS
Date: Thu, 27 Feb 2020 12:05:04 +0100	[thread overview]
Message-ID: <20200227110504.GN24458@Air-de-Roger.citrite.net> (raw)
In-Reply-To: <20200226113355.2532224-16-anthony.perard@citrix.com>

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@citrix.com>
> ---
> 
> 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@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2020-02-27 11:05 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-26 11:33 [Xen-devel] [XEN PATCH v3 00/23] xen: Build system improvements Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 01/23] xen/include: remove include of Config.mk Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 02/23] Makefile: Fix install-tests Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 03/23] xen/build: Remove confusing comment on the %.s:%.S rule Anthony PERARD
2020-02-26 11:53   ` Wei Liu
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 04/23] xen/build: remove use of AFLAGS-y Anthony PERARD
2020-02-26 12:58   ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 05/23] xen/build: Allow to test clang .include without asm symlink Anthony PERARD
2020-02-27  9:05   ` Roger Pau Monné
2020-02-27  9:22     ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 06/23] xen/build: Fix section-renaming of libfdt and libelf Anthony PERARD
2020-02-27  9:38   ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 07/23] xen/build: Use obj-y += subdir/ instead of subdir-y Anthony PERARD
2020-02-27  9:22   ` Roger Pau Monné
2020-02-27  9:43   ` Jan Beulich
2020-03-04 14:14     ` Jan Beulich
2020-03-05  9:24   ` Jan Beulich
2020-03-05 13:42     ` Andrew Cooper
2020-03-05 15:02     ` Julien Grall
2020-03-05 15:59       ` Anthony PERARD
2020-03-05 16:31         ` Julien Grall
2020-03-09  6:46     ` Tian, Kevin
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 08/23] xen/build: use $(clean) shorthand for clean targets Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 09/23] xen/build: extract clean target from Rules.mk Anthony PERARD
2020-03-04 14:13   ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 10/23] xen/build: run targets csopes, tags, .. without Rules.mk Anthony PERARD
2020-03-04 14:17   ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 11/23] xen/build: make tests in test/ directly Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 12/23] xen/build: Move as-option-add to xen/ Anthony PERARD
2020-03-04 14:17   ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 13/23] xen/build: include include/config/auto.conf in main Makefile Anthony PERARD
2020-03-04 14:29   ` Jan Beulich
2020-03-10 17:10     ` Anthony PERARD
2020-03-11  9:26       ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 14/23] xen/build: use new $(c_flags) and $(a_flags) instead of $(CFLAGS) Anthony PERARD
2020-02-27 10:22   ` Roger Pau Monné
2020-03-10 17:55     ` Anthony PERARD
2020-03-04 14:42   ` Jan Beulich
2020-03-10 17:43     ` Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 15/23] xen/build: have the root Makefile generates the CFLAGS Anthony PERARD
2020-02-27 11:05   ` Roger Pau Monné [this message]
2020-03-17 18:05     ` Anthony PERARD
2020-03-19 16:24       ` Anthony PERARD
2020-03-23 15:11         ` Roger Pau Monné
2020-03-24 17:11           ` [Xen-devel] " Anthony PERARD
2020-03-04 15:00   ` Jan Beulich
2020-03-17 18:35     ` Anthony PERARD
2020-03-18 10:20       ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 16/23] xen/build: introduce if_changed and if_changed_rule Anthony PERARD
2020-03-04 15:45   ` Jan Beulich
2020-03-18 10:44     ` Anthony PERARD
2020-03-18 11:14       ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 17/23] xen/build: Start using if_changed Anthony PERARD
2020-02-27 13:09   ` Roger Pau Monné
2020-03-04 16:00     ` Jan Beulich
2020-03-18 10:52       ` Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 18/23] xen/build: use if_changed on built_in.o Anthony PERARD
2020-03-04 16:03   ` Jan Beulich
2020-03-18 10:55     ` Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 19/23] xen/build: Use if_changed_rules with %.o:%.c targets Anthony PERARD
2020-03-04 16:09   ` Jan Beulich
2020-03-18 11:14     ` Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 20/23] xen/build: factorise generation of the linker scripts Anthony PERARD
2020-02-27 13:14   ` Roger Pau Monné
2020-03-05 11:07     ` Jan Beulich
2020-03-05 11:05   ` Jan Beulich
2020-03-18 11:59     ` Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 21/23] xen/build: Use if_changed for prelink*.o Anthony PERARD
2020-02-27 13:16   ` Roger Pau Monné
2020-03-04 16:12     ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 22/23] xen, symbols: rework file symbols selection Anthony PERARD
2020-03-05 14:44   ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 23/23] xen/build: use if_changed to build guest_%.o Anthony PERARD
2020-03-05 15:12   ` Jan Beulich
2020-02-27 21:17 ` [Xen-devel] [XEN PATCH v3 00/23] xen: Build system improvements Stewart Hildebrand
2020-03-06 10:12   ` Anthony PERARD

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=20200227110504.GN24458@Air-de-Roger.citrite.net \
    --to=roger.pau@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@citrix.com \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=konrad.wilk@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.