[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XEN PATCH v7 49/51] build: adding out-of-tree support to the xen build


  • To: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 14 Oct 2021 12:14:29 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=F1w/wcdwqVVfnml3Ug9BPNlOAB72tYYCv1Qc0qqfq1Y=; b=dyVavzGSohGVSBVGSYSQravthB1eVSAp/3m9Lw/StiFOs95BcLYY5Go7K0F5QonZmSoOKpzhtDpIHWT7zbwJtwVA+asR/UyOw9feZmknI7b6PMoqlsLIWOIgVrzl1hmAerk1ClpCh+2n+TaE249i9iHiqNx96VoPmUyJ5lnKYlfjdQARSxAQgKWhUVbcuHKX0e9S5bHKdpraW1WVFKqv1HB0NumVJresw1tu7VoJ1ien91lt7xpHJluvcSiO3mEOfPkiWjqR9ELZNpGuFpgW6+utjNvud5W+h+snzC0M0CQaKIcIFlm1tudJ1ro5rUzRSuEC/pR4TkwUSvLhpi9T8w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XY6O6dFHVHIJ5ABhphh1AH69515SRNBWgyUSmoA1Cfhq9/JZ9LAzdNN+OMqrgddnHDtpBrSAjQoJIOI+UMGqB97rTIyvA68KvaODuLUUAlTU3LTrfxFQct+NZPChHsRdZ52IZnnCaQW3JF3QTkJPM2U1x286S2uA3HCKJJpP24QlJwbkAmM7ImiD/3edPHW5fVr7uvAf2n+ydzIygIzeljCF5x98hNbbqYqqR35FIpQ1Qx8UYQ6ZejX8reUiEVKs2ug4tNBnwtrgxgfeVBtqxqWOuCfnSXEg+rZ0cjsCK1cKXEL6ZC9Uf/itS1mOwmeeqqq16AhxOgbSt4vaBQQTbQ==
  • Authentication-results: lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>, Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>, Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>, "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 14 Oct 2021 10:14:59 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxxxxx>
> ---
>  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.

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

DYM 3.81?

> +lastword = $(word $(words $(1)),$(1))
> +this-makefile := $(call lastword,$(MAKEFILE_LIST))

Oh - is it documented somewhere that this would always be last?

> @@ -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?

> @@ -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?

>  export quiet Q KBUILD_VERBOSE
>  
> +# $(realpath,) for GNU Make older than 0.81

Again - 3.81?

> +ifeq ($(abs_srctree),$(abs_objtree))
> +        # building in the source tree
> +        srctree := .
> +     building_out_of_srctree :=
> +else
> +        ifeq ($(abs_srctree)/,$(dir $(abs_objtree)))
> +                # building in a subdirectory of the source tree
> +                srctree := ..
> +        else
> +                srctree := $(abs_srctree)
> +        endif
> +     building_out_of_srctree := 1
> +endif
> +
> +objtree              := .
> +VPATH                := $(srctree)

Would you mind using blank padding here, and perhaps fewer blanks than
the tabs are worth?

> --- 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.)

> --- 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?

> --- a/xen/include/Makefile
> +++ b/xen/include/Makefile
> @@ -110,7 +110,7 @@ $(obj)/headers99.chk: $(PUBLIC_C99_HEADERS) 
> $(src)/Makefile
>       $(foreach i, $(filter %.h,$^),                                        \
>           echo "#include "\"$(i)\"                                          \
>           | $(CC) -x c -std=c99 -Wall -Werror                               \
> -           -include stdint.h $(foreach j, $($(i)-prereq), -include $(j).h) \
> +           -include stdint.h $(foreach j, $($(patsubst 
> $(srctree)/%,%,$i)-prereq), -include $(j).h) \

Please split the $(foreach ...) from the earlier -include.

> @@ -124,8 +124,8 @@ $(obj)/headers++.chk: $(PUBLIC_HEADERS) $(src)/Makefile
>       $(foreach i, $(filter %.h,$^),                                        \
>           echo "#include "\"$(i)\"                                          \
>           | $(CXX) -x c++ -std=gnu++98 -Wall -Werror -D__XEN_TOOLS__        \
> -           -include stdint.h -include $(src)/public/xen.h                  \
> -           $(foreach j, $($(i)-prereq), -include c$(j)) -S -o /dev/null -  \
> +           -include stdint.h -include $(srctree)/$(src)/public/xen.h       \
> +           $(foreach j, $($(patsubst $(srctree)/%,%,$i)-prereq), -include 
> c$(j)) -S -o /dev/null -  \

Similarly here please split -S ... onto the next line.

> --- 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"?

Jan




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.