All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Anthony PERARD <anthony.perard@citrix.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>, Wei Liu <wl@xen.org>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	George Dunlap <george.dunlap@citrix.com>,
	xen-devel@lists.xenproject.org
Subject: Re: [XEN PATCH v4 08/18] xen/build: introduce if_changed and if_changed_rule
Date: Wed, 8 Apr 2020 14:05:43 +0200	[thread overview]
Message-ID: <45e19a69-2f9e-a264-0129-539d362487a4@suse.com> (raw)
In-Reply-To: <20200331103102.1105674-9-anthony.perard@citrix.com>

On 31.03.2020 12:30, Anthony PERARD wrote:
> The if_changed macro from Linux, in addition to check if any files
> needs an update, check if the command line has changed since the last
> invocation. The latter will force a rebuild if any options to the
> executable have changed.
> 
> if_changed_rule checks dependencies like if_changed, but execute
> rule_$(1) instead of cmd_$(1) when a target needs to be rebuilt. A rule_
> macro can call more than one cmd_ macro. One of the cmd_ macro in a
> rule need to be call using a macro that record the command line, so
> cmd_and_record is introduced. It is similar to cmd_and_fixup from
> Linux but without a call to fixdep which we don't have yet. (We will
> later replace cmd_and_record by cmd_and_fixup.)
> 
> Example of a rule_ macro:
> define rule_cc_o_c
>     $(call cmd_and_record,cc_o_o)
>     $(call cmd,objcopy)
> endef
> 
> This needs one of the call to use cmd_and_record, otherwise no .*.cmd
> file will be created, and the target will keep been rebuilt.
> 
> In order for if_changed to works correctly, we need to load the .%.cmd
> files that the macro generates, this is done by adding targets in to
> the $(targets) variable. We use intermediate_targets to add %.init.o
> dependency %.o to target since there aren't in obj-y.
> 
> We also add $(MAKECMDGOALS) to targets so that when running for
> example `make common/memory.i`, make will load the associated .%.cmd
> dependency file.
> 
> Beside the if_changed*, we import the machinery used for a "beautify
> output". The important one is when running make with V=2 which help to
> debug the makefiles by printing why a target is been rebuilt, via the
> $(echo-why) macro.
> 
> if_changed and if_changed_rule aren't used yet.
> 
> Most of this code is copied from Linux v5.4, including the
> documentation.
> 
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

Acked-by: Jan Beulich <jbeulich@suse.com>
with ...

> --- a/docs/misc/xen-makefiles/makefiles.rst
> +++ b/docs/misc/xen-makefiles/makefiles.rst
> @@ -85,3 +85,102 @@ Compilation flags
>  
>  	CFLAGS-y specifies options for compiling with $(CC).
>  	AFLAGS-y specifies assembler options.
> +
> +
> +Build system infrastructure
> +===========================
> +
> +This chapter describe some of the macro used when building Xen.
> +
> +Macros
> +------
> +
> +
> +    if_changed
> +	if_changed is the infrastructure used for the following commands.
> +
> +	Usage::
> +
> +		target: source(s) FORCE
> +			$(call if_changed,ld/objcopy/...)
> +
> +	When the rule is evaluated, it is checked to see if any files
> +	need an update, or the command line has changed since the last
> +	invocation. The latter will force a rebuild if any options
> +	to the executable have changed.
> +	Any target that utilises if_changed must be listed in $(targets),
> +	otherwise the command line check will fail, and the target will
> +	always be built.
> +	if_changed may be used in conjunction with custom commands as
> +	defined in "Custom commands".
> +
> +	Note: It is a typical mistake to forget the FORCE prerequisite.
> +	Another common pitfall is that whitespace is sometimes
> +	significant; for instance, the below will fail (note the extra space
> +	after the comma)::
> +
> +		target: source(s) FORCE
> +
> +	**WRONG!**	$(call if_changed, ld/objcopy/...)
> +
> +        Note:
> +	      if_changed should not be used more than once per target.
> +              It stores the executed command in a corresponding .cmd

... the odd mixing of tabs and spaces here taken care of (I didn't
check if there are more) and ...

> +
> +        file and multiple calls would result in overwrites and

... the apparently stray blank like here dropped.

