All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony PERARD <anthony.perard@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"George Dunlap" <george.dunlap@citrix.com>,
	"Ian Jackson" <iwj@xenproject.org>,
	"Julien Grall" <julien@xen.org>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Wei Liu" <wl@xen.org>,
	"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>,
	"Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>,
	"Ross Lagerwall" <ross.lagerwall@citrix.com>,
	"Daniel De Graaf" <dgdegra@tycho.nsa.gov>,
	"Daniel P. Smith" <dpsmith@apertussolutions.com>,
	xen-devel@lists.xenproject.org
Subject: Re: [XEN PATCH v7 49/51] build: adding out-of-tree support to the xen build
Date: Fri, 15 Oct 2021 17:58:50 +0100	[thread overview]
Message-ID: <YWmzSkLdH5wtQ77V@perard> (raw)
In-Reply-To: <2aaf0858-1602-be5c-77e4-2daa7fddc534@suse.com>

On Thu, Oct 14, 2021 at 12:14:29PM +0200, Jan Beulich wrote:
> On 24.08.2021 12:50, Anthony PERARD wrote:
> > This implement out-of-tree support, there's two ways to create an
> > out-of-tree build tree (after that, `make` in that new directory
> > works):
> >     make O=build
> >     mkdir build; cd build; make -f ../Makefile
> > also works with an absolute path for both.
> > 
> > This implementation only works if the source tree is clean, as we use
> > VPATH.
> > 
> > This patch copies most new code with handling out-of-tree build from
> > Linux v5.12.
> > 
> > Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> > ---
> >  xen/Makefile                | 173 +++++++++++++++++++++++++++++-------
> >  xen/Rules.mk                |  11 ++-
> >  xen/arch/arm/efi/Makefile   |   3 +
> >  xen/arch/x86/arch.mk        |   3 +
> >  xen/arch/x86/boot/Makefile  |   5 +-
> >  xen/arch/x86/efi/Makefile   |   3 +
> >  xen/include/Makefile        |   9 +-
> >  xen/scripts/mkmakefile      |  17 ++++
> >  xen/test/livepatch/Makefile |   2 +
> >  xen/xsm/flask/Makefile      |   3 +
> >  xen/xsm/flask/ss/Makefile   |   3 +
> >  11 files changed, 194 insertions(+), 38 deletions(-)
> >  create mode 100755 xen/scripts/mkmakefile
> 
> Linux have done away with this script just recently; I don't think we
> should introduce it.

Will change.

> > --- a/xen/Makefile
> > +++ b/xen/Makefile
> > @@ -1,3 +1,7 @@
> > +# $(lastword,) for GNU Make older than 0.81
> 
> DYM 3.81?

Yes.

> > +lastword = $(word $(words $(1)),$(1))
> > +this-makefile := $(call lastword,$(MAKEFILE_LIST))
> 
> Oh - is it documented somewhere that this would always be last?

Yes, it is even in Make's documentation about the variable:
    "if the first thing a makefile does is examine the last word in this
    variable, it will be the name of the current makefile."
    (taken from Make 3.80 documentation)

