diff mbox series

Add --enable-first-stage-cross configure option

Message ID 87czrj1ysc.fsf@depni.sinp.msu.ru
State New
Headers show
Series Add --enable-first-stage-cross configure option | expand

Commit Message

Serge Belyshev July 15, 2021, 1:39 p.m. UTC
Add --enable-first-stage-cross configure option

Build static-only, C-only compiler that is sufficient to cross compile
glibc.  This option disables various runtime libraries that require
libc to compile, turns on --with-newlib, --without-headers,
--disable-decimal-float, --disable-shared, --disable-threads, and sets
--enable-languages=c.
    
Rationale: current way of building first stage compiler of a cross
toolchain requires specifying a list of target libraries that are not
going to be compiled due to their dependency on target libc.  This
list is not documented in gccinstall.texi and sometimes changes.  To
simplify the procedure, it is better to maintain that list in the GCC
itself.

Usage example as a patch to glibc's scripts/build-many-libcs.py:

Comments

Serge Belyshev Sept. 6, 2021, 1:13 p.m. UTC | #1
Ping?

[PATCH] Add --enable-first-stage-cross configure option
https://gcc.gnu.org/pipermail/gcc-patches/2021-July/575318.html


> Add --enable-first-stage-cross configure option
>
> Build static-only, C-only compiler that is sufficient to cross compile
> glibc.  This option disables various runtime libraries that require
> libc to compile, turns on --with-newlib, --without-headers,
> --disable-decimal-float, --disable-shared, --disable-threads, and sets
> --enable-languages=c.
>     
> Rationale: current way of building first stage compiler of a cross
> toolchain requires specifying a list of target libraries that are not
> going to be compiled due to their dependency on target libc.  This
> list is not documented in gccinstall.texi and sometimes changes.  To
> simplify the procedure, it is better to maintain that list in the GCC
> itself.
>
> Usage example as a patch to glibc's scripts/build-many-libcs.py:
>
> diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
> index 580d25e8ee..3a6a7be76b 100755
> --- a/scripts/build-many-glibcs.py
> +++ b/scripts/build-many-glibcs.py
> @@ -1446,17 +1446,7 @@ class Config(object):
>              # required to define inhibit_libc (to stop some parts of
>              # libgcc including libc headers); --without-headers is not
>              # sufficient.
> -            cfg_opts += ['--enable-languages=c', '--disable-shared',
> -                         '--disable-threads',
> -                         '--disable-libatomic',
> -                         '--disable-decimal-float',
> -                         '--disable-libffi',
> -                         '--disable-libgomp',
> -                         '--disable-libitm',
> -                         '--disable-libmpx',
> -                         '--disable-libquadmath',
> -                         '--disable-libsanitizer',
> -                         '--without-headers', '--with-newlib',
> +            cfg_opts += ['--enable-first-stage-cross',
>                           '--with-glibc-version=%s' % self.ctx.glibc_version
>                           ]
>              cfg_opts += self.first_gcc_cfg
>
>
> Bootstrapped/regtested on x86_64-pc-linux-gnu, and
> tested with build-many-glibcs.py with the above patch.
>
> OK for mainline?
>
>
> ChangeLog:
>
> 	* configure.ac: Add --enable-first-stage-cross.
> 	* configure: Regenerate.
>
> gcc/ChangeLog:
>
> 	* doc/install.texi: Document --enable-first-stage-cross.
> ---
>  configure            | 20 ++++++++++++++++++++
>  configure.ac         | 15 +++++++++++++++
>  gcc/doc/install.texi |  7 +++++++
>  3 files changed, 42 insertions(+)
>
> diff --git a/configure b/configure
> index 85ab9915402..df59036e258 100755
> --- a/configure
> +++ b/configure
> @@ -787,6 +787,7 @@ ac_user_opts='
>  enable_option_checking
>  with_build_libsubdir
>  with_system_zlib
> +enable_first_stage_cross
>  enable_as_accelerator_for
>  enable_offload_targets
>  enable_offload_defaulted
> @@ -1514,6 +1515,9 @@ Optional Features:
>    --disable-option-checking  ignore unrecognized --enable/--with options
>    --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
>    --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
> +  --enable-first-stage-cross
> +                          Build a static-only compiler that is sufficient to
> +                          build glibc.
>    --enable-as-accelerator-for=ARG
>                            build as offload target compiler. Specify offload
>                            host triple by ARG
> @@ -2961,6 +2965,22 @@ case $is_cross_compiler in
>    no) skipdirs="${skipdirs} ${cross_only}" ;;
>  esac
>  
> +# Check whether --enable-first-stage-cross was given.
> +if test "${enable_first_stage_cross+set}" = set; then :
> +  enableval=$enable_first_stage_cross; ENABLE_FIRST_STAGE_CROSS=$enableval
> +else
> +  ENABLE_FIRST_STAGE_CROSS=no
> +fi
> +
> +case "${ENABLE_FIRST_STAGE_CROSS}" in
> +  yes)
> +    noconfigdirs="$noconfigdirs target-libatomic target-libquadmath target-libgomp target-libssp"
> +    host_configargs="$host_configargs --disable-shared --disable-threads --disable-decimal-float --without-headers --with-newlib"
> +    target_configargs="$target_configargs --disable-shared"
> +    enable_languages=c
> +    ;;
> +esac
> +
>  # If both --with-headers and --with-libs are specified, default to
>  # --without-newlib.
>  if test x"${with_headers}" != x && test x"${with_headers}" != xno \
> diff --git a/configure.ac b/configure.ac
> index 1df038b04f3..53f920c1a2c 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -268,6 +268,21 @@ case $is_cross_compiler in
>    no) skipdirs="${skipdirs} ${cross_only}" ;;
>  esac
>  
> +AC_ARG_ENABLE(first-stage-cross,
> +[AS_HELP_STRING([--enable-first-stage-cross],
> +		[Build a static-only compiler that is
> +		sufficient to build glibc.])],
> +ENABLE_FIRST_STAGE_CROSS=$enableval,
> +ENABLE_FIRST_STAGE_CROSS=no)
> +case "${ENABLE_FIRST_STAGE_CROSS}" in
> +  yes)
> +    noconfigdirs="$noconfigdirs target-libatomic target-libquadmath target-libgomp target-libssp"
> +    host_configargs="$host_configargs --disable-shared --disable-threads --disable-decimal-float --without-headers --with-newlib"
> +    target_configargs="$target_configargs --disable-shared"
> +    enable_languages=c
> +    ;;
> +esac
> +
>  # If both --with-headers and --with-libs are specified, default to
>  # --without-newlib.
>  if test x"${with_headers}" != x && test x"${with_headers}" != xno \
> diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
> index 6eee1bb43d4..b19923769e0 100644
> --- a/gcc/doc/install.texi
> +++ b/gcc/doc/install.texi
> @@ -2501,6 +2501,13 @@ When you use this option, you should ensure that @var{dir} includes
>  @command{ranlib} and @command{strip} if necessary, and possibly
>  @command{objdump}.  Otherwise, GCC may use an inconsistent set of
>  tools.
> +
> +@item --enable-first-stage-cross
> +Build static-only, C-only compiler that is sufficient to cross compile glibc.
> +This option disables various runtime libraries that require libc to compile,
> +turns on @option{--with-newlib}, @option{--without-headers},
> +@option{--disable-decimal-float}, @option{--disable-shared},
> +@option{--disable-threads} and sets @option{--enable-languages=c}.
>  @end table
>  
>  @subsubheading Overriding @command{configure} test results
diff mbox series

