All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC] build: detect outdated configure outputs
@ 2021-03-11 11:46 Roger Pau Monne
  2021-03-11 13:01 ` Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: Roger Pau Monne @ 2021-03-11 11:46 UTC (permalink / raw)
  To: xen-devel
  Cc: Roger Pau Monne, Andrew Cooper, George Dunlap, Ian Jackson,
	Jan Beulich, Julien Grall, Stefano Stabellini, Wei Liu

The Xen build system relies on configure to parse some .in files in
order to do substitutions based on the data gathered from configure.

The main issue with those substitutions done at the configure level is
that make is not able to detect when they go out of date because the
.in file has been modified, and hence it's possible to end up in a
situation where .in files have been modified but the build is using
outdated ones. This is made even worse because the 'clean' targets
don't remove the output of the .in parsing, so doing a typical `make
clean && make` will still use the old files without complaining.
Note that 'clean' not removing the output of the .in transformations
is the right behavior, otherwise Xen would require re-executing the
configure script after each clean.

Attempt to improve the situation by adding a global rule that spot the
outdated files as long as they are properly listed as makefile target
prerequisites.

Ultimately those substitutions should be part of the build phase, not
the configure one.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
RFC because I'm not sure if there's some better way to handle this.
Also I think we would want to make sure all the .in outputs are
properly listed as target prerequisites, or else this won't work.

Also not sure whether this will break some other usage of .in files
I'm not aware.
---
 Config.mk | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Config.mk b/Config.mk
index a56a971028..a81d384899 100644
--- a/Config.mk
+++ b/Config.mk
@@ -65,6 +65,10 @@ DEPS_RM = $(DEPS) $(DEPS_INCLUDE)
 %.d2: %.d
 	sed "s!\(^\| \)$$PWD/! !" $^ >$@.tmp && mv -f $@.tmp $@
 
+# Make sure the configure generated files are up to date
+%: %.in
+	$(error $@ is outdated, please re-run configure)
+
 include $(XEN_ROOT)/config/$(XEN_OS).mk
 include $(XEN_ROOT)/config/$(XEN_TARGET_ARCH).mk
 
-- 
2.30.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH RFC] build: detect outdated configure outputs
  2021-03-11 11:46 [PATCH RFC] build: detect outdated configure outputs Roger Pau Monne
@ 2021-03-11 13:01 ` Jan Beulich
  2021-03-11 16:12   ` Roger Pau Monné
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2021-03-11 13:01 UTC (permalink / raw)
  To: Roger Pau Monne
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Julien Grall,
	Stefano Stabellini, Wei Liu, xen-devel

On 11.03.2021 12:46, Roger Pau Monne wrote:
> The Xen build system relies on configure to parse some .in files in
> order to do substitutions based on the data gathered from configure.
> 
> The main issue with those substitutions done at the configure level is
> that make is not able to detect when they go out of date because the
> .in file has been modified, and hence it's possible to end up in a
> situation where .in files have been modified but the build is using
> outdated ones. This is made even worse because the 'clean' targets
> don't remove the output of the .in parsing, so doing a typical `make
> clean && make` will still use the old files without complaining.
> Note that 'clean' not removing the output of the .in transformations
> is the right behavior, otherwise Xen would require re-executing the
> configure script after each clean.
> 
> Attempt to improve the situation by adding a global rule that spot the
> outdated files as long as they are properly listed as makefile target
> prerequisites.
> 
> Ultimately those substitutions should be part of the build phase, not
> the configure one.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> ---
> RFC because I'm not sure if there's some better way to handle this.
> Also I think we would want to make sure all the .in outputs are
> properly listed as target prerequisites, or else this won't work.
> 
> Also not sure whether this will break some other usage of .in files
> I'm not aware.

There are a number of such files in the tree which aren't used to
record configure results. Whether their existence could actually
case a problem with this approach I can't tell. Would it be
possible to ...

> --- a/Config.mk
> +++ b/Config.mk
> @@ -65,6 +65,10 @@ DEPS_RM = $(DEPS) $(DEPS_INCLUDE)
>  %.d2: %.d
>  	sed "s!\(^\| \)$$PWD/! !" $^ >$@.tmp && mv -f $@.tmp $@
>  
> +# Make sure the configure generated files are up to date
> +%: %.in
> +	$(error $@ is outdated, please re-run configure)

... make this a static pattern rule for just the file names that
are actually processed / produced by configure? Of course it
wouldn't be very nice to have to keep in sync that list and what
the various configure.ac scripts list in AC_CONFIG_FILES() et al.
But not listing the targets explicitly would always risk the rule
to kick in for a file where it's not supposed to apply.

Jan


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH RFC] build: detect outdated configure outputs
  2021-03-11 13:01 ` Jan Beulich
