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

Re: [XEN PATCH v7 26/51] build: build everything from the root dir, use obj=$subdir


  • To: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 11 Oct 2021 16:02:22 +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=xbjm/insLpSAtnftwykU3DoT0k9nscyGQ6ldLJaxOA0=; b=dJlpeqlmd13Qpc7v7ofpZDqzGvFV2bs0DDitRHDKhJSiWQHLCkrUn9O47ZWDsVQico1Mr+E77d0k1fDJpNxGF9OcyB2lOapBrd+SBOdBl0GKGD/Z0AXC38UHl1H6uFlNb0G2So6Ls0NFiauRr5qQNaBlC4xxaVGxBn0goOj9fmRUkw11DPiN/gzkFrI7DpI8iLRqnJcpPn2NNBXOH6r9P+g2og1YC/CyxGB2mV6+D9Sn2FziTF2uaosbdI/cCe3JZYfHXEgQOphqwShnTu5U25N6Gl7P9+HzjnVsS28korK/Dci3NcaRA85XpZC/ffSMgBeYw5dHed3Fz4boRoxXSQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RWYOlAYZPRYjlrqvhtsZ2GLlrP6FhbsUfVb4S9LwElgJB/vq9LbRkJNzCHDRH7zklyjkQ0CLRXcNfo4sI1BmKipBXcErrmnal4bigqgepZ7BPEZEY3HXCnA1PbCmln53lBrbhlBtvf0gMIcmUOp16+NHcp7G2BdlS7U2jo3QVZvfQXK09KWacoT0Z3M4jSKtqL2UejFGpVpFRHm9Xc6939oyySwpEZmkRQbrJ1Qzh+We5b8MpozE0fsdB7bv3IJXkPFwgXyWEzm5s4Y210k8hFBEjeCcYJMPxXXU6MyRW+YUGED70YmTft6L8jPaU1zIgYtzmQ/H7NGaOE9RfzH6hA==
  • 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: Bob Eshleman <bobbyeshleman@xxxxxxxxx>, 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>, Alistair Francis <alistair.francis@xxxxxxx>, Connor Davis <connojdavis@xxxxxxxxx>, 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: Mon, 11 Oct 2021 14:02:34 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 24.08.2021 12:50, Anthony PERARD wrote:
> A subdirectory is now built by setting "$(obj)" instead of changing
> directory. "$(obj)" should always be set when using "Rules.mk" and
> thus a shortcut "$(build)" is introduced and should be used.
> 
> A new variable "$(need-builtin)" is introduce. It is to be used
> whenever a "built_in.o" is wanted from a subdirectory. "built_in.o"
> isn't the main target anymore, and thus only needs to depends on the
> objects that should be part of "built_in.o".

How "good" are our chances that we hit a need-builtin variable from
the environment? Its uses are simply using "ifdef".

> --- a/xen/Rules.mk
> +++ b/xen/Rules.mk
> @@ -3,19 +3,29 @@
>  # Makefile and are consumed by Rules.mk
>  #
>  
> -obj := .
>  src := $(obj)
>  
> +PHONY := __build
> +__build:
> +
>  -include $(BASEDIR)/include/config/auto.conf
>  
>  include $(XEN_ROOT)/Config.mk
>  include $(BASEDIR)/scripts/Kbuild.include
>  
> +ifndef obj
> +$(warning kbuild: Rules.mk is included improperly)
> +endif

Is there a particular reason for this to come only here, rather than
before the include-s (e.g. right at where the assignment to the
variable lived)?

> @@ -51,27 +61,54 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $< $@
>  quiet_cmd_binfile = BINFILE $@
>  cmd_binfile = $(SHELL) $(BASEDIR)/tools/binfile $(BINFILE_FLAGS) $@ $(2)
>  
> -define gendep
> -    ifneq ($(1),$(subst /,:,$(1)))
> -        DEPS += $(dir $(1)).$(notdir $(1)).d
> -    endif
> -endef
> -$(foreach o,$(filter-out %/,$(obj-y) $(obj-bin-y) $(extra-y)),$(eval $(call 
> gendep,$(o))))
> +# Figure out what we need to build from the various variables
> +# ===========================================================================
> +
> +# Libraries are always collected in one lib file.
> +# Filter out objects already built-in
> +lib-y := $(filter-out $(obj-y), $(sort $(lib-y)))
> +
> +# Subdirectories we need to descend into
> +subdir-y := $(subdir-y) $(patsubst %/,%,$(filter %/, $(obj-y)))

Deliberately or accidentally not += ?

> @@ -156,21 +192,13 @@ endif
>  PHONY += FORCE
>  FORCE:
>  
> -%/built_in.o %/lib.a: FORCE
> -     $(MAKE) -f $(BASEDIR)/Rules.mk -C $* built_in.o
> -
> -%/built_in_bin.o: FORCE
> -     $(MAKE) -f $(BASEDIR)/Rules.mk -C $* built_in_bin.o
> -
> -SRCPATH := $(patsubst $(BASEDIR)/%,%,$(CURDIR))
> -
>  quiet_cmd_cc_o_c = CC      $@
>  ifeq ($(CONFIG_ENFORCE_UNIQUE_SYMBOLS),y)
>      cmd_cc_o_c = $(CC) $(c_flags) -c $< -o $(dot-target).tmp -MQ $@
>      ifeq ($(CONFIG_CC_IS_CLANG),y)
> -        cmd_objcopy_fix_sym = $(OBJCOPY) --redefine-sym $<=$(SRCPATH)/$< 
> $(dot-target).tmp $@
> +        cmd_objcopy_fix_sym = $(OBJCOPY) --redefine-sym $(<F)=$< 
> $(dot-target).tmp $@

Are you sure about the $< => $(<F) transformation here? Previoiusly it
was present only ...

>      else
> -        cmd_objcopy_fix_sym = $(OBJCOPY) --redefine-sym $(<F)=$(SRCPATH)/$< 
> $(dot-target).tmp $@
> +        cmd_objcopy_fix_sym = $(OBJCOPY) --redefine-sym $(<F)=$< 
> $(dot-target).tmp $@

... here.

> @@ -251,6 +292,9 @@ existing-targets := $(wildcard $(sort $(targets)))
>  
>  -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
>  
> +DEPS:= $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).d)

Nit: Preferably blanks on both sides of := or none at all, please.

> --- a/xen/arch/x86/Makefile
> +++ b/xen/arch/x86/Makefile
> @@ -81,6 +81,9 @@ endif
>  extra-y += asm-macros.i
>  extra-y += xen.lds
>  
> +# Allows usercopy.c to includes itself

Nit: include

> +$(obj)/usercopy.o: CFLAGS-y += -I.

This is ugly, but presumably unavoidable. Preferably I would see us
the more specific -iquote though, assuming clang also supports it.

> --- a/xen/arch/x86/boot/Makefile
> +++ b/xen/arch/x86/boot/Makefile
> @@ -1,8 +1,8 @@
>  obj-bin-y += head.o
>  
> -DEFS_H_DEPS = $(src)/defs.h $(BASEDIR)/include/xen/stdbool.h
> +DEFS_H_DEPS = $(BASEDIR)/$(src)/defs.h $(BASEDIR)/include/xen/stdbool.h
>  
> -CMDLINE_DEPS = $(DEFS_H_DEPS) $(src)/video.h
> +CMDLINE_DEPS = $(DEFS_H_DEPS) $(BASEDIR)/$(src)/video.h

Hmm, new uses of $(BASEDIR) (a few more further down). Why not
$(srctree)?

Jan




 


Rackspace

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