Patch

diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
index 580d25e8ee..3a6a7be76b 100755
--- a/scripts/build-many-glibcs.py
+++ b/scripts/build-many-glibcs.py
@@ -1446,17 +1446,7 @@  class Config(object):
             # required to define inhibit_libc (to stop some parts of
             # libgcc including libc headers); --without-headers is not
             # sufficient.
-            cfg_opts += ['--enable-languages=c', '--disable-shared',
-                         '--disable-threads',
-                         '--disable-libatomic',
-                         '--disable-decimal-float',
-                         '--disable-libffi',
-                         '--disable-libgomp',
-                         '--disable-libitm',
-                         '--disable-libmpx',
-                         '--disable-libquadmath',
-                         '--disable-libsanitizer',
-                         '--without-headers', '--with-newlib',
+            cfg_opts += ['--enable-first-stage-cross',
                          '--with-glibc-version=%s' % self.ctx.glibc_version
                          ]
             cfg_opts += self.first_gcc_cfg


Bootstrapped/regtested on x86_64-pc-linux-gnu, and
tested with build-many-glibcs.py with the above patch.

OK for mainline?


ChangeLog:

	* configure.ac: Add --enable-first-stage-cross.
	* configure: Regenerate.

gcc/ChangeLog:

	* doc/install.texi: Document --enable-first-stage-cross.
---
 configure            | 20 ++++++++++++++++++++
 configure.ac         | 15 +++++++++++++++
 gcc/doc/install.texi |  7 +++++++
 3 files changed, 42 insertions(+)

diff --git a/configure b/configure
index 85ab9915402..df59036e258 100755
--- a/configure
+++ b/configure
@@ -787,6 +787,7 @@  ac_user_opts='
 enable_option_checking
 with_build_libsubdir
 with_system_zlib
+enable_first_stage_cross
 enable_as_accelerator_for
 enable_offload_targets
 enable_offload_defaulted
@@ -1514,6 +1515,9 @@  Optional Features:
   --disable-option-checking  ignore unrecognized --enable/--with options
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --enable-first-stage-cross
+                          Build a static-only compiler that is sufficient to
+                          build glibc.
   --enable-as-accelerator-for=ARG
                           build as offload target compiler. Specify offload
                           host triple by ARG
@@ -2961,6 +2965,22 @@  case $is_cross_compiler in
   no) skipdirs="${skipdirs} ${cross_only}" ;;
 esac
 