> > @@ -17,33 +21,18 @@ export XEN_BUILD_HOST	?= $(shell hostname)
> >  PYTHON_INTERPRETER	:= $(word 1,$(shell which python3 python python2 2>/dev/null) python)
> >  export PYTHON		?= $(PYTHON_INTERPRETER)
> >  
> > -export XEN_ROOT := $(CURDIR)/..
> > +$(if $(filter __%, $(MAKECMDGOALS)), \
> > +	$(error targets prefixed with '__' are only for internal use))
> >  
> > -srctree := .
> > -objtree := .
> > -export srctree objtree
> > +# That's our default target when none is given on the command line
> > +PHONY := __all
> > +__all:
> >  
> >  # Do not use make's built-in rules and variables
> >  MAKEFLAGS += -rR
> >  
> >  EFI_MOUNTPOINT ?= $(BOOT_DIR)/efi
> >  
> > -ARCH=$(XEN_TARGET_ARCH)
> > -SRCARCH=$(shell echo $(ARCH) | \
> > -          sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g' \
> > -              -e s'/riscv.*/riscv/g')
> > -export ARCH SRCARCH
> > -
> > -# Don't break if the build process wasn't called from the top level
> > -# we need XEN_TARGET_ARCH to generate the proper config
> > -include $(XEN_ROOT)/Config.mk
> > -
> > -# Set ARCH/SUBARCH appropriately.
> > -export TARGET_SUBARCH  := $(XEN_TARGET_ARCH)
> > -export TARGET_ARCH     := $(shell echo $(XEN_TARGET_ARCH) | \
> > -                            sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g' \
> > -                                -e s'/riscv.*/riscv/g')
> > -
> >  # Allow someone to change their config file
> >  export KCONFIG_CONFIG ?= .config
> 
> Would it be possible to split off some of the pure movement of pieces,
> to make it easier to see what (if anything) is actually changed at the
> same time as getting moved?

I'll give it a try.

> > @@ -51,14 +40,9 @@ export CC CXX LD
> >  
> >  export TARGET := xen
> >  
> > -.PHONY: default
> > -default: build
> > -
> >  .PHONY: dist
> >  dist: install
> >  
> > -include scripts/Kbuild.include
> > -
> >  ifneq ($(root-make-done),y)
> >  # section to run before calling Rules.mk, but only once.
> >  
> > @@ -130,14 +114,93 @@ endif
> >  
> >  ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
> >      quiet := silent_
> > +    KBUILD_VERBOSE = 0
> >  endif
> 
> In how far is this related here? Doesn't this belong in an earlier patch?

That probably belong to a patch that have been committed some time ago,
and I've notice it was missing when comparing our makefile to Linux's
one. (Or maybe it wasn't set as well in Linux originally). I'll look if
that can be added to another patch, or just have a patch for this single
line.

> > --- a/xen/Rules.mk
> > +++ b/xen/Rules.mk
> > @@ -38,7 +38,7 @@ SPECIAL_DATA_SECTIONS := rodata $(foreach a,1 2 4 8 16, \
> >                           $(foreach r,rel rel.ro,data.$(r).local)
> >  
> >  # The filename build.mk has precedence over Makefile
> > -mk-dir := $(src)
> > +mk-dir := $(srctree)/$(src)
> >  include $(if $(wildcard $(mk-dir)/build.mk),$(mk-dir)/build.mk,$(mk-dir)/Makefile)
> 
> Perhaps already when it was changed to $(src) the name has become
> slightly misleading, at least imo: I would rather expect a variable
> with this name to refer to the build dir/tree. Maybe "srcdir" or
> even shorted "sd" right from the start? (Reaching here I can finally
> see why having a shorthand is helpful.)

I have to think about that. I've made some further progress in order to
be able to build the Xen pvhshim without a link farm and notice that
nearly every source file needs to use "$(srctree)/$(src)" and I'm not
sure "$(src)" could be use alone. So having a single variable which have
both would be useful.

"srcdir" might be to close to "srctree" and one might mistake it for the
other, so "sd" might be better.

> > --- a/xen/arch/x86/efi/Makefile
> > +++ b/xen/arch/x86/efi/Makefile
> > @@ -1,5 +1,8 @@
> >  CFLAGS-y += -fshort-wchar
> >  CFLAGS-y += -I$(srctree)/common/efi
> > +ifdef building_out_of_srctree
> > +CFLAGS-y += -I$(srctree)/$(src)
> > +endif
> 
> At the example of this (where perhaps -iquote could be used again) - is
> it strictly necessary to have the ifdef-s around such? I.e. would things
> fail to work for an in-tree build without them?

ifdef isn't really necessary, gcc always check that directory first
anyway (for quote-included headers), so it is just a duplicate of gcc's
path list, but it would work fine. So I'll remove the ifdef.

> > --- a/xen/xsm/flask/ss/Makefile
> > +++ b/xen/xsm/flask/ss/Makefile
> > @@ -9,3 +9,6 @@ obj-y += conditional.o
> >  obj-y += mls.o
> >  
> >  CFLAGS-y += -I$(srctree)/xsm/flask/include
> > +ifdef building_out_of_srctree
> > +    CFLAGS-y += -I$(objtree)/xsm/flask/include
> 
> There's no header in $(srctree)/xsm/flask/include in this case, so if you
> use "ifdef" here, shouldn't that other part move into an "else"?

Actually, there are headers in the source, like "security.h", and `git
ls-files xen/xsm/flask/include` shows plenty other headers.

Thanks,

-- 
Anthony PERARD


  reply	other threads:[~2021-10-15 16:59 UTC|newest]

Thread overview: 161+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-24 10:49 [XEN PATCH v7 00/51] xen: Build system improvements, now with out-of-tree build! Anthony PERARD
2021-08-24 10:49 ` [XEN PATCH v7 01/51] build: introduce cpp_flags macro Anthony PERARD
2021-09-02 10:08   ` Jan Beulich
2021-09-06 10:06     ` Anthony PERARD
2021-09-06 10:30       ` Jan Beulich
2021-09-06 11:21         ` Anthony PERARD
2021-08-24 10:49 ` [XEN PATCH v7 02/51] build: use if_changed on built_in.o Anthony PERARD
2021-08-24 10:49 ` [XEN PATCH v7 03/51] build: use if_changed_rules with %.o:%.c targets Anthony PERARD
2021-08-24 10:49 ` [XEN PATCH v7 04/51] build: factorise generation of the linker scripts Anthony PERARD
2021-09-07 14:22   ` Anthony PERARD
2021-08-24 10:49 ` [XEN PATCH v7 05/51] x86/mm: avoid building multiple .o from a single .c file Anthony PERARD
2021-09-07  6:14   ` Jan Beulich
2021-09-08 11:14     ` Anthony PERARD
2021-09-08 11:44       ` Ian Jackson
2021-10-11 14:13         ` Andrew Cooper
2021-09-08 12:01       ` Jan Beulich
2021-09-09 10:03         ` Anthony PERARD
2021-08-24 10:49 ` [XEN PATCH v7 06/51] build,include: rework compat-build-source.py Anthony PERARD
2021-08-24 10:49 ` [XEN PATCH v7 07/51] build,include: rework compat-build-header.py Anthony PERARD
2021-08-24 10:49 ` [XEN PATCH v7 08/51] build: fix clean targets when subdir-y is used Anthony PERARD
2021-08-24 10:49 ` [XEN PATCH v7 09/51] build: use subdir-y in test/Makefile Anthony PERARD
2021-09-02 10:17   ` Jan Beulich
2021-08-24 10:49 ` [XEN PATCH v7 10/51] build,arm: move LDFLAGS change to arch.mk Anthony PERARD
2021-08-24 12:50   ` Julien Grall
2021-08-24 15:00     ` Anthony PERARD
2021-08-24 15:23       ` Julien Grall
2021-08-24 16:14         ` Anthony PERARD
2021-08-24 10:49 ` [XEN PATCH v7 11/51] build: move make option changes check earlier Anthony PERARD
2021-08-24 10:49 ` [XEN PATCH v7 12/51] build: avoid building arm/arm/*/head.o twice Anthony PERARD
2021-08-24 12:53   ` Julien Grall
2021-08-24 15:12     ` Anthony PERARD
2021-08-24 15:20       ` Julien Grall
2021-08-24 10:50 ` [XEN PATCH v7 13/51] build: convert binfile use to if_changed Anthony PERARD
2021-10-07 13:55   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 14/51] xen: move include/asm-* to arch/*/include/asm Anthony PERARD
2021-10-07 14:17   ` Jan Beulich
2021-10-11 13:57     ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 15/51] build,riscv: tell the build system about riscv64/head.S Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 16/51] build: generate "include/xen/compile.h" with if_changed Anthony PERARD
2021-10-07 14:55   ` Jan Beulich
2021-10-11 14:11     ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 17/51] build: set XEN_BUILD_EFI earlier Anthony PERARD
2021-10-07 16:14   ` Jan Beulich
2021-10-11 14:21     ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 18/51] build: fix $(TARGET).efi creation in arch/arm Anthony PERARD
2021-10-11 10:37   ` Jan Beulich
2021-10-11 14:22     ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 19/51] build: fix arch/x86/note.o rule Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 20/51] build: avoid re-executing the main Makefile by introducing build.mk Anthony PERARD
2021-10-11 10:56   ` Jan Beulich
2021-10-11 14:58     ` Anthony PERARD
2021-10-11 15:31       ` Jan Beulich
2021-10-11 17:07         ` Anthony PERARD
2021-10-12  8:06           ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 21/51] build: set ALL_OBJS to main Makefile; move prelink.o to main Makefile Anthony PERARD
2021-10-11 11:31   ` Jan Beulich
2021-10-13 12:30     ` Anthony PERARD
2021-10-13 12:41       ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 22/51] build: clean common temporary files from root makefile Anthony PERARD
2021-10-11 11:41   ` Jan Beulich
2021-10-13 10:36     ` Anthony PERARD
2021-10-13 12:32       ` Jan Beulich
2021-10-13 14:26         ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 23/51] build,include: remove arch-*/*.h public header listing from headers*.chk Anthony PERARD
2021-10-11 11:49   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 24/51] build: prepare to always invoke $(MAKE) from xen/, use $(obj) Anthony PERARD
2021-10-11 12:39   ` Jan Beulich
2021-10-13 10:57     ` Anthony PERARD
2021-10-13 12:35       ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 25/51] build: rework test/livepatch/Makefile Anthony PERARD
2021-10-11 13:28   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 26/51] build: build everything from the root dir, use obj=$subdir Anthony PERARD
2021-10-11 14:02   ` Jan Beulich
2021-10-13 14:24     ` Anthony PERARD
2021-10-14 13:33       ` Anthony PERARD
2021-10-14 13:54         ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 27/51] build: introduce if_changed_deps Anthony PERARD
2021-10-11 14:20   ` Jan Beulich
2021-10-14 13:56     ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 28/51] build: rename __LINKER__ to LINKER_SCRIPT Anthony PERARD
2021-10-11 14:23   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 29/51] build: add an other explicite rules to not build $(XEN_ROOT)/.config Anthony PERARD
2021-10-11 14:29   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 30/51] build: hook kconfig into xen build system Anthony PERARD
2021-10-11 15:38   ` Jan Beulich
2021-10-14 15:09     ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 31/51] xen/tools/kconfig: fix build with -Wdeclaration-after-statement Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 32/51] build: Remove KBUILD_ specific from Makefile.host Anthony PERARD
2021-10-11 15:47   ` Jan Beulich
2021-10-14 14:18     ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 33/51] build: handle always-y and hostprogs-always-y Anthony PERARD
2021-10-11 15:48   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 34/51] build: start building the tools with the main makefiles Anthony PERARD
2021-10-11 15:49   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 35/51] build: Add headers path to CFLAGS once for all archs Anthony PERARD
2021-10-11 15:51   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 36/51] build: generate x86's asm-macros.h with filechk Anthony PERARD
2021-10-11 15:52   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 37/51] build: clean-up "clean" rules of duplication Anthony PERARD
2021-10-11 15:53   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 38/51] build: use main rune to build host binary x86's mkelf32 and mkreloc Anthony PERARD
2021-10-11 15:56   ` Jan Beulich
2021-10-14 14:20     ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 39/51] build: rework coverage and ubsan CFLAGS handling Anthony PERARD
2021-10-11 16:04   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 40/51] build: fix dependencies in arch/x86/boot Anthony PERARD
2021-10-14  8:08   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 41/51] build,x86: remove the need for build32.mk Anthony PERARD
2021-10-14  8:32   ` Jan Beulich
2021-10-15 15:52     ` Anthony PERARD
2021-10-18  8:43       ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 42/51] build: grab common EFI source files in arch specific dir Anthony PERARD
2021-10-14  8:51   ` Jan Beulich
2021-10-15 16:29     ` Anthony PERARD
2021-10-18  8:48       ` Jan Beulich
2021-10-21 11:03         ` Anthony PERARD
2021-10-21 11:24           ` Jan Beulich
2021-10-21 13:54             ` Anthony PERARD
2021-10-21 14:16               ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 43/51] build: replace $(BASEDIR) by $(objtree) Anthony PERARD
2021-10-14  9:21   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 44/51] build: add $(srctree) in few key places Anthony PERARD
2021-10-14  9:26   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 45/51] build: rework cloc recipe Anthony PERARD
2021-10-14  9:33   ` Jan Beulich
2021-10-15 16:34     ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 46/51] build: replace $(BASEDIR) by $(srctree) Anthony PERARD
2021-10-14  9:36   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 47/51] build: Rework "clean" to clean from the root dir Anthony PERARD
2021-10-14  9:44   ` Jan Beulich
2021-10-15 16:40     ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 48/51] build: Rework "headers*.chk" prerequisite in include/ Anthony PERARD
2021-10-14  9:48   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 49/51] build: adding out-of-tree support to the xen build Anthony PERARD
2021-10-14 10:14   ` Jan Beulich
2021-10-15 16:58     ` Anthony PERARD [this message]
2021-10-18  9:02       ` Jan Beulich
2021-10-18  9:51         ` Anthony PERARD
2021-10-18 10:05           ` Jan Beulich
2021-10-18 10:28           ` Juergen Gross
2021-10-18 10:36             ` Jan Beulich
2021-10-18 10:40               ` Juergen Gross
2021-10-18 11:07                 ` Jan Beulich
2021-10-18 11:20                   ` Juergen Gross
2021-10-18 12:03                     ` Jan Beulich
2021-10-21 14:10               ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 50/51] build: specify source tree in include/ for prerequisite Anthony PERARD
2021-10-14 10:19   ` Jan Beulich
2021-10-15 17:02     ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 51/51] build: add %.E targets Anthony PERARD
2021-10-13 15:48   ` Jan Beulich
2021-10-14  6:52     ` Jan Beulich
2021-09-02 10:22 ` [XEN PATCH v7 00/51] xen: Build system improvements, now with out-of-tree build! Jan Beulich
2021-09-06 16:13 ` Anthony PERARD
2021-09-07  6:20   ` Jan Beulich
2021-09-07  7:46   ` Jan Beulich
2021-09-15  9:53 ` Michal Orzel
2021-11-04 15:49 ` Alex Bennée
2021-11-04 16:12   ` Alex Bennée
2021-11-04 16:34   ` Anthony PERARD
2021-11-04 16:59     ` Alex Bennée

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=YWmzSkLdH5wtQ77V@perard \
    --to=anthony.perard@citrix.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=dpsmith@apertussolutions.com \
    --cc=george.dunlap@citrix.com \
    --cc=iwj@xenproject.org \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=konrad.wilk@oracle.com \
    --cc=roger.pau@citrix.com \
    --cc=ross.lagerwall@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 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.