xen/build: have the root Makefile generates the CFLAGS
authorAnthony PERARD <anthony.perard@citrix.com>
Fri, 24 Apr 2020 12:57:10 +0000 (14:57 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 24 Apr 2020 12:57:10 +0000 (14:57 +0200)
commit2740d96efdd3009f8adb40aacdbcf05cfe8d1bbb
tree522a491d245c875ec2a66840b067bad7aedb3906
parentaa14feb6723d3bb15a884533ade1cd9732792145
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>
15 files changed:
xen/Makefile
xen/Rules.mk
xen/arch/arm/Makefile
xen/arch/arm/Rules.mk
xen/arch/arm/arch.mk [new file with mode: 0644]
xen/arch/arm/efi/Makefile
xen/arch/x86/Makefile
xen/arch/x86/Rules.mk
xen/arch/x86/arch.mk [new file with mode: 0644]
xen/arch/x86/efi/Makefile
xen/common/libelf/Makefile
xen/common/libfdt/Makefile
xen/include/Makefile
xen/xsm/flask/Makefile
xen/xsm/flask/ss/Makefile