Re: [PATCH v3] gcc_update: use human readable name for revision string in gcc/REVISION

2021-09-06 Thread Serge Belyshev
Jakub Jelinek  writes:

> On Mon, Sep 06, 2021 at 12:49:18PM +0300, Serge Belyshev wrote:
>   * gcc_update: derive human readable name for HEAD using git describe
>
> After : start with upper case, ^^^ Derive
>
>   like "git gcc-descr" with short commit hash.  Drop "revision" from 
> gcc/REVISION.
>
> Too long line.
>
> Otherwise LGTM.

Thanks!  Changed and committed as r12-3370-g78b34cd8a80.


Ping: [PATCH] Add --enable-first-stage-cross configure option

2021-09-06 Thread Serge Belyshev
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_STAG

[PATCH] Add --enable-first-stage-cross configure option

2021-07-15 Thread Serge Belyshev
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
+
 # I

[PATCH] gcc_update: use gcc-descr git alias for revision string in gcc/REVISION

2021-07-15 Thread Serge Belyshev
This is to make development version string more readable, and
to simplify navigation through gcc-testresults.

Currently gcc_update uses git log --pretty=tformat:%p:%t:%H to
generate version string, which is somewhat excessive since conversion
to git because commit hashes are now stable.

Even better, gcc-git-customization.sh script provides gcc-descr alias
which makes prettier version string, and thus use it instead (or just
abbreviated commit hash when the alias is not available).

Before: [master revision 
b25edf6e6fe:e035f180ebf:7094a69bd62a14dfa311eaa2fea468f221c7c9f3]
After: [master r12-2331]

OK for mainline?

contrib/Changelog:

* gcc_update: Use gcc-descr alias for revision string if it exists, or
abbreviated commit hash instead. Drop "revision" from gcc/REVISION.
---
 contrib/gcc_update | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/gcc_update b/contrib/gcc_update
index 80fac9fc995..8f712e37616 100755
--- a/contrib/gcc_update
+++ b/contrib/gcc_update
@@ -332,7 +332,7 @@ case $vcs_type in
 exit 1
fi
 
-   revision=`$GCC_GIT log -n1 --pretty=tformat:%p:%t:%H`
+   revision=`$GCC_GIT gcc-descr || $GCC_GIT log -n1 --pretty=tformat:%h`
branch=`$GCC_GIT name-rev --name-only HEAD || :`
;;
 
@@ -414,6 +414,6 @@ rm -f LAST_UPDATED gcc/REVISION
 date
 echo "`TZ=UTC date` (revision $revision)"
 } > LAST_UPDATED
-echo "[$branch revision $revision]" > gcc/REVISION
+echo "[$branch $revision]" > gcc/REVISION
 
 touch_files_reexec


[PATCH v2] gcc_update: use human readable name for revision string in gcc/REVISION

2021-07-16 Thread Serge Belyshev
Based on discussion I've chosen open-coded version without commit hash.

>> > > ...  Perhaps rename the r, o, rr and m temporaries.

I like it better with short names, there is no other code in that
script to clash with.  (Also, two adjacent case branches for hg and svn
are essentialy dead now).

>> ...  Perhaps also replace both HEAD occurences with $revision

not sure about that: should not they be exactly equivalent in all cases?

---
gcc_update: use human readable name for revision string in gcc/REVISION

contrib/Changelog:

* gcc_update: derive human readable name for HEAD using git describe
like "git gcc-descr" does.  Drop "revision" from gcc/REVISION.
---
 contrib/gcc_update | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/contrib/gcc_update b/contrib/gcc_update
index 80fac9fc995..558926b3a2d 100755
--- a/contrib/gcc_update
+++ b/contrib/gcc_update
@@ -332,7 +332,22 @@ case $vcs_type in
 exit 1
fi
 
-   revision=`$GCC_GIT log -n1 --pretty=tformat:%p:%t:%H`
+   # Open-coded version of "git gcc-descr" from 
contrib/gcc-git-customization.sh
+   revision=`$GCC_GIT log -n1 --pretty=tformat:%h`
+   r=`$GCC_GIT describe --all --match 'basepoints/gcc-[0-9]*' HEAD \
+  | sed -n 
's,^\(tags/\)\?basepoints/gcc-\([0-9]\+\)-\([0-9]\+\)-g[0-9a-f]*$,r\2-\3,p;s,^\(tags/\)\?basepoints/gcc-\([0-9]\+\)$,r\2-0,p'`;
+   if test -n $r; then
+   o=`$GCC_GIT config --get gcc-config.upstream`;
+   rr=`echo $r | sed -n 
's,^r\([0-9]\+\)-[0-9]\+\(-g[0-9a-f]\+\)\?$,\1,p'`;
+   if $GCC_GIT rev-parse --verify --quiet 
${o:-origin}/releases/gcc-$rr >/dev/null; then
+   m=releases/gcc-$rr;
+   else
+   m=master;
+   fi;
+   if $GCC_GIT merge-base --is-ancestor HEAD ${o:-origin}/$m; then
+   revision=$r;
+   fi
+   fi
branch=`$GCC_GIT name-rev --name-only HEAD || :`
;;
 
@@ -414,6 +429,6 @@ rm -f LAST_UPDATED gcc/REVISION
 date
 echo "`TZ=UTC date` (revision $revision)"
 } > LAST_UPDATED
-echo "[$branch revision $revision]" > gcc/REVISION
+echo "[$branch $revision]" > gcc/REVISION
 
 touch_files_reexec


[PATCH v3] gcc_update: use human readable name for revision string in gcc/REVISION

2021-07-19 Thread Serge Belyshev