Jan


  reply	other threads:[~2020-04-08 12:06 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-31 10:30 [XEN PATCH v4 00/18] xen: Build system improvements Anthony PERARD
2020-03-31 10:30 ` [XEN PATCH v4 01/18] xen/arm: Rename all early printk macro Anthony PERARD
2020-03-31 10:30 ` [XEN PATCH v4 02/18] xen/arm: Configure early printk via Kconfig Anthony PERARD
2020-04-01  9:22   ` Julien Grall
2020-03-31 10:30 ` [XEN PATCH v4 03/18] build,arm: Fix deps check of head.o Anthony PERARD
2020-04-01  9:42   ` Julien Grall
2020-03-31 10:30 ` [XEN PATCH v4 04/18] xen/build: include include/config/auto.conf in main Makefile Anthony PERARD
2020-04-08 11:33   ` Jan Beulich
2020-04-14 12:24     ` Anthony PERARD
2020-03-31 10:30 ` [XEN PATCH v4 05/18] xen/build: use new $(c_flags) and $(a_flags) instead of $(CFLAGS) Anthony PERARD
2020-04-08 11:36   ` Jan Beulich
2020-03-31 10:30 ` [XEN PATCH v4 06/18] xen/build: have the root Makefile generates the CFLAGS Anthony PERARD
2020-04-08 11:50   ` Jan Beulich
2020-04-15 14:10     ` Anthony PERARD
2020-04-15 15:55       ` Jan Beulich
2020-03-31 10:30 ` [XEN PATCH v4 07/18] build: Introduce documentation for xen Makefiles Anthony PERARD
2020-04-08 12:00   ` Jan Beulich
2020-04-15 14:38     ` Anthony PERARD
2020-03-31 10:30 ` [XEN PATCH v4 08/18] xen/build: introduce if_changed and if_changed_rule Anthony PERARD
2020-04-08 12:05   ` Jan Beulich [this message]
2020-03-31 10:30 ` [XEN PATCH v4 09/18] xen/build: Start using if_changed Anthony PERARD
2020-03-31 10:30 ` [XEN PATCH v4 10/18] xen/build: use if_changed on built_in.o Anthony PERARD
2020-04-08 12:40   ` Jan Beulich
2020-04-08 13:13     ` Andrew Cooper
2020-04-08 13:35       ` Jan Beulich
2020-04-15 16:06         ` Anthony PERARD
2020-03-31 10:30 ` [XEN PATCH v4 11/18] xen/build: Use if_changed_rules with %.o:%.c targets Anthony PERARD
2020-03-31 10:30 ` [XEN PATCH v4 12/18] xen/build: factorise generation of the linker scripts Anthony PERARD
2020-04-08 12:46   ` Jan Beulich
2020-04-15 16:58     ` Anthony PERARD
2020-04-16  7:36       ` Jan Beulich
2020-04-16  9:57         ` Anthony PERARD
2020-03-31 10:30 ` [XEN PATCH v4 13/18] xen/build: Use if_changed for prelink*.o Anthony PERARD
2020-03-31 10:30 ` [XEN PATCH v4 14/18] xen,symbols: rework file symbols selection Anthony PERARD
2020-04-08 12:54   ` Jan Beulich
2020-04-16 12:44     ` Anthony PERARD
2020-04-16 14:22       ` Jan Beulich
2020-04-16 15:09         ` Anthony PERARD
2020-04-17  7:12           ` Jan Beulich
2020-04-17 13:19             ` Anthony PERARD
2020-04-17 13:39               ` Jan Beulich
2020-04-17 14:42                 ` Anthony PERARD
2020-04-20 13:39                   ` Jan Beulich
2020-03-31 10:30 ` [XEN PATCH v4 15/18] xen/build: use if_changed to build guest_%.o Anthony PERARD
2020-04-08 13:02   ` Jan Beulich
2020-04-16 12:57     ` Anthony PERARD
2020-04-16 14:28       ` Jan Beulich
2020-03-31 10:31 ` [XEN PATCH v4 16/18] build,xsm: Fix multiple call Anthony PERARD
2020-04-08 13:28   ` Jan Beulich
2020-04-16 13:02     ` Anthony PERARD
2020-04-16 14:30       ` Jan Beulich
2020-03-31 10:31 ` [XEN PATCH v4 17/18] build,include: rework compat-build-source.py Anthony PERARD
2020-04-08 13:53   ` [XEN PATCH v4 17/18] build, include: " Jan Beulich
2020-04-16 13:07     ` Anthony PERARD
2020-03-31 10:31 ` [XEN PATCH v4 18/18] build,include: rework compat-build-header.py Anthony PERARD
2020-04-08 13:56   ` [XEN PATCH v4 18/18] build, include: " Jan Beulich
2020-04-16 14:17     ` Anthony PERARD
2020-04-16 14:34       ` Jan Beulich
2020-04-01  9:52 ` [XEN PATCH v4 00/18] xen: Build system improvements Julien Grall

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=45e19a69-2f9e-a264-0129-539d362487a4@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=julien@xen.org \
    --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.