On 2024-03-13 04:02, Christophe Lyon via Gdb wrote:
> Hi!
> 
> After recent discussions on IRC and on the lists about maintainer-mode
> and various problems with auto-generated source files, I've written
> this small prototype.
> 
> Based on those discussions, I assumed that people generally want to
> update autotools files using a script similar to autoregen.py, which
> takes care of running aclocal, autoheader, automake and autoconf as
> appropriate.
> 
> What is currently missing is a "simple" way of regenerating other
> files, which happens normally with --enable-maintainer-mode (which is
> reportedly broken).  This patch as a "regenerate" Makefile target
> which can be called to update those files, provided
> --enable-maintainer-mode is used.
> 
> I tried this approach with the following workflow for binutils/gdb:
> - run autoregen.py in srcdir
> - cd builddir
> - configure --enable-maintainer-mode 
> - make all-bfd all-libiberty regenerate -j1
> - for gdb: make all -C gdb/data-directory -j1
> - make all -jXXX
> 
> Making 'all' in bfd and libiberty is needed by some XXX-gen host
> programs in opcodes.
> 
> The advantage (for instance for CI) is that we can regenerate files at
> -j1, thus avoiding the existing race conditions, and build the rest
> with -j XXX.
> 
> Among drawbacks:
> - most sub-components use Makefile.am, but gdb does not: this may make
>   maintenance more complex (different rules for different projects)
> - maintaining such ad-hoc "regenerate" rules would require special
>   attention from maintainers/reviewers
> - dependency on -all-bfd and all-libiberty is probably not fully
>    intuitive, but should not be a problem if the "regenerate" rules
>    are used after a full build for instance
> 
> Of course Makefile.def/Makefile.tpl would need further cleanup as I
> didn't try to take gcc into account is this patch.
> 
> Thoughts?

My first thought it: why is it a Makefile target, instead of some script
on the side (like autoregen.sh).  It would be nice / useful to be
able to it without configuring / building anything.  For instance, the
autoregen buildbot job could run it without configuring anything.
Ideally, the buildbot wouldn't maintain its own autoregen.py file on the
side, it would just use whatever is in the repo.

Looking at the rule to re-generate copying.c in gdb for instance:

    # Make copying.c from COPYING
    $(srcdir)/copying.c: @MAINTAINER_MODE_TRUE@ $(srcdir)/../COPYING3 
$(srcdir)/copying.awk
           awk -f $(srcdir)/copying.awk \
               < $(srcdir)/../COPYING3 > $(srcdir)/copying.tmp
           mv $(srcdir)/copying.tmp $(srcdir)/copying.c

There is nothing in this code that requires having configured the source
tree.  This code could for instance be moved to some
generate-copying-c.sh script.  generate-copying-c.sh could be called by
an hypothetical autoregen.sh script, as well as the copying.c Makefile
target, if we want to continue supporting the maintainer mode.

Much like your regenerate targets, an autoregen.sh script in a given
directory would be responsible to re-generate all the files in this
directory that are generated and checked in git.  It would also be
responsible to call any autoregen.sh file in subdirectories.

There's just the issue of files that are generated using tools that are
compiled.  When experimenting with maintainer mode the other day, I
stumbled on the opcodes/i386-gen, for instance.  I don't have a good
solution to that, except to rewrite these tools in a scripting language
like Python.

Simon

Reply via email to