>> > On 19 Jul 2021, at 11:39, Richard Biener via Gcc-patches 
>> >  wrote:
>> > 
>> > On Fri, Jul 16, 2021 at 12:37 PM Serge Belyshev
>> >  wrote:
>> >> 
>> >> Based on discussion I've chosen open-coded version without commit hash.
>> > 
>> > As said I'd prefer one with (shortened) hash,

Oh, I misunderstood then.

>> 
>> Likewise, I’ve been using a local change to produce “r12-2447-gcca1e30db142” 
>>  since soon after
>> change; I suspect that 12 digits is ‘enough’.  It makes it easier for the 
>> folks who want to find by 
>> SHA1 as well as folks who want to find by revision number.
>
> If the patch is changed from
>   revision=$r;
> to
>   revision=${r}-g${revision};
> then the exact hash length isn't hardcoded to 12 digits, but whatever git
> chooses to make it unique (with the current state of repository).
> Of course, changes later on in the repository can introduce collisions and
> more hash letters might be needed, but that is a general git problem.  And
> at least when we have the rXX--gZ revisions, it is still unique
> on the release branches, just one might need to use
> $(git gcc-descr `echo $rev | sed 's/-g[0-9a-f]*$//'`)
> instead of just
> $rev
> in case such collision happens if git tells rXX--g is ambiguous.
>

Right, variant with hash has the advantage that it is understood by git
out of the box without customisations, so be it then.

OK for mainline?

---
contrib/Changelog:

* gcc_update: derive human readable name for HEAD using git describe
like "git gcc-descr" with short commit hash.  Drop "revision" from 
gcc/REVISION.
---
 contrib/gcc_update | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/contrib/gcc_update b/contrib/gcc_update
index 80fac9fc995..ce472545e25 100755
--- a/contrib/gcc_update
+++ b/contrib/gcc_update
@@ -332,7 +332,22 @@ case $vcs_type in
 exit 1
fi
 
-   revision=`$GCC_GIT log -n1 --pretty=tformat:%p:%t:%H`
+   # Open-coded version of "git gcc-descr" from 
contrib/gcc-git-customization.sh
+   revision=`$GCC_GIT log -n1 --pretty=tformat:%h`
+   r=`$GCC_GIT describe --all --match 'basepoints/gcc-[0-9]*' HEAD \
+  | sed -n 
's,^\(tags/\)\?basepoints/gcc-\([0-9]\+\)-\([0-9]\+\)-g[0-9a-f]*$,r\2-\3,p;s,^\(tags/\)\?basepoints/gcc-\([0-9]\+\)$,r\2-0,p'`;
+   if test -n $r; then
+   o=`$GCC_GIT config --get gcc-config.upstream`;
+   rr=`echo $r | sed -n 
's,^r\([0-9]\+\)-[0-9]\+\(-g[0-9a-f]\+\)\?$,\1,p'`;
+   if $GCC_GIT rev-parse --verify --quiet 
${o:-origin}/releases/gcc-$rr >/dev/null; then
+   m=releases/gcc-$rr;
+   else
+   m=master;
+   fi;
+   if $GCC_GIT merge-base --is-ancestor HEAD ${o:-origin}/$m; then
+   revision=${r}-g${revision};
+   fi
+   fi
branch=`$GCC_GIT name-rev --name-only HEAD || :`
;;
 
@@ -414,6 +429,6 @@ rm -f LAST_UPDATED gcc/REVISION
 date
 echo "`TZ=UTC date` (revision $revision)"
 } > LAST_UPDATED
-echo "[$branch revision $revision]" > gcc/REVISION
+echo "[$branch $revision]" > gcc/REVISION
 
 touch_files_reexec


[PATCH 0/4] drop version checks for in-tree gas [PR91602]

2021-07-21 Thread Serge Belyshev
Special-casing checks for in-tree gas features is unnecessary since
r17 which made configure-gcc depend on all-gas, and thus making
alternate code path in gcc_GAS_CHECK_FEATURE for in-tree gas
redundant.

Along the way this fixes PR 91602, which is caused by incorrect guess
of leb128 support presense in RISC-V.

First patch removes alternate code path in gcc_GAS_CHECK_FEATURE and
related code, the rest are further cleanups.  Patches 2 and 3 in
series make no functional changes, thus configure is unchanged.

Bootstrapped/regtested on x86_64-pc-linux-gnu, riscv64-unknown-linux-gnu,
sparc-sun-solaris2.11 and powerpc-ibm-aix7.{1.5.0,2.4.0}, with and without
in-tree binutils (except on aix where combined tree does not appear to work
due to dynamic linker peculiarity).

OK for mainline ?

Serge Belyshev (4):
  configure: drop version checks for in-tree gas [PR91602]
  configure: remove version argument from gcc_GAS_CHECK_FEATURE
  configure: fixup formatting from previous change
  configure: remove gas versions from tls check

 gcc/acinclude.m4 |  82 +---
 gcc/configure| 472 ++-
 gcc/configure.ac | 335 -
 3 files changed, 188 insertions(+), 701 deletions(-)



[PATCH 1/4] configure: drop version checks for in-tree gas [PR91602]

2021-07-21 Thread Serge Belyshev
configure: drop version checks for in-tree gas [PR91602]

gcc/ChangeLog:

PR build/91602
* acinclude.m4 (_gcc_COMPUTE_GAS_VERSION, _gcc_GAS_VERSION_GTE_IFELSE)
(gcc_GAS_VERSION_GTE_IFELSE): Remove.
(gcc_GAS_CHECK_FEATURE): Do not handle in-tree case specially.
* configure.ac: Remove gcc_cv_gas_major_version, 
gcc_cv_gas_minor_version.
Remove remaining checks for in-tree assembler.
* configure: Regenerate.
---
 gcc/acinclude.m4 |  66 +---
 gcc/configure| 414 +++
 gcc/configure.ac |  26 +--
 3 files changed, 61 insertions(+), 445 deletions(-)

