Enable top-level recursive 'autoreconf' (was: Hints on reconfiguring GCC)

Message ID 87v8b37ye7.fsf@euler.schwinge.homeip.net
State Accepted
Headers
Series Enable top-level recursive 'autoreconf' (was: Hints on reconfiguring GCC) |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Thomas Schwinge Oct. 19, 2023, 9:30 a.m. UTC
  Hi!

On 2023-10-18T15:42:18+0100, R jd <3246251196ryan@gmail.com> wrote:
> I guess I can ask, why there is not a recursive approach for configuring
> GCC. e.g. AC_SUBDIRS in the top level?

('AC_CONFIG_SUBDIRS' you mean.)  You know, often it just takes someone to
ask the right questions...  ;-)

What do people think about the attached
"Enable top-level recursive 'autoreconf'"?  Only lightly tested, so far.


Grüße
 Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
  

Comments

Andreas Schwab Oct. 19, 2023, 9:57 a.m. UTC | #1
On Okt 19 2023, Thomas Schwinge wrote:

> Hi!
>
> On 2023-10-18T15:42:18+0100, R jd <3246251196ryan@gmail.com> wrote:
>> I guess I can ask, why there is not a recursive approach for configuring
>> GCC. e.g. AC_SUBDIRS in the top level?
>
> ('AC_CONFIG_SUBDIRS' you mean.)  You know, often it just takes someone to
> ask the right questions...  ;-)
>
> What do people think about the attached
> "Enable top-level recursive 'autoreconf'"?  Only lightly tested, so far.

The top-level files are shared with binutils-gdb, which has a different
set of subdirs.
  
Alexandre Oliva Oct. 20, 2023, 4:07 a.m. UTC | #2
On Oct 19, 2023, Thomas Schwinge <thomas@codesourcery.com> wrote:

> On 2023-10-18T15:42:18+0100, R jd <3246251196ryan@gmail.com> wrote:
>> I guess I can ask, why there is not a recursive approach for configuring
>> GCC. e.g. AC_SUBDIRS in the top level?

> ('AC_CONFIG_SUBDIRS' you mean.)  You know, often it just takes someone to
> ask the right questions...  ;-)

> What do people think about the attached
> "Enable top-level recursive 'autoreconf'"?  Only lightly tested, so far.

Interesting idea!

It is a little hackish, in that it seems to exploit an implementation
detail in AC_CONFIG_SUBDIRS rather than a documented feature.

I like it!

The autoconf documentation suggests that optional directories can be
tested for:

  if test -d "$srcdir/foo"; then
    AC_CONFIG_SUBDIRS([foo])
  fi

We could use a macro that takes a list and iterates over the list (untested):

dnl Handle a list of optional subdirs.
dnl After AC_OUTPUT, affects autoreconf runs, but not configure runs.
AC_DEFUN([AC_CONFIG_SUBDIRS_OPT], [
  m4_foreach_w([dir], [$1], [
    if test -d "$srcdir/dir"; then
      AC_CONFIG_SUBDIRS(dir)
    fi
  ])
])

Thanks,
  
Hans-Peter Nilsson Oct. 30, 2023, 1:31 a.m. UTC | #3
> From: Thomas Schwinge <thomas@codesourcery.com>
> Date: Thu, 19 Oct 2023 12:42:26 +0200

> It's just GCC and Binutils/GDB, or are the top-level files also shared
> with additional projects?

Not sure if that counts as "shared", but I regularly drop
in* newlib to build simulator targets (*-elf, *-newabi).
That's git://sourceware.org/git/newlib-cygwin.git but I
extract tarballs for the merging.

"Drop in" is actually the other way round, starting with a
newlib tarball, so gcc files overwrite newlib ones.

(FWIW, I never drop in binutils like that; they're better
built separately.  "Better" for your long-term sanity.)

brgds, H-P
  

Patch

From 43127e5643337ca407071ad93bccbc716024352e Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Thu, 19 Oct 2023 10:28:30 +0200
Subject: [PATCH] Enable top-level recursive 'autoreconf'

	* configure.ac: At end of file, instantiate 'AC_CONFIG_SUBDIRS'
	for all relevant directories.
	* configure: Regenerate.
---
 configure    | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 configure.ac |  36 ++++++++++++++++++
 2 files changed, 136 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 8fc163d36bd..fcb4d591334 100755
--- a/configure
+++ b/configure
@@ -584,7 +584,8 @@  PACKAGE_URL=
 
 ac_unique_file="move-if-change"
 enable_option_checking=no
-ac_subst_vars='LTLIBOBJS
+ac_subst_vars='subdirs
+LTLIBOBJS
 LIBOBJS
 compare_exclusions
 stage2_werror_flag
@@ -909,7 +910,37 @@  READELF_FOR_TARGET
 STRIP_FOR_TARGET
 WINDRES_FOR_TARGET
 WINDMC_FOR_TARGET'