@ 2021-03-11 16:12   ` Roger Pau Monné
  0 siblings, 0 replies; 3+ messages in thread
From: Roger Pau Monné @ 2021-03-11 16:12 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Julien Grall,
	Stefano Stabellini, Wei Liu, xen-devel

On Thu, Mar 11, 2021 at 02:01:53PM +0100, Jan Beulich wrote:
> On 11.03.2021 12:46, Roger Pau Monne wrote:
> > The Xen build system relies on configure to parse some .in files in
> > order to do substitutions based on the data gathered from configure.
> > 
> > The main issue with those substitutions done at the configure level is
> > that make is not able to detect when they go out of date because the
> > .in file has been modified, and hence it's possible to end up in a
> > situation where .in files have been modified but the build is using
> > outdated ones. This is made even worse because the 'clean' targets
> > don't remove the output of the .in parsing, so doing a typical `make
> > clean && make` will still use the old files without complaining.
> > Note that 'clean' not removing the output of the .in transformations
> > is the right behavior, otherwise Xen would require re-executing the
> > configure script after each clean.
> > 
> > Attempt to improve the situation by adding a global rule that spot the
> > outdated files as long as they are properly listed as makefile target
> > prerequisites.
> > 
> > Ultimately those substitutions should be part of the build phase, not
> > the configure one.
> > 
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> > ---
> > RFC because I'm not sure if there's some better way to handle this.
> > Also I think we would want to make sure all the .in outputs are
> > properly listed as target prerequisites, or else this won't work.
> > 
> > Also not sure whether this will break some other usage of .in files
> > I'm not aware.
> 
> There are a number of such files in the tree which aren't used to
> record configure results. Whether their existence could actually
> case a problem with this approach I can't tell. Would it be
> possible to ...

I think having other .in files in the tree is not a problem with the
target I've added, as it would only apply to files that have an .in
pair and are used as prerequisites.

> > --- a/Config.mk
> > +++ b/Config.mk
> > @@ -65,6 +65,10 @@ DEPS_RM = $(DEPS) $(DEPS_INCLUDE)
> >  %.d2: %.d
> >  	sed "s!\(^\| \)$$PWD/! !" $^ >$@.tmp && mv -f $@.tmp $@
> >  
> > +# Make sure the configure generated files are up to date
> > +%: %.in
> > +	$(error $@ is outdated, please re-run configure)
> 
> ... make this a static pattern rule for just the file names that
> are actually processed / produced by configure? Of course it
> wouldn't be very nice to have to keep in sync that list and what
> the various configure.ac scripts list in AC_CONFIG_FILES() et al.
> But not listing the targets explicitly would always risk the rule
> to kick in for a file where it's not supposed to apply.

Yes, I think it's going to be a pain to keep the list updated, as it's
part of two different configure.ac files.

From a quick look there are other .in files used in a similar way by
ocaml, so those targets will override the pattern rule (%: %.in) in
some places, for example in tools/ocaml/libs/xl/Makefile. I think this
should be fine.

Thanks, Roger.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-11 16:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11 11:46 [PATCH RFC] build: detect outdated configure outputs Roger Pau Monne
2021-03-11 13:01 ` Jan Beulich
2021-03-11 16:12   ` Roger Pau Monné

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.