+# Check whether --enable-first-stage-cross was given.
+if test "${enable_first_stage_cross+set}" = set; then :
+  enableval=$enable_first_stage_cross; ENABLE_FIRST_STAGE_CROSS=$enableval
+else
+  ENABLE_FIRST_STAGE_CROSS=no
+fi
+
+case "${ENABLE_FIRST_STAGE_CROSS}" in
+  yes)
+    noconfigdirs="$noconfigdirs target-libatomic target-libquadmath target-libgomp target-libssp"
+    host_configargs="$host_configargs --disable-shared --disable-threads --disable-decimal-float --without-headers --with-newlib"
+    target_configargs="$target_configargs --disable-shared"
+    enable_languages=c
+    ;;
+esac
+
 # If both --with-headers and --with-libs are specified, default to
 # --without-newlib.
 if test x"${with_headers}" != x && test x"${with_headers}" != xno \
diff --git a/configure.ac b/configure.ac
index 1df038b04f3..53f920c1a2c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -268,6 +268,21 @@  case $is_cross_compiler in
   no) skipdirs="${skipdirs} ${cross_only}" ;;
 esac
 
+AC_ARG_ENABLE(first-stage-cross,
+[AS_HELP_STRING([--enable-first-stage-cross],
+		[Build a static-only compiler that is
+		sufficient to build glibc.])],
+ENABLE_FIRST_STAGE_CROSS=$enableval,
+ENABLE_FIRST_STAGE_CROSS=no)
+case "${ENABLE_FIRST_STAGE_CROSS}" in
+  yes)
+    noconfigdirs="$noconfigdirs target-libatomic target-libquadmath target-libgomp target-libssp"
+    host_configargs="$host_configargs --disable-shared --disable-threads --disable-decimal-float --without-headers --with-newlib"
+    target_configargs="$target_configargs --disable-shared"
+    enable_languages=c
+    ;;
+esac
+
 # If both --with-headers and --with-libs are specified, default to
 # --without-newlib.
 if test x"${with_headers}" != x && test x"${with_headers}" != xno \
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index 6eee1bb43d4..b19923769e0 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -2501,6 +2501,13 @@  When you use this option, you should ensure that @var{dir} includes
 @command{ranlib} and @command{strip} if necessary, and possibly
 @command{objdump}.  Otherwise, GCC may use an inconsistent set of
 tools.
+
+@item --enable-first-stage-cross
+Build static-only, C-only compiler that is sufficient to cross compile glibc.
+This option disables various runtime libraries that require libc to compile,
+turns on @option{--with-newlib}, @option{--without-headers},
+@option{--disable-decimal-float}, @option{--disable-shared},
+@option{--disable-threads} and sets @option{--enable-languages=c}.
 @end table
 
 @subsubheading Overriding @command{configure} test results