-
+ac_subdirs_all='c++tools
+fixincludes
+gcc
+gcc/m2
+gnattools
+gotools
+intl
+libada
+libatomic
+libbacktrace
+libcc1
+libcody
+libcpp
+libdecnumber
+libffi
+libgcc
+libgfortran
+libgm2
+libgo
+libgomp
+libiberty
+libitm
+libobjc
+libphobos
+libquadmath
+libsanitizer
+libssp
+libstdc++-v3
+libvtv
+lto-plugin
+zlib'
 
 # Initialize some variables set by options.
 ac_init_help=
@@ -20081,3 +20112,70 @@  if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
 fi
 
+
+# Enable top-level recursive 'autoreconf' by enumerating all relevant
+# directories here.  This is intentionally done at end of 'configure.ac',
+# *after* 'AC_OUTPUT', so that we don't attempt to prematurely 'configure'
+# these directories when the top-level 'configure' is invoked.
+subdirs="$subdirs c++tools"
+
+subdirs="$subdirs fixincludes"
+
+subdirs="$subdirs gcc"
+
+subdirs="$subdirs gcc/m2"
+
+subdirs="$subdirs gnattools"
+
+subdirs="$subdirs gotools"
+
+subdirs="$subdirs intl"
+
+subdirs="$subdirs libada"
+
+subdirs="$subdirs libatomic"
+
+subdirs="$subdirs libbacktrace"
+
+subdirs="$subdirs libcc1"
+
+subdirs="$subdirs libcody"
+
+subdirs="$subdirs libcpp"
+
+subdirs="$subdirs libdecnumber"
+
+subdirs="$subdirs libffi"
+
+subdirs="$subdirs libgcc"
+
+subdirs="$subdirs libgfortran"
+
+subdirs="$subdirs libgm2"
+
+subdirs="$subdirs libgo"
+
+subdirs="$subdirs libgomp"
+
+subdirs="$subdirs libiberty"
+
+subdirs="$subdirs libitm"
+
+subdirs="$subdirs libobjc"
+
+subdirs="$subdirs libphobos"
+
+subdirs="$subdirs libquadmath"
+
+subdirs="$subdirs libsanitizer"
+
+subdirs="$subdirs libssp"
+
+subdirs="$subdirs libstdc++-v3"
+
+subdirs="$subdirs libvtv"
+
+subdirs="$subdirs lto-plugin"
+
+subdirs="$subdirs zlib"
+
diff --git a/configure.ac b/configure.ac
index 1d16530140a..0d37d30196e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3944,3 +3944,39 @@  AC_CONFIG_FILES([Makefile],
    extrasub_host="$extrasub_host"
    extrasub_target="$extrasub_target"])
 AC_OUTPUT
+
+# Enable top-level recursive 'autoreconf' by enumerating all relevant
+# directories here.  This is intentionally done at end of 'configure.ac',
+# *after* 'AC_OUTPUT', so that we don't attempt to prematurely 'configure'
+# these directories when the top-level 'configure' is invoked.
+AC_CONFIG_SUBDIRS([c++tools])
+AC_CONFIG_SUBDIRS([fixincludes])
+AC_CONFIG_SUBDIRS([gcc])
+AC_CONFIG_SUBDIRS([gcc/m2])
+AC_CONFIG_SUBDIRS([gnattools])
+AC_CONFIG_SUBDIRS([gotools])
+AC_CONFIG_SUBDIRS([intl])
+AC_CONFIG_SUBDIRS([libada])
+AC_CONFIG_SUBDIRS([libatomic])
+AC_CONFIG_SUBDIRS([libbacktrace])
+AC_CONFIG_SUBDIRS([libcc1])
+AC_CONFIG_SUBDIRS([libcody])
+AC_CONFIG_SUBDIRS([libcpp])
+AC_CONFIG_SUBDIRS([libdecnumber])
+AC_CONFIG_SUBDIRS([libffi])
+AC_CONFIG_SUBDIRS([libgcc])
+AC_CONFIG_SUBDIRS([libgfortran])
+AC_CONFIG_SUBDIRS([libgm2])
+AC_CONFIG_SUBDIRS([libgo])
+AC_CONFIG_SUBDIRS([libgomp])
+AC_CONFIG_SUBDIRS([libiberty])
+AC_CONFIG_SUBDIRS([libitm])
+AC_CONFIG_SUBDIRS([libobjc])
+AC_CONFIG_SUBDIRS([libphobos])
+AC_CONFIG_SUBDIRS([libquadmath])
+AC_CONFIG_SUBDIRS([libsanitizer])
+AC_CONFIG_SUBDIRS([libssp])
+AC_CONFIG_SUBDIRS([libstdc++-v3])
+AC_CONFIG_SUBDIRS([libvtv])
+AC_CONFIG_SUBDIRS([lto-plugin])
+AC_CONFIG_SUBDIRS([zlib])
-- 
2.34.1