diff --git a/gcc/acinclude.m4 b/gcc/acinclude.m4
index f9f6a07b040..e038990cca6 100644
--- a/gcc/acinclude.m4
+++ b/gcc/acinclude.m4
@@ -442,63 +442,6 @@ AC_DEFINE_UNQUOTED(HAVE_INITFINI_ARRAY_SUPPORT,
   [Define 0/1 if .init_array/.fini_array sections are available and working.])
 ])
 
-dnl # _gcc_COMPUTE_GAS_VERSION
-dnl # Used by gcc_GAS_VERSION_GTE_IFELSE
-dnl #
-dnl # WARNING:
-dnl # gcc_cv_as_gas_srcdir must be defined before this.
-dnl # This gross requirement will go away eventually.
-AC_DEFUN([_gcc_COMPUTE_GAS_VERSION],
-[gcc_cv_as_bfd_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/bfd
-for f in $gcc_cv_as_bfd_srcdir/configure \
- $gcc_cv_as_gas_srcdir/configure \
- $gcc_cv_as_gas_srcdir/configure.ac \
- $gcc_cv_as_gas_srcdir/Makefile.in ; do
-  gcc_cv_gas_version=`sed -n -e 's/^[[ 
]]*VERSION=[[^0-9A-Za-z_]]*\([[0-9]]*\.[[0-9]]*.*\)/VERSION=\1/p' < $f`
-  if test x$gcc_cv_gas_version != x; then
-break
-  fi
-done
-case $gcc_cv_gas_version in
-  VERSION=[[0-9]]*) ;;
-  *) AC_MSG_ERROR([[cannot find version of in-tree assembler]]);;
-esac
-gcc_cv_gas_major_version=`expr "$gcc_cv_gas_version" : "VERSION=\([[0-9]]*\)"`
-gcc_cv_gas_minor_version=`expr "$gcc_cv_gas_version" : 
"VERSION=[[0-9]]*\.\([[0-9]]*\)"`
-gcc_cv_gas_patch_version=`expr "$gcc_cv_gas_version" : 
"VERSION=[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)"`
-case $gcc_cv_gas_patch_version in
-  "") gcc_cv_gas_patch_version="0" ;;
-esac
-gcc_cv_gas_vers=`expr \( \( $gcc_cv_gas_major_version \* 1000 \) \
-   + $gcc_cv_gas_minor_version \) \* 1000 \
-   + $gcc_cv_gas_patch_version`
-]) []dnl # _gcc_COMPUTE_GAS_VERSION
-
-dnl # gcc_GAS_VERSION_GTE_IFELSE([elf,] major, minor, patchlevel,
-dnl # [command_if_true = :], [command_if_false = :])
-dnl # Check to see if the version of GAS is greater than or
-dnl # equal to the specified version.
-dnl #
-dnl # The first ifelse() shortens the shell code if the patchlevel
-dnl # is unimportant (the usual case).  The others handle missing
-dnl # commands.  Note that the tests are structured so that the most
-dnl # common version number cases are tested first.
-AC_DEFUN([_gcc_GAS_VERSION_GTE_IFELSE],
-[ifelse([$1], elf,
- [if test $in_tree_gas_is_elf = yes \
-  &&],
- [if]) test $gcc_cv_gas_vers -ge `expr \( \( $2 \* 1000 \) + $3 \) \* 1000 + 
$4`
-  then dnl
-ifelse([$5],,:,[$5])[]dnl
-ifelse([$6],,,[
-  else $6])
-fi])
-
-AC_DEFUN([gcc_GAS_VERSION_GTE_IFELSE],
-[AC_REQUIRE([_gcc_COMPUTE_GAS_VERSION])dnl
-ifelse([$1], elf, [_gcc_GAS_VERSION_GTE_IFELSE($@)],
-  [_gcc_GAS_VERSION_GTE_IFELSE(,$@)])])
-
 dnl # gcc_GAS_FLAGS
 dnl # Used by gcc_GAS_CHECK_FEATURE 
 dnl #
@@ -531,9 +474,7 @@ dnl gcc_GAS_CHECK_FEATURE(description, cv, 
[[elf,]major,minor,patchlevel],
 dnl [extra switches to as], [assembler input],
 dnl [extra testing logic], [command if feature available])
 dnl
-dnl Checks for an assembler feature.  If we are building an in-tree
-dnl gas, the feature is available if the associated assembler version
-dnl is greater than or equal to major.minor.patchlevel.  If not, then
+dnl Checks for an assembler feature.
 dnl ASSEMBLER INPUT is fed to the assembler and the feature is available
 dnl if assembly succeeds.  If EXTRA TESTING LOGIC is not the empty string,
 dnl then it is run instead of simply setting CV to "yes" - it is responsible
@@ -542,10 +483,7 @@ AC_DEFUN([gcc_GAS_CHECK_FEATURE],
 [AC_REQUIRE([gcc_GAS_FLAGS])dnl
 AC_CACHE_CHECK([assembler for $1], [$2],
  [[$2]=no
-  ifelse([$3],,,[dnl
-  if test $in_tree_gas = yes; then
-gcc_GAS_VERSION_GTE_IFELSE($3, [[$2]=yes])
-  el])if test x$gcc_cv_as != x; then
+  if test x$gcc_cv_as != x; then
 AS_ECHO([ifelse(m4_substr([$5],0,1),[$], "[$5]", '[$5]')]) > conftest.s
 if AC_TRY_COMMAND([$gcc_cv_as $gcc_cv_as_flags $4 -o conftest.o conftest.s 
>&AS_MESSAGE_LOG_FD])
 then
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 26da07325e7..c6e0bfdde90 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -2556,8 +2556,6 @@ AC_SUBST(enable_fast_install)
 # If build != host, and we aren't building gas in-tree, we identify a
 # build->target assembler and hope that it will have the same features
 # as the host->target assembler we'll be using.
-gcc_cv_gas_major_version=
-gcc_cv_gas_minor_version=

[PATCH 2/4] configure: remove version argument from gcc_GAS_CHECK_FEATURE

2021-07-21 Thread Serge Belyshev
configure: remove version argument from gcc_GAS_CHECK_FEATURE

gcc/ChangeLog:

* acinclude.m4 (gcc_GAS_CHECK_FEATURE): Remove third argument and ...
* configure.ac: ... update all callers.
---
 gcc/acinclude.m4 |  16 ++--
 gcc/configure.ac | 224 +++
 2 files changed, 120 insertions(+), 120 deletions(-)

diff --git a/gcc/acinclude.m4 b/gcc/acinclude.m4
index e038990cca6..082fa16ecb5 100644
--- a/gcc/acinclude.m4
+++ b/gcc/acinclude.m4
@@ -470,7 +470,7 @@ AC_DEFUN([gcc_GAS_FLAGS],
   esac])
 ])
 
-dnl gcc_GAS_CHECK_FEATURE(description, cv, [[elf,]major,minor,patchlevel],
+dnl gcc_GAS_CHECK_FEATURE(description, cv,
 dnl [extra switches to as], [assembler input],
 dnl [extra testing logic], [command if feature available])
 dnl
@@ -484,23 +484,23 @@ AC_DEFUN([gcc_GAS_CHECK_FEATURE],
 AC_CACHE_CHECK([assembler for $1], [$2],
  [[$2]=no
   if test x$gcc_cv_as != x; then
-AS_ECHO([ifelse(m4_substr([$5],0,1),[$], "[$5]", '[$5]')]) > conftest.s
-if AC_TRY_COMMAND([$gcc_cv_as $gcc_cv_as_flags $4 -o conftest.o conftest.s 
>&AS_MESSAGE_LOG_FD])
+AS_ECHO([ifelse(m4_substr([$4],0,1),[$], "[$4]", '[$4]')]) > conftest.s
+if AC_TRY_COMMAND([$gcc_cv_as $gcc_cv_as_flags $3 -o conftest.o conftest.s 
>&AS_MESSAGE_LOG_FD])
 then
-   ifelse([$6],, [$2]=yes, [$6])
+   ifelse([$5],, [$2]=yes, [$5])
 else
   echo "configure: failed program was" >&AS_MESSAGE_LOG_FD
   cat conftest.s >&AS_MESSAGE_LOG_FD
 fi
 rm -f conftest.o conftest.s
   fi])
-ifelse([$7],,,[dnl
+ifelse([$6],,,[dnl
 if test $[$2] = yes; then
-  $7
+  $6
 fi])
-ifelse([$8],,,[dnl
+ifelse([$7],,,[dnl
 if test $[$2] != yes; then
-  $8
+  $7
 fi])])
 
 dnl GCC_TARGET_TEMPLATE(KEY)
diff --git a/gcc/configure.ac b/gcc/configure.ac
index c6e0bfdde90..3846794b949 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -2884,27 +2884,27 @@ esac
 
 # Figure out what assembler alignment features are present.
 gcc_GAS_CHECK_FEATURE([.balign and .p2align], gcc_cv_as_balign_and_p2align,
- [2,6,0],,
+ ,
 [.balign 4
 .p2align 2],,
 [AC_DEFINE(HAVE_GAS_BALIGN_AND_P2ALIGN, 1,
   [Define if your assembler supports .balign and .p2align.])])
 
 gcc_GAS_CHECK_FEATURE([.p2align with maximum skip], gcc_cv_as_max_skip_p2align,
- [2,8,0],,
+ ,
  [.p2align 4,,7],,
 [AC_DEFINE(HAVE_GAS_MAX_SKIP_P2ALIGN, 1,
   [Define if your assembler supports specifying the maximum number
of bytes to skip when using the GAS .p2align command.])])
 
 gcc_GAS_CHECK_FEATURE([.literal16], gcc_cv_as_literal16,
- [2,8,0],,
+ ,
  [.literal16],,
 [AC_DEFINE(HAVE_GAS_LITERAL16, 1,
   [Define if your assembler supports .literal16.])])
 
 gcc_GAS_CHECK_FEATURE([working .subsection -1], gcc_cv_as_subsection_m1,
- [elf,2,9,0],,
+ ,
  [conftest_label1: .word 0
 .subsection -1
 conftest_label2: .word 0
@@ -2923,17 +2923,17 @@ conftest_label2: .word 0
emitting at the beginning of your section.])])
 
 gcc_GAS_CHECK_FEATURE([.weak], gcc_cv_as_weak,
- [2,2,0],,
+ ,
  [ .weak foobar],,
 [AC_DEFINE(HAVE_GAS_WEAK, 1, [Define if your assembler supports .weak.])])
 
 gcc_GAS_CHECK_FEATURE([.weakref], gcc_cv_as_weakref,
- [2,17,0],,
+ ,
  [ .weakref foobar, barfnot],,
 [AC_DEFINE(HAVE_GAS_WEAKREF, 1, [Define if your assembler supports 
.weakref.])])
 
 gcc_GAS_CHECK_FEATURE([.nsubspa comdat], gcc_cv_as_nsubspa_comdat,
- [2,15,91],,
+ ,
  [ .SPACE $TEXT$
.NSUBSPA $CODE$,COMDAT],,
 [AC_DEFINE(HAVE_GAS_NSUBSPA_COMDAT, 1, [Define if your assembler supports 
.nsubspa comdat option.])])
@@ -2955,7 +2955,7 @@ foobar:'
 ;;
 esac
 gcc_GAS_CHECK_FEATURE([.hidden], gcc_cv_as_hidden,
- [elf,2,13,0],, [$conftest_s])
+ , [$conftest_s])
 case "${target}" in
   *-*-darwin*)
 # Darwin as has some visibility support, though with a different syntax.
@@ -3174,7 +3174,7 @@ gcc_AC_INITFINI_ARRAY
 # Older versions of GAS and some non-GNU assemblers, have a bugs handling
 # these directives, even when they appear to accept them.
 gcc_GAS_CHECK_FEATURE([.sleb128 and .uleb128], gcc_cv_as_leb128,
- [elf,2,11,0],,
+ ,
 [  .data
.uleb128 L2 - L1
 L1:
@@ -3213,7 +3213,7 @@ gcc_fn_eh_frame_ro () {
 
 # Check if we have assembler support for unwind directives.
 gcc_GAS_CHECK_FEATURE([cfi directives], gcc_cv_as_cfi_directive,
-  ,,
+  ,
 [  .text
.cfi_startproc
.cfi_offset 0, 0
@@ -3269,7 +3269,7 @@ gcc_GAS_CHECK_FEATURE([cfi directives], 
gcc_cv_as_cfi_directive,
 esac])
 if test $gcc_cv_as_cfi_directive = yes && test x$gcc_cv_objdump != x; then
 gcc_GAS_CHECK_FEATURE([working cfi advance], gcc_cv_as_cfi_advance_working,
-  ,,
+  ,
 [  .text
.cfi_startproc
.cfi_adjust_cfa_offset 64
@@ -3294,7 +3294,7 @@ AC_DEFINE_UNQUOTED(HAVE_GAS_CFI_DIRECTIVE,
 
 GCC_TARGET_TEMPLATE(HAVE_GAS_CFI_PERSONALITY_DIRECTIVE)
 gcc_GAS_CHECK_FEATURE([cfi personality directive],
-  gcc_cv_as_cfi_personality_directive, ,,
+  gcc_cv_as_cfi_personality_directive,,
 [  .text
.cfi_startproc
 

[PATCH 3/4] configure: fixup formatting from previous change

2021-07-21 Thread Serge Belyshev
configure: fixup formatting from previous change

gcc/ChangeLog:

* configure.ac: Fixup formatting.
---
 gcc/configure.ac | 71 ++--
 1 file changed, 27 insertions(+), 44 deletions(-)

diff --git a/gcc/configure.ac b/gcc/configure.ac
index 3846794b949..6b452904ce7 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -2883,28 +2883,24 @@ case "$ORIGINAL_DSYMUTIL_FOR_TARGET" in
 esac 
 
 # Figure out what assembler alignment features are present.
-gcc_GAS_CHECK_FEATURE([.balign and .p2align], gcc_cv_as_balign_and_p2align,
- ,
+gcc_GAS_CHECK_FEATURE([.balign and .p2align], gcc_cv_as_balign_and_p2align,,
 [.balign 4
 .p2align 2],,
 [AC_DEFINE(HAVE_GAS_BALIGN_AND_P2ALIGN, 1,
   [Define if your assembler supports .balign and .p2align.])])
 
-gcc_GAS_CHECK_FEATURE([.p2align with maximum skip], gcc_cv_as_max_skip_p2align,
- ,
+gcc_GAS_CHECK_FEATURE([.p2align with maximum skip], 
gcc_cv_as_max_skip_p2align,,
  [.p2align 4,,7],,
 [AC_DEFINE(HAVE_GAS_MAX_SKIP_P2ALIGN, 1,
   [Define if your assembler supports specifying the maximum number
of bytes to skip when using the GAS .p2align command.])])
 
-gcc_GAS_CHECK_FEATURE([.literal16], gcc_cv_as_literal16,
- ,
+gcc_GAS_CHECK_FEATURE([.literal16], gcc_cv_as_literal16,,
  [.literal16],,
 [AC_DEFINE(HAVE_GAS_LITERAL16, 1,
   [Define if your assembler supports .literal16.])])
 
-gcc_GAS_CHECK_FEATURE([working .subsection -1], gcc_cv_as_subsection_m1,
- ,
+gcc_GAS_CHECK_FEATURE([working .subsection -1], gcc_cv_as_subsection_m1,,
  [conftest_label1: .word 0
 .subsection -1
 conftest_label2: .word 0
@@ -2922,18 +2918,15 @@ conftest_label2: .word 0
   [Define if your assembler supports .subsection and .subsection -1 starts
emitting at the beginning of your section.])])
 
-gcc_GAS_CHECK_FEATURE([.weak], gcc_cv_as_weak,
- ,
+gcc_GAS_CHECK_FEATURE([.weak], gcc_cv_as_weak,,
  [ .weak foobar],,
 [AC_DEFINE(HAVE_GAS_WEAK, 1, [Define if your assembler supports .weak.])])
 
-gcc_GAS_CHECK_FEATURE([.weakref], gcc_cv_as_weakref,
- ,
+gcc_GAS_CHECK_FEATURE([.weakref], gcc_cv_as_weakref,,
  [ .weakref foobar, barfnot],,
 [AC_DEFINE(HAVE_GAS_WEAKREF, 1, [Define if your assembler supports 
.weakref.])])
 
-gcc_GAS_CHECK_FEATURE([.nsubspa comdat], gcc_cv_as_nsubspa_comdat,
- ,
+gcc_GAS_CHECK_FEATURE([.nsubspa comdat], gcc_cv_as_nsubspa_comdat,,
  [ .SPACE $TEXT$
.NSUBSPA $CODE$,COMDAT],,
 [AC_DEFINE(HAVE_GAS_NSUBSPA_COMDAT, 1, [Define if your assembler supports 
.nsubspa comdat option.])])
@@ -2954,8 +2947,7 @@ case "${target}" in
 foobar:'
 ;;
 esac
-gcc_GAS_CHECK_FEATURE([.hidden], gcc_cv_as_hidden,
- , [$conftest_s])
+gcc_GAS_CHECK_FEATURE([.hidden], gcc_cv_as_hidden,, [$conftest_s])
 case "${target}" in
   *-*-darwin*)
 # Darwin as has some visibility support, though with a different syntax.
@@ -3173,8 +3165,7 @@ gcc_AC_INITFINI_ARRAY
 # Check if we have .[us]leb128, and support symbol arithmetic with it.
 # Older versions of GAS and some non-GNU assemblers, have a bugs handling
 # these directives, even when they appear to accept them.
-gcc_GAS_CHECK_FEATURE([.sleb128 and .uleb128], gcc_cv_as_leb128,
- ,
+gcc_GAS_CHECK_FEATURE([.sleb128 and .uleb128], gcc_cv_as_leb128,,
 [  .data
.uleb128 L2 - L1
 L1:
@@ -3212,8 +3203,7 @@ gcc_fn_eh_frame_ro () {
 }
 
 # Check if we have assembler support for unwind directives.
-gcc_GAS_CHECK_FEATURE([cfi directives], gcc_cv_as_cfi_directive,
-  ,
+gcc_GAS_CHECK_FEATURE([cfi directives], gcc_cv_as_cfi_directive,,
 [  .text
.cfi_startproc
.cfi_offset 0, 0
@@ -3268,8 +3258,7 @@ gcc_GAS_CHECK_FEATURE([cfi directives], 
gcc_cv_as_cfi_directive,
 ;;
 esac])
 if test $gcc_cv_as_cfi_directive = yes && test x$gcc_cv_objdump != x; then
-gcc_GAS_CHECK_FEATURE([working cfi advance], gcc_cv_as_cfi_advance_working,
-  ,
+gcc_GAS_CHECK_FEATURE([working cfi advance], gcc_cv_as_cfi_advance_working,,
 [  .text
.cfi_startproc
.cfi_adjust_cfa_offset 64
@@ -3332,8 +3321,7 @@ AC_DEFINE_UNQUOTED(HAVE_GAS_CFI_SECTIONS_DIRECTIVE,
 
 # GAS versions up to and including 2.11.0 may mis-optimize
 # .eh_frame data.
-gcc_GAS_CHECK_FEATURE(eh_frame optimization, gcc_cv_as_eh_frame,
-  ,
+gcc_GAS_CHECK_FEATURE(eh_frame optimization, gcc_cv_as_eh_frame,,
 [  .text
 .LFB1:
.4byte  0
@@ -3636,8 +3624,7 @@ case "${target}" in
 esac
 
 gcc_GAS_CHECK_FEATURE([line table is_stmt support],
- gcc_cv_as_is_stmt,
- ,
+ gcc_cv_as_is_stmt,,
 [  .text
.file 1 "conf.c"
.loc 1 1 0 is_stmt 1],,
@@ -3645,8 +3632,7 @@ gcc_GAS_CHECK_FEATURE([line table is_stmt support],
   [Define if your assembler supports the .loc is_stmt sub-directive.])])
 
 gcc_GAS_CHECK_FEATURE([line table discriminator support],
- gcc_cv_as_discriminator,
- ,
+ gcc_cv_as_discriminator,,
 [  .text
.file 1 "conf.c"
.loc 1 1 0 discriminator 1],,
@@ -4741,16 +4727,15 @@ changequote([,])dnl
# Recent binutils allows the three-operand fo

[PATCH 4/4] configure: remove gas versions from tls check

2021-07-21 Thread Serge Belyshev
configure: remove gas versions from tls check

gcc/ChangeLog:

* configure.ac (thread-local storage support): Remove tls_first_major
and tls_first_minor.  Use "$conftest_s" to check support.
* configure: Regenerate.
---
 gcc/configure| 58 +---
 gcc/configure.ac | 58 +---
 2 files changed, 2 insertions(+), 114 deletions(-)

diff --git a/gcc/configure.ac b/gcc/configure.ac
index 6b452904ce7..02211b376bf 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -3653,8 +3653,6 @@ esac], [])
 
 # Thread-local storage - the check is heavily parameterized.
 conftest_s=
-tls_first_major=
-tls_first_minor=
 tls_as_opt=
 case "$target" in
 changequote(,)dnl
@@ -3677,15 +3675,11 @@ foo:.long   25
ldah$2,foo($29) !tprelhi
lda $3,foo($2)  !tprello
lda $4,foo($29) !tprel'
-   tls_first_major=2
-   tls_first_minor=13
tls_as_opt=--fatal-warnings
;;
   arc*-*-*)
 conftest_s='
add_s r0,r0, @foo@tpoff'
-   tls_first_major=2
-   tls_first_minor=23
;;
   cris-*-*|crisv32-*-*)
 conftest_s='
@@ -3694,8 +3688,6 @@ x:  .long   25
 .text
move.d x:IE,$r10
nop'
-   tls_first_major=2
-   tls_first_minor=20
tls_as_opt=--fatal-warnings
;;
   frv*-*-*)
@@ -3704,8 +3696,6 @@ x:  .long   25
 x:  .long   25
 .text
 call#gettlsoff(x)'
-   tls_first_major=2
-   tls_first_minor=14
;;
   hppa*-*-linux*)
 conftest_s='
@@ -3732,8 +3722,6 @@ foo:  .long   25
mfctl %cr27,%t1 
addil LR%foo-$tls_leoff$,%t1
ldo RR%foo-$tls_leoff$(%r1),%t2'
-   tls_first_major=2
-   tls_first_minor=15
tls_as_opt=--fatal-warnings
;;
   arm*-*-*)
@@ -3746,8 +3734,6 @@ foo:  .long   25
 .word foo(tlsgd)
 .word foo(tlsldm)
 .word foo(tlsldo)'
-   tls_first_major=2
-   tls_first_minor=17
;;
   i[34567]86-*-* | x86_64-*-*)
 case "$target" in
@@ -3761,8 +3747,6 @@ foo:  .long   25
 if test x$on_solaris = xyes && test x$gas_flag = xno; then
   conftest_s='
.section .tdata,"awt",@progbits'
-  tls_first_major=0
-  tls_first_minor=0
   tls_section_flag=t
 changequote([,])dnl
   AC_DEFINE(TLS_SECTION_ASM_FLAG, 't',
@@ -3771,8 +3755,6 @@ changequote(,)dnl
 else
   conftest_s='
.section ".tdata","awT",@progbits'
-  tls_first_major=2
-  tls_first_minor=14
   tls_section_flag=T
   tls_as_opt="--fatal-warnings"
 fi
@@ -3831,8 +3813,6 @@ foo:  data8   25
addlr20 = @tprel(foo#), gp
addsr22 = @tprel(foo#), r13
movlr24 = @tprel(foo#)'
-   tls_first_major=2
-   tls_first_minor=13
tls_as_opt=--fatal-warnings
;;
   microblaze*-*-*)
@@ -3843,8 +3823,6 @@ x:
.text
addik r5,r20,x@TLSGD
addik r5,r20,x@TLSLDM'
-   tls_first_major=2
-   tls_first_minor=20
tls_as_opt='--fatal-warnings'
;;
   mips*-*-*)
@@ -3860,8 +3838,6 @@ x:
lw $4, %gottprel(x)($28)
lui $4, %tprel_hi(x)
addiu $4, $4, %tprel_lo(x)'
-   tls_first_major=2
-   tls_first_minor=16
tls_as_opt='-32 --fatal-warnings'
;;
   m68k-*-*)
@@ -3876,15 +3852,11 @@ foo:
move.l x@TLSLDO(%a5),%a0
move.l x@TLSIE(%a5),%a0
move.l x@TLSLE(%a5),%a0'
-   tls_first_major=2
-   tls_first_minor=19
tls_as_opt='--fatal-warnings'
;;
   nios2-*-*)
   conftest_s='
.section ".tdata","awT",@progbits'
-   tls_first_major=2
-   tls_first_minor=23
tls_as_opt="--fatal-warnings"
;;
   aarch64*-*-*)
@@ -3896,8 +3868,6 @@ foo:  .long   25
add   x0, x0, #:tlsgd_lo12:x
 bl__tls_get_addr
nop'
-   tls_first_major=2
-   tls_first_minor=20
tls_as_opt='--fatal-warnings'
;;
   or1k*-*-*)
@@ -3908,8 +3878,6 @@ foo:  .long   25
l.movhi r3, tpoffha(foo)
l.add   r3, r3, r10
l.lwz   r4, tpofflo(foo)(r3)'
-tls_first_major=2
-tls_first_minor=30
 tls_as_opt=--fatal-warnings
 ;;
   powerpc-ibm-aix*)
@@ -3927,8 +3895,6 @@ LC..1:
.csect a[TL],4
 a:
.space 4'
-   tls_first_major=0
-   tls_first_minor=0
;;
   powerpc64*-*-*)
 conftest_s='
@@ -3960,8 +3926,6 @@ x3:   .space 8
add 9,9,3
bl .__tls_get_addr
nop'
-   tls_first_major=2
-   tls_first_minor=14
tls_as_opt="-a64 --fatal-warnings"
;;
   powerpc*-*-*)
@@ -3986,8 +3950,6 @@ x3:   .space 4
addi 9,2,x1@tprel
addis 9,2,x2@tprel@ha
addi 9,9,x2@tprel@l'
-   tls_first_major=2
-   tls_first_minor=14
tls_as_opt="-a32 --fatal-warnings"
;;
   riscv*-

PING^2: [PATCH] Add --enable-first-stage-cross configure option

2022-01-09 Thread Serge Belyshev
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 9c2d7df1bb2..44f6ebcb947 100755
--- a/configure
+++ b/configure
@@ -794,6 +794,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
@@ -1522,6 +1523,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
@@ -2971,6 +2975,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 68cc5cc31fe..84ae8210a72 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-h

Re: PING^2: [PATCH] Add --enable-first-stage-cross configure option

2022-07-13 Thread Serge Belyshev via Gcc-patches
Jeff Law via Gcc-patches  writes:

> I'm not really sure we need a patch for this.  Isn't it sufficient to
> "make all-gcc && make all-target-libgcc"?  Folks have been doing that
> for decades.
>
> Jeff

Oh, I did not know that "make install-gcc install-target-libgcc" works in this 
case.

So in the end, patch simplifies quirky first stage cross tool build procedure 
from

  configure --target=$target  --enable-languages=c --disable-threads 
--disable-shared # plus --with-newlib when --with-sysroot=
  make all-gcc all-target-libgcc
  make install-gcc install-target-libgcc

to

  configure --target=$target --enable-first-stage-cross
  make
  make install

Either way is more or less okay for me, it just needs to be documented.


Re: [PATCH 0/4] drop version checks for in-tree gas [PR91602]

2021-08-08 Thread Serge Belyshev via Gcc-patches
Jeff Law  writes:

> On 7/20/2021 9:44 AM, Serge Belyshev wrote:
>> Special-casing checks for in-tree gas features is unnecessary since
>> r17 which made configure-gcc depend on all-gas, and thus making
>> alternate code path in gcc_GAS_CHECK_FEATURE for in-tree gas
>> redundant.
>>
>> Along the way this fixes PR 91602, which is caused by incorrect guess
>> of leb128 support presense in RISC-V.
>>
>> First patch removes alternate code path in gcc_GAS_CHECK_FEATURE and
>> related code, the rest are further cleanups.  Patches 2 and 3 in
>> series make no functional changes, thus configure is unchanged.
>>
>> Bootstrapped/regtested on x86_64-pc-linux-gnu, riscv64-unknown-linux-gnu,
>> sparc-sun-solaris2.11 and powerpc-ibm-aix7.{1.5.0,2.4.0}, with and without
>> in-tree binutils (except on aix where combined tree does not appear to work
>> due to dynamic linker peculiarity).
>>
>> OK for mainline ?
>>
>> Serge Belyshev (4):
>>configure: drop version checks for in-tree gas [PR91602]
>>configure: remove version argument from gcc_GAS_CHECK_FEATURE
>>configure: fixup formatting from previous change
>>configure: remove gas versions from tls check
> So just be clear, the point here is to stop checking the version # and
> instead always do a real feature check by testing the behavior of the
> assembler, even an in-tree assembler, right?

That is correct, yes.


Re: [PATCH 0/4] drop version checks for in-tree gas [PR91602]

2021-08-20 Thread Serge Belyshev via Gcc-patches
Jeff Law  writes:

> This set is approved.    Push them to the trunk when it's convenient
> for you.
>
> Thanks for your patience,

Thanks! Committed as r12-3047 .. r12-3050.


Re: [PATCH v3] gcc_update: use human readable name for revision string in gcc/REVISION

2021-09-06 Thread Serge Belyshev via Gcc-patches
Ping?

[PATCH v3] gcc_update: use human readable name for revision string in 
gcc/REVISION
https://gcc.gnu.org/pipermail/gcc-patches/2021-July/575556.html

>
> OK for mainline?
>
> ---
> contrib/Changelog:
>
>   * gcc_update: derive human readable name for HEAD using git describe
>   like "git gcc-descr" with short commit hash.  Drop "revision" from 
> gcc/REVISION.
> ---
>  contrib/gcc_update | 19 +--
>  1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/contrib/gcc_update b/contrib/gcc_update
> index 80fac9fc995..ce472545e25 100755
> --- a/contrib/gcc_update
> +++ b/contrib/gcc_update
> @@ -332,7 +332,22 @@ case $vcs_type in
>  exit 1
>   fi
>  
> - revision=`$GCC_GIT log -n1 --pretty=tformat:%p:%t:%H`
> + # Open-coded version of "git gcc-descr" from 
> contrib/gcc-git-customization.sh
> + revision=`$GCC_GIT log -n1 --pretty=tformat:%h`
> + r=`$GCC_GIT describe --all --match 'basepoints/gcc-[0-9]*' HEAD \
> +| sed -n 
> 's,^\(tags/\)\?basepoints/gcc-\([0-9]\+\)-\([0-9]\+\)-g[0-9a-f]*$,r\2-\3,p;s,^\(tags/\)\?basepoints/gcc-\([0-9]\+\)$,r\2-0,p'`;
> + if test -n $r; then
> + o=`$GCC_GIT config --get gcc-config.upstream`;
> + rr=`echo $r | sed -n 
> 's,^r\([0-9]\+\)-[0-9]\+\(-g[0-9a-f]\+\)\?$,\1,p'`;
> + if $GCC_GIT rev-parse --verify --quiet 
> ${o:-origin}/releases/gcc-$rr >/dev/null; then
> + m=releases/gcc-$rr;
> + else
> + m=master;
> + fi;
> + if $GCC_GIT merge-base --is-ancestor HEAD ${o:-origin}/$m; then
> + revision=${r}-g${revision};
> + fi
> + fi
>   branch=`$GCC_GIT name-rev --name-only HEAD || :`
>   ;;
>  
> @@ -414,6 +429,6 @@ rm -f LAST_UPDATED gcc/REVISION
>  date
>  echo "`TZ=UTC date` (revision $revision)"
>  } > LAST_UPDATED
> -echo "[$branch revision $revision]" > gcc/REVISION
> +echo "[$branch $revision]" > gcc/REVISION
>  
>  touch_files_reexec


[COMMITTED] MAINTAINERS: Add myself for write after approval

2021-05-17 Thread Serge Belyshev via Gcc-patches
2021-05-17  Serge Belyshev  

* MAINTAINERS (Write After Approval): Add myself.

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 5b10f212ce8..fbaa183cea4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -317,6 +317,7 @@ Gergö Barany

 Charles Baylis 
 Tejas Belagod  
 Matthew Beliveau   
+Serge Belyshev 
 Jon Beniston   
 Andrew Bennett 
 Andrew Benson  


PING^3: [PATCH] Add --enable-first-stage-cross configure option

2022-01-16 Thread Serge Belyshev via Gcc-patches
Final ping before stage3 ends:

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