https://gcc.gnu.org/g:d8621cbce4de5b01eaedab7fc9280d2214dbb620
commit r17-2037-gd8621cbce4de5b01eaedab7fc9280d2214dbb620 Author: Rainer Orth <[email protected]> Date: Wed Jul 1 10:24:10 2026 +0200 build: Introduce {as,ld}_flavor When working to handle more vendor assemblers and linkers for the patch series described in [PATCH 0/6] Remove HAVE_GNU_{AS,LD} etc. https://gcc.gnu.org/pipermail/gcc-patches/2026-April/715161.html it turned out that the original plan to follow what I'd done for Solaris so far with the solaris_{as,ld} variables leads to code that is hard to understand. Therefore this patch uses a different approach: it introduces two new variables, as_flavor, and ld_flavor. They both default to gnu, i.e. the GNU Binutils toolchain or compatible assemblers and linkers. To deal with incompatible vendor toolchains, those variables can take other values. In addition to solaris, there are aix, darwin, hpux, and nvptx. More could be added as necessary. In preparation for the patch series above, this patch switches existing code from solaris_{as,ld} to {as,ld}_flavor=solaris. It also checks the configured assembler and linker for the vendor toolchains above. If there's a choice between native and GNU toolchains (AIX, HP-UX, Solaris), the as and ld version outputs are examined. Otherwise (Darwin, NVPTX), the values are hardcoded and only used in configure messages. In addition to {as,ld}_flavor, HAVE_<FLAVOR>_{AS,LD} macros are defined in cases they are actually needed, matching existing HAVE_SOLARIS_{AS,LD}. Tested together with a reworked version of the patch series above on x86_64-pc-linux-gnu, powerpc-ibm-aix7.3.1.0 (as/ld and gas/gld), x86_64-apple-darwin17.7.0, i386-pc-solaris2.11 and sparc-sun-solaris2.11 (as/ld, gas/ld, and gas/gld). Also tested by Dave on HP-UX. 2026-05-03 Rainer Orth <[email protected]> gcc: * acinclude.m4: Check as_flavor, ld_flavor instead of solaris_as, solaris_ld. * configure.ac: Likewise. (as_flavor, ld_flavor): New variables. Adapt messages. Set based on as, ld version output. (HAVE_AIX_AS): Define. * configure: Regenerate. * config.in: Regenerate. Diff: --- gcc/acinclude.m4 | 6 +-- gcc/config.in | 6 +++ gcc/configure | 112 ++++++++++++++++++++++++++++++++++++++++--------------- gcc/configure.ac | 97 +++++++++++++++++++++++++++++++++++------------ 4 files changed, 163 insertions(+), 58 deletions(-) diff --git a/gcc/acinclude.m4 b/gcc/acinclude.m4 index a4f9c96a245d..e9427f37c66c 100644 --- a/gcc/acinclude.m4 +++ b/gcc/acinclude.m4 @@ -308,8 +308,8 @@ int (*fp) (void) __attribute__ ((section (".init_array"))) = foo; gcc_cv_initfini_array=yes fi elif test x"$gcc_cv_as" != x -a x"$gcc_cv_ld" != x -a x"$gcc_cv_objdump" != x ; then - case $target:$solaris_as in - i?86-*-solaris2*:yes | x86_64-*-solaris2*:yes) + case $target:$as_flavor in + i?86-*-solaris2*:solaris | x86_64-*-solaris2*:solaris) sh_flags='"a"' sh_type='@progbits' ;; @@ -323,7 +323,7 @@ int (*fp) (void) __attribute__ ((section (".init_array"))) = foo; sh_type='%progbits' ;; esac - if test x$solaris_ld = xno; then + if test x$ld_flavor = xgnu; then cat > conftest.s <<EOF .section .dtors,$sh_flags,$sh_type .balign 4 diff --git a/gcc/config.in b/gcc/config.in index b1f2bacf9a81..7a58d51d1b61 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -373,6 +373,12 @@ #endif +/* Define to 1 if using the AIX assembler. */ +#ifndef USED_FOR_TARGET +#undef HAVE_AIX_AS +#endif + + /* Define if your assembler supports LSX and SCQ for 16B atomic. */ #ifndef USED_FOR_TARGET #undef HAVE_AS_16B_ATOMIC diff --git a/gcc/configure b/gcc/configure index a6e7f86ad0ca..59b8193a892e 100755 --- a/gcc/configure +++ b/gcc/configure @@ -25495,24 +25495,52 @@ fi fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Solaris assembler" >&5 -$as_echo_n "checking Solaris assembler... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler flavor" >&5 +$as_echo_n "checking assembler flavor... " >&6; } +as_flavor=gnu case $target in + *-*-aix*) + if $gcc_cv_as -v 2>&1 | grep '^as V' > /dev/null; then + as_flavor=aix + gas=no + else + gas=yes + fi + ;; + *-*-darwin*) + as_flavor=darwin + gas=no + ;; *-*-solaris2*) if $gcc_cv_as -V 2>&1 | grep 'Compiler Common.*SunOS' > /dev/null; then - solaris_as=yes + as_flavor=solaris + gas=no + else + gas=yes + fi + ;; + hppa*64*-*-hpux11*) + if $gcc_cv_as -V 2>&1 | grep 'UX.11.*PA-RISC.*Assembler' > /dev/null; then + as_flavor=hpux gas=no - elif $gcc_cv_as --version 2>/dev/null | grep GNU > /dev/null; then + else gas=yes fi ;; - *) - solaris_as=no + nvptx-*-*) + as_flavor=nvptx + gas=no ;; esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $solaris_as" >&5 -$as_echo "$solaris_as" >&6; } -solaris_as_bool=`if test $solaris_as = yes; then echo 1; else echo 0; fi` +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $as_flavor" >&5 +$as_echo "$as_flavor" >&6; } +aix_as_bool=`if test $as_flavor = aix; then echo 1; else echo 0; fi` + +cat >>confdefs.h <<_ACEOF +#define HAVE_AIX_AS $aix_as_bool +_ACEOF + +solaris_as_bool=`if test $as_flavor = solaris; then echo 1; else echo 0; fi` cat >>confdefs.h <<_ACEOF #define HAVE_SOLARIS_AS $solaris_as_bool @@ -25649,24 +25677,46 @@ fi fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Solaris linker" >&5 -$as_echo_n "checking Solaris linker... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking linker flavor" >&5 +$as_echo_n "checking linker flavor... " >&6; } +ld_flavor=gnu case $target in + *-*-aix*) + if $gcc_cv_ld -V 2>&1 | grep 'ld: LD ' > /dev/null; then + ld_flavor=aix + gnu_ld=no + else + gnu_ld=yes + fi + ;; + *-*-darwin*) + ld_flavor=darwin + gnu_ld=no + ;; *-*-solaris2*) - if $gcc_cv_ld -V 2>/dev/null | grep 'Solaris Link Editors' > /dev/null; then + if $gcc_cv_ld -V 2>&1 | grep 'Solaris Link Editors' > /dev/null; then + ld_flavor=solaris gnu_ld=no - solaris_ld=yes - elif $gcc_cv_ld --version 2>/dev/null | grep GNU > /dev/null; then + else gnu_ld=yes fi ;; - *) - solaris_ld=no + hppa*64*-*-hpux11*) + if $gcc_cv_ld -V 2>&1 | grep 'linker command.*sgs.*ld PA64' > /dev/null; then + ld_flavor=hpux + gnu_ld=no + else + gnu_ld=yes + fi + ;; + nvptx-*-*) + ld_flavor=nvptx + gnu_ld=no ;; esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $solaris_ld" >&5 -$as_echo "$solaris_ld" >&6; } -solaris_ld_bool=`if test $solaris_ld = yes; then echo 1; else echo 0; fi` +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_flavor" >&5 +$as_echo "$ld_flavor" >&6; } +solaris_ld_bool=`if test $ld_flavor = solaris; then echo 1; else echo 0; fi` cat >>confdefs.h <<_ACEOF #define HAVE_SOLARIS_LD $solaris_ld_bool @@ -25706,16 +25756,16 @@ if test -z "$gnu_ld"; then fi fi -case "$target:$gnu_ld" in - *-*-solaris2*:no) +case "$target:$ld_flavor" in + *-*-solaris2*:solaris) # While Solaris ld has -m32/-m64 it usually determines the ELF class # from the input objects. ;; - i?86-*-solaris2*:yes | x86_64-*-solaris2*:yes) + i?86-*-solaris2*:gnu | x86_64-*-solaris2*:gnu) ld_32_opt=-melf_i386_sol2 ld_64_opt=-melf_x86_64_sol2 ;; - i?86-*-*:yes | x86_64-*-*:yes) + i?86-*-*:gnu | x86_64-*-*:gnu) ld_32_opt=-melf_i386 ld_64_opt=-melf_x86_64 ;; @@ -26914,8 +26964,8 @@ fi gcc_cv_initfini_array=yes fi elif test x"$gcc_cv_as" != x -a x"$gcc_cv_ld" != x -a x"$gcc_cv_objdump" != x ; then - case $target:$solaris_as in - i?86-*-solaris2*:yes | x86_64-*-solaris2*:yes) + case $target:$as_flavor in + i?86-*-solaris2*:solaris | x86_64-*-solaris2*:solaris) sh_flags='"a"' sh_type='@progbits' ;; @@ -26929,7 +26979,7 @@ fi sh_type='%progbits' ;; esac - if test x$solaris_ld = xno; then + if test x$ld_flavor = xgnu; then cat > conftest.s <<EOF .section .dtors,$sh_flags,$sh_type .balign 4 @@ -28097,7 +28147,7 @@ foo: .long 25 .word foo(tlsldo)' ;; i?86-*-* | x86_64-*-*) - if test x$solaris_as = xyes; then + if test x$as_flavor = xsolaris; then tls_section_flag=t $as_echo "#define TLS_SECTION_ASM_FLAG 't'" >>confdefs.h @@ -28345,7 +28395,7 @@ foo: .long 25 .long foo@TPOFF' ;; sparc*-*-*) - if test x$solaris_as = xyes; then + if test x$as_flavor = xsolaris; then conftest_s=' .section ".tdata",#alloc,#write,#tls' else @@ -28522,7 +28572,7 @@ ld_version_script_option='' if test $in_tree_ld = yes || test x"$gnu_ld" = xyes; then gcc_cv_ld_version_script=yes ld_version_script_option='--version-script' -elif test x$solaris_ld = xyes; then +elif test x$ld_flavor = xsolaris; then # Solaris 2 ld always supports -M. It also supports a subset of # --version-script since Solaris 11.4, but requires # -z gnu-version-script-compat to activate. @@ -32905,7 +32955,7 @@ gcc_cv_ld_ctf=no # Check for Solaris ld 1.3315 introduced in Solaris 11.4 SRU 84. ld -z ctf # already went in in SRU 81, but lacked GNU CTF to Solaris CTF conversion. if $gcc_cv_ld --help 2>&1 | grep -- '-z ctf' > /dev/null \ - && test x$solaris_ld = xyes && test "$ld_vers_minor" -ge 3315; then + && test x$ld_flavor = xsolaris && test "$ld_vers_minor" -ge 3315; then gcc_cv_ld_ctf=yes $as_echo "#define HAVE_LD_CTF 1" >>confdefs.h @@ -33188,7 +33238,7 @@ elif test x$gcc_cv_ld != x; then gcc_cv_ld_no_as_needed_option='--pop-state' fi fi - if test x$solaris_ld = xyes; then + if test x$ld_flavor = xsolaris; then # Solaris 2 ld always supports -z ignore/-z record. Prefer the native # forms. gcc_cv_ld_as_needed=yes diff --git a/gcc/configure.ac b/gcc/configure.ac index 6129a06dccc2..8766ee0c8a00 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -2738,22 +2738,48 @@ else AC_PATH_PROG(gcc_cv_as, $AS_FOR_TARGET) fi]) -AC_MSG_CHECKING(Solaris assembler) +AC_MSG_CHECKING(assembler flavor) +as_flavor=gnu case $target in + *-*-aix*) + if $gcc_cv_as -v 2>&1 | grep '^as V' > /dev/null; then + as_flavor=aix + gas=no + else + gas=yes + fi + ;; + *-*-darwin*) + as_flavor=darwin + gas=no + ;; *-*-solaris2*) if $gcc_cv_as -V 2>&1 | grep 'Compiler Common.*SunOS' > /dev/null; then - solaris_as=yes + as_flavor=solaris gas=no - elif $gcc_cv_as --version 2>/dev/null | grep GNU > /dev/null; then + else gas=yes fi ;; - *) - solaris_as=no + hppa*64*-*-hpux11*) + if $gcc_cv_as -V 2>&1 | grep 'UX.11.*PA-RISC.*Assembler' > /dev/null; then + as_flavor=hpux + gas=no + else + gas=yes + fi + ;; + nvptx-*-*) + as_flavor=nvptx + gas=no ;; esac -AC_MSG_RESULT($solaris_as) -solaris_as_bool=`if test $solaris_as = yes; then echo 1; else echo 0; fi` +AC_MSG_RESULT($as_flavor) +dnl Don't define HAVE_GNU_AS, only HAVE_<FLAVOR>_AS when actually used. +aix_as_bool=`if test $as_flavor = aix; then echo 1; else echo 0; fi` +AC_DEFINE_UNQUOTED(HAVE_AIX_AS, $aix_as_bool, + [Define to 1 if using the AIX assembler.]) +solaris_as_bool=`if test $as_flavor = solaris; then echo 1; else echo 0; fi` AC_DEFINE_UNQUOTED(HAVE_SOLARIS_AS, $solaris_as_bool, [Define to 1 if using the Solaris assembler.]) @@ -2839,22 +2865,45 @@ else AC_PATH_PROG(gcc_cv_ld, $LD_FOR_TARGET) fi]) -AC_MSG_CHECKING(Solaris linker) +AC_MSG_CHECKING(linker flavor) +ld_flavor=gnu case $target in + *-*-aix*) + if $gcc_cv_ld -V 2>&1 | grep 'ld: LD ' > /dev/null; then + ld_flavor=aix + gnu_ld=no + else + gnu_ld=yes + fi + ;; + *-*-darwin*) + ld_flavor=darwin + gnu_ld=no + ;; *-*-solaris2*) - if $gcc_cv_ld -V 2>/dev/null | grep 'Solaris Link Editors' > /dev/null; then + if $gcc_cv_ld -V 2>&1 | grep 'Solaris Link Editors' > /dev/null; then + ld_flavor=solaris gnu_ld=no - solaris_ld=yes - elif $gcc_cv_ld --version 2>/dev/null | grep GNU > /dev/null; then + else gnu_ld=yes fi ;; - *) - solaris_ld=no + hppa*64*-*-hpux11*) + if $gcc_cv_ld -V 2>&1 | grep 'linker command.*sgs.*ld PA64' > /dev/null; then + ld_flavor=hpux + gnu_ld=no + else + gnu_ld=yes + fi + ;; + nvptx-*-*) + ld_flavor=nvptx + gnu_ld=no ;; esac -AC_MSG_RESULT($solaris_ld) -solaris_ld_bool=`if test $solaris_ld = yes; then echo 1; else echo 0; fi` +AC_MSG_RESULT($ld_flavor) +dnl Don't define HAVE_GNU_LD, only HAVE_<FLAVOR>_LD when actually used. +solaris_ld_bool=`if test $ld_flavor = solaris; then echo 1; else echo 0; fi` AC_DEFINE_UNQUOTED(HAVE_SOLARIS_LD, $solaris_ld_bool, [Define to 1 if using the Solaris linker.]) @@ -2884,16 +2933,16 @@ if test -z "$gnu_ld"; then fi fi -case "$target:$gnu_ld" in - *-*-solaris2*:no) +case "$target:$ld_flavor" in + *-*-solaris2*:solaris) # While Solaris ld has -m32/-m64 it usually determines the ELF class # from the input objects. ;; - i?86-*-solaris2*:yes | x86_64-*-solaris2*:yes) + i?86-*-solaris2*:gnu | x86_64-*-solaris2*:gnu) ld_32_opt=-melf_i386_sol2 ld_64_opt=-melf_x86_64_sol2 ;; - i?86-*-*:yes | x86_64-*-*:yes) + i?86-*-*:gnu | x86_64-*-*:gnu) ld_32_opt=-melf_i386 ld_64_opt=-melf_x86_64 ;; @@ -3993,7 +4042,7 @@ foo: .long 25 .word foo(tlsldo)' ;; i?86-*-* | x86_64-*-*) - if test x$solaris_as = xyes; then + if test x$as_flavor = xsolaris; then tls_section_flag=t changequote([,])dnl AC_DEFINE(TLS_SECTION_ASM_FLAG, 't', @@ -4242,7 +4291,7 @@ foo: .long 25 .long foo@TPOFF' ;; sparc*-*-*) - if test x$solaris_as = xyes; then + if test x$as_flavor = xsolaris; then conftest_s=' .section ".tdata",#alloc,#write,#tls' else @@ -4383,7 +4432,7 @@ ld_version_script_option='' if test $in_tree_ld = yes || test x"$gnu_ld" = xyes; then gcc_cv_ld_version_script=yes ld_version_script_option='--version-script' -elif test x$solaris_ld = xyes; then +elif test x$ld_flavor = xsolaris; then # Solaris 2 ld always supports -M. It also supports a subset of # --version-script since Solaris 11.4, but requires # -z gnu-version-script-compat to activate. @@ -6321,7 +6370,7 @@ gcc_cv_ld_ctf=no # Check for Solaris ld 1.3315 introduced in Solaris 11.4 SRU 84. ld -z ctf # already went in in SRU 81, but lacked GNU CTF to Solaris CTF conversion. if $gcc_cv_ld --help 2>&1 | grep -- '-z ctf' > /dev/null \ - && test x$solaris_ld = xyes && test "$ld_vers_minor" -ge 3315; then + && test x$ld_flavor = xsolaris && test "$ld_vers_minor" -ge 3315; then gcc_cv_ld_ctf=yes AC_DEFINE(HAVE_LD_CTF, 1, [Define if your linker supports -z ctf.]) fi @@ -6554,7 +6603,7 @@ elif test x$gcc_cv_ld != x; then gcc_cv_ld_no_as_needed_option='--pop-state' fi fi - if test x$solaris_ld = xyes; then + if test x$ld_flavor = xsolaris; then # Solaris 2 ld always supports -z ignore/-z record. Prefer the native # forms. gcc_cv_ld_as_needed=yes
