On Mon, Apr 04, 2022 at 11:10:14AM +0100, Richard Sandiford wrote:
> > Normally updates to the source directory files are guarded with
> > --enable-maintainer-mode, e.g. we don't regenerate configure, config.h,
> > Makefile.in in directories that use automake etc. unless gcc is configured
> > that way.  Otherwise the source tree can't be e.g. stored on a read-only
> > filesystem etc.
> > In gcc/Makefile.in we use @MAINT@ for that but that works because
> > gcc/Makefile is generated by configure.  In config/*/t-* files we need to
> > check $(ENABLE_MAINTAINER_RULES):
> > # The following provides the variable ENABLE_MAINTAINER_RULES that can
> > # be used in language Make-lang.in makefile fragments to enable
> > # maintainer rules.  So, ENABLE_MAINTAINER_RULES is 'true' in
> > # maintainer mode, and '' otherwise.
> > @MAINT@ ENABLE_MAINTAINER_RULES = true
> >
> > This is incremental patch does that, tested again on aarch64-linux and
> > x86_64-linux (cross in that case), ok for trunk?
> >
> > 2022-04-04  Jakub Jelinek  <ja...@redhat.com>
> >
> >     PR target/105144
> >     * config/aarch64/t-aarch64 ($(srcdir)/config/aarch64/aarch64-tune.md,
> >     s-aarch64-tune-md, s-mddeps): Only enable the rules if
> >     $(ENABLE_MAINTAINER_RULES) is non-empty.
> 
> OK.  But I guess the risk is that it will become even easier to forget
> to commit an updated aarch64-tune.md.  Perhaps we should have a
> non-maintainer rule to build aarch64-tune.md locally and check it
> against the source-directory version, and fail the build if there's
> a mismatch.  Or maybe we should just generate aarch64-tune.md in the
> build directory and remove the source directory version.

I've tried if aarch64-tune.md will be read from the build dir, but it is
not.  The gen* files can use -I options to add additional directories, but
they don't use them.

Here is a variant patch which will complain and fail if there is a change
and --enable-maintainer-mode is not enabled:

2022-04-04  Jakub Jelinek  <ja...@redhat.com>

        PR target/105144
        * config/aarch64/t-aarch64 (s-aarch64-tune-md): Do move-if-change
        only if configured with --enable-maintainer-mode, otherwise compare
        tmp-aarch64-tune.md with $(srcdir)/config/aarch64/aarch64-tune.md and
        if they differ, emit a message and fail.

--- gcc/config/aarch64/t-aarch64.jj     2022-04-04 12:09:18.530859281 +0200
+++ gcc/config/aarch64/t-aarch64        2022-04-04 12:44:35.878930189 +0200
@@ -30,8 +30,18 @@ s-aarch64-tune-md: $(srcdir)/config/aarc
        $(SHELL) $(srcdir)/config/aarch64/gentune.sh \
                $(srcdir)/config/aarch64/aarch64-cores.def > \
                tmp-aarch64-tune.md
+ifneq ($(strip $(ENABLE_MAINTAINER_RULES)),)
        $(SHELL) $(srcdir)/../move-if-change tmp-aarch64-tune.md \
                $(srcdir)/config/aarch64/aarch64-tune.md
+else
+       @if ! cmp -s tmp-aarch64-tune.md \
+         $(srcdir)/config/aarch64/aarch64-tune.md; then \
+         echo "aarch64-tune.md has changed; either"; \
+         echo "configure with --enable-maintainer-mode"; \
+         echo "or copy tmp-aarch64-tune.md to 
$(srcdir)/config/aarch64/aarch64-tune.md"; \
+         exit 1; \
+       fi
+endif
        $(STAMP) s-aarch64-tune-md
 
 s-mddeps: s-aarch64-tune-md


        Jakub

Reply via email to