]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
build: Check solaris_{as,ld} where appropriate
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Fri, 1 May 2026 13:18:04 +0000 (15:18 +0200)
committerRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Fri, 1 May 2026 13:18:04 +0000 (15:18 +0200)
Several of the gas and gnu_ld checks in gcc/configure actually need to
determine if Solaris as and ld are in use.  Since solaris_as and
solaris_ld are determined reliably now, it's clearer to check them
directly instead of !gas and !gnu_ld.

This patch does just that.  Since solaris_as/solaris_ld imply target
*-*-solaris2*, the tests can be simplified and sometimes converted from
case/esac to if/else.

Bootstrapped on amd64-pc-solaris2.11, sparcv9-sun-solaris2.11,
x86_64-pc-linux-gnu, amd64-pc-freebsd15.0, and
x86_64-apple-darwin21.6.0.

When there are different flavours of as and/or ld depending on PATH
(/usr/bin/as vs. /usr/gnu/bin/as resp. ld on Solaris, /usr/bin/ld, LLD,
and /usr/local/bin/ld, GNU ld on FreeBSD), the builds were configured
with --with-as/--with-ld.

The Solaris tests were run for as/ld, gas/ld, and gas/gld
configurations, the FreeBSD tests with gas/gld.

In all cases, gcc/auto-host.h and gcc/Makefile were unchanged.

2026-02-08  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc:
* configure.ac: Test solaris_as, solaris_ld instead of gas, gnu_ld.
(gcc_cv_as_working_gdwarf_n_flag): Escape '.' in filename.
* acinclude.m4 (gcc_cv_initfini_array): Test solaris_as,
solaris_ld instead of gas, gnu_ld.
* configure: Regenerate.

gcc/acinclude.m4
gcc/configure
gcc/configure.ac

index f10c83ef056c15943170ab673ca81e9f1600e0a2..135a66a91ba587f23f5243df07bcd004e9cf6f31 100644 (file)
@@ -308,24 +308,23 @@ 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:$gas in
-           *:yes)
-             sh_flags='"a"'
-             sh_type='%progbits'
-             ;;
-           i?86-*-solaris2*:no | x86_64-*-solaris2*:no)
+         case $target:$solaris_as in
+           i?86-*-solaris2*:yes | x86_64-*-solaris2*:yes)
              sh_flags='"a"'
              sh_type='@progbits'
              ;;
-           sparc*-*-solaris2*:no)
+           sparc*-*-solaris2*:yes)
              sh_flags='#alloc'
              sh_type='#progbits'
              sh_quote='"'
              ;;
+           *:*)
+             sh_flags='"a"'
+             sh_type='%progbits'
+             ;;
          esac
-         case "$target:$gnu_ld" in
-           *:yes)
-             cat > conftest.s <<EOF
+         if test x$solaris_ld = xno; then
+           cat > conftest.s <<EOF
 .section .dtors,$sh_flags,$sh_type
 .balign 4
 .byte 'A', 'A', 'A', 'A'
@@ -354,24 +353,23 @@ int (*fp) (void) __attribute__ ((section (".init_array"))) = foo;
 .globl _start
 _start:
 EOF
-             if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \
-                && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1 \
-                && $gcc_cv_objdump -s -j .init_array conftest \
-                   | grep HHHHFFFFDDDDBBBB > /dev/null 2>&1 \
-                && $gcc_cv_objdump -s -j .fini_array conftest \
-                   | grep GGGGEEEECCCCAAAA > /dev/null 2>&1; then
-               gcc_cv_initfini_array=yes
-             fi
-             ;;
-           *-*-solaris2*:no)
-             # When Solaris ld added constructor priority support, it was
-             # decided to only handle .init_array.N/.fini_array.N since
-             # there was no need for backwards compatibility with
-             # .ctors.N/.dtors.N.  .ctors/.dtors remain as separate
-             # sections with correct execution order resp. to
-             # .init_array/.fini_array, while gld merges them into
-             # .init_array/.fini_array.
-             cat > conftest.s <<EOF
+           if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \
+              && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1 \
+              && $gcc_cv_objdump -s -j .init_array conftest \
+                 | grep HHHHFFFFDDDDBBBB > /dev/null 2>&1 \
+              && $gcc_cv_objdump -s -j .fini_array conftest \
+                 | grep GGGGEEEECCCCAAAA > /dev/null 2>&1; then
+             gcc_cv_initfini_array=yes
+           fi
+         else
+           # When Solaris ld added constructor priority support, it was
+           # decided to only handle .init_array.N/.fini_array.N since
+           # there was no need for backwards compatibility with
+           # .ctors.N/.dtors.N.  .ctors/.dtors remain as separate
+           # sections with correct execution order resp. to
+           # .init_array/.fini_array, while gld merges them into
+           # .init_array/.fini_array.
+           cat > conftest.s <<EOF
 .section $sh_quote.fini_array.65530$sh_quote,$sh_flags,$sh_type
 .align 4
 .byte 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C'
@@ -388,16 +386,15 @@ EOF
 .globl _start
 _start:
 EOF
-             if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \
-                && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1 \
-                && $gcc_cv_objdump -s -j .init_array conftest \
-                   | grep HHHHHHHHDDDDDDDD > /dev/null 2>&1 \
-                && $gcc_cv_objdump -s -j .fini_array conftest \
-                   | grep GGGGGGGGCCCCCCCC > /dev/null 2>&1; then
-               gcc_cv_initfini_array=yes
-             fi
-             ;;
-           esac
+           if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \
+              && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1 \
+              && $gcc_cv_objdump -s -j .init_array conftest \
+                 | grep HHHHHHHHDDDDDDDD > /dev/null 2>&1 \
+              && $gcc_cv_objdump -s -j .fini_array conftest \
+                 | grep GGGGGGGGCCCCCCCC > /dev/null 2>&1; then
+             gcc_cv_initfini_array=yes
+           fi
+         fi
 changequote(,)dnl
          rm -f conftest conftest.*
 changequote([,])dnl
index ef780a23c2fdd0103fbc7db663f78dfbb482ef79..76220b8c0394e3cbecf9dacf4ce9e24edcb8dfd2 100755 (executable)
            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:$gas in
-           *:yes)
-             sh_flags='"a"'
-             sh_type='%progbits'
-             ;;
-           i?86-*-solaris2*:no | x86_64-*-solaris2*:no)
+         case $target:$solaris_as in
+           i?86-*-solaris2*:yes | x86_64-*-solaris2*:yes)
              sh_flags='"a"'
              sh_type='@progbits'
              ;;
-           sparc*-*-solaris2*:no)
+           sparc*-*-solaris2*:yes)
              sh_flags='#alloc'
              sh_type='#progbits'
              sh_quote='"'
              ;;
+           *:*)
+             sh_flags='"a"'
+             sh_type='%progbits'
+             ;;
          esac
-         case "$target:$gnu_ld" in
-           *:yes)
-             cat > conftest.s <<EOF
+         if test x$solaris_ld = xno; then
+           cat > conftest.s <<EOF
 .section .dtors,$sh_flags,$sh_type
 .balign 4
 .byte 'A', 'A', 'A', 'A'
 .globl _start
 _start:
 EOF
-             if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \
-                && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1 \
-                && $gcc_cv_objdump -s -j .init_array conftest \
-                   | grep HHHHFFFFDDDDBBBB > /dev/null 2>&1 \
-                && $gcc_cv_objdump -s -j .fini_array conftest \
-                   | grep GGGGEEEECCCCAAAA > /dev/null 2>&1; then
-               gcc_cv_initfini_array=yes
-             fi
-             ;;
-           *-*-solaris2*:no)
-             # When Solaris ld added constructor priority support, it was
-             # decided to only handle .init_array.N/.fini_array.N since
-             # there was no need for backwards compatibility with
-             # .ctors.N/.dtors.N.  .ctors/.dtors remain as separate
-             # sections with correct execution order resp. to
-             # .init_array/.fini_array, while gld merges them into
-             # .init_array/.fini_array.
-             cat > conftest.s <<EOF
+           if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \
+              && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1 \
+              && $gcc_cv_objdump -s -j .init_array conftest \
+                 | grep HHHHFFFFDDDDBBBB > /dev/null 2>&1 \
+              && $gcc_cv_objdump -s -j .fini_array conftest \
+                 | grep GGGGEEEECCCCAAAA > /dev/null 2>&1; then
+             gcc_cv_initfini_array=yes
+           fi
+         else
+           # When Solaris ld added constructor priority support, it was
+           # decided to only handle .init_array.N/.fini_array.N since
+           # there was no need for backwards compatibility with
+           # .ctors.N/.dtors.N.  .ctors/.dtors remain as separate
+           # sections with correct execution order resp. to
+           # .init_array/.fini_array, while gld merges them into
+           # .init_array/.fini_array.
+           cat > conftest.s <<EOF
 .section $sh_quote.fini_array.65530$sh_quote,$sh_flags,$sh_type
 .align 4
 .byte 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C'
@@ -26994,16 +26992,15 @@ EOF
 .globl _start
 _start:
 EOF
-             if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \
-                && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1 \
-                && $gcc_cv_objdump -s -j .init_array conftest \
-                   | grep HHHHHHHHDDDDDDDD > /dev/null 2>&1 \
-                && $gcc_cv_objdump -s -j .fini_array conftest \
-                   | grep GGGGGGGGCCCCCCCC > /dev/null 2>&1; then
-               gcc_cv_initfini_array=yes
-             fi
-             ;;
-           esac
+           if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \
+              && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1 \
+              && $gcc_cv_objdump -s -j .init_array conftest \
+                 | grep HHHHHHHHDDDDDDDD > /dev/null 2>&1 \
+              && $gcc_cv_objdump -s -j .fini_array conftest \
+                 | grep GGGGGGGGCCCCCCCC > /dev/null 2>&1; then
+             gcc_cv_initfini_array=yes
+           fi
+         fi
          rm -f conftest conftest.*
        fi
        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -28100,17 +28097,14 @@ foo:  .long   25
 .word foo(tlsldo)'
        ;;
   i?86-*-* | x86_64-*-*)
-    case "$target:$gas" in
-      i?86-*-solaris2*:no | x86_64-*-solaris2*:no)
-       tls_section_flag=t
+    if test x$solaris_as = xyes; then
+      tls_section_flag=t
 
 $as_echo "#define TLS_SECTION_ASM_FLAG 't'" >>confdefs.h
 
-       ;;
-      *:*)
-       tls_section_flag=T
-       ;;
-    esac
+    else
+      tls_section_flag=T
+    fi
     conftest_s='
       .section .tdata,"aw'$tls_section_flag'",@progbits'
     case "$target" in
@@ -28351,16 +28345,13 @@ foo:  .long   25
        .long   foo@TPOFF'
        ;;
   sparc*-*-*)
-    case "$target:$gas" in
-      sparc*-sun-solaris2.*:no)
-       conftest_s='
-       .section ".tdata",#alloc,#write,#tls'
-       ;;
-       *:*)
-        conftest_s='
-       .section ".tdata","awT",@progbits'
-       ;;
-    esac
+    if test x$solaris_as = xyes; then
+      conftest_s='
+      .section ".tdata",#alloc,#write,#tls'
+    else
+      conftest_s='
+      .section ".tdata","awT",@progbits'
+    fi
     tls_as_opt=$as_32_opt
     conftest_s="$conftest_s
 foo:   .long   25
@@ -28531,16 +28522,12 @@ 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$gcc_cv_ld != x; then
-  case "$target" in
-    # 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.
-    *-*-solaris2*)
-      gcc_cv_ld_version_script=yes
-      ld_version_script_option='-M'
-      ;;
-  esac
+elif test x$solaris_ld = xyes; 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.
+  gcc_cv_ld_version_script=yes
+  ld_version_script_option='-M'
 fi
 # Don't AC_DEFINE result, only used in jit/Make-lang.in so far.
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld_version_script" >&5
@@ -32398,7 +32385,7 @@ else
     then
              if test x$gcc_cv_objdump != x \
         && $gcc_cv_objdump -W conftest.o 2>&1 \
-               | grep conftest.s > /dev/null 2>&1; then
+               | grep 'conftest\.s' > /dev/null 2>&1; then
        gcc_cv_as_working_gdwarf_n_flag=no
       else
        gcc_cv_as_working_gdwarf_n_flag=yes
@@ -32986,7 +32973,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$gnu_ld = xno && test "$ld_vers_minor" -ge 3315; then
+  && test x$solaris_ld = xyes && test "$ld_vers_minor" -ge 3315; then
   gcc_cv_ld_ctf=yes
 
 $as_echo "#define HAVE_LD_CTF 1" >>confdefs.h
@@ -33269,16 +33256,14 @@ elif test x$gcc_cv_ld != x; then
       gcc_cv_ld_no_as_needed_option='--pop-state'
     fi
   fi
-  case "$target:$gnu_ld" in
-    *-*-solaris2*:no)
-      # Solaris 2 ld always supports -z ignore/-z record.  Prefer the native
-      # forms.
-      gcc_cv_ld_as_needed=yes
-      gcc_cv_ld_as_needed_option="-z ignore"
-      gcc_cv_ld_no_as_needed_option="-z record"
-      gcc_cv_ld_use_as_needed_ldscript=no
-      ;;
-  esac
+  if test x$solaris_ld = xyes; then
+    # Solaris 2 ld always supports -z ignore/-z record.  Prefer the native
+    # forms.
+    gcc_cv_ld_as_needed=yes
+    gcc_cv_ld_as_needed_option="-z ignore"
+    gcc_cv_ld_no_as_needed_option="-z record"
+    gcc_cv_ld_use_as_needed_ldscript=no
+  fi
 fi
 
 fi
index cdf2997cb5f8614e22e659ad9cf566909086e58a..4c939d6e19c409300a4f84f52bcfd5d29a48152d 100644 (file)
@@ -3993,18 +3993,15 @@ foo:    .long   25
 .word foo(tlsldo)'
        ;;
   i?86-*-* | x86_64-*-*)
-    case "$target:$gas" in
-      i?86-*-solaris2*:no | x86_64-*-solaris2*:no)
-       tls_section_flag=t
+    if test x$solaris_as = xyes; then
+      tls_section_flag=t
 changequote([,])dnl
-       AC_DEFINE(TLS_SECTION_ASM_FLAG, 't',
+      AC_DEFINE(TLS_SECTION_ASM_FLAG, 't',
 [Define to the flag used to mark TLS sections if the default (`T') doesn't work.])
 changequote(,)dnl
-       ;;
-      *:*)
-       tls_section_flag=T
-       ;;
-    esac
+    else
+      tls_section_flag=T
+    fi
     conftest_s='
       .section .tdata,"aw'$tls_section_flag'",@progbits'
     case "$target" in
@@ -4245,16 +4242,13 @@ foo:    .long   25
        .long   foo@TPOFF'
        ;;
   sparc*-*-*)
-    case "$target:$gas" in
-      sparc*-sun-solaris2.*:no)
-       conftest_s='
-       .section ".tdata",#alloc,#write,#tls'
-       ;;
-       *:*)
-        conftest_s='
-       .section ".tdata","awT",@progbits'
-       ;;
-    esac
+    if test x$solaris_as = xyes; then
+      conftest_s='
+      .section ".tdata",#alloc,#write,#tls'
+    else
+      conftest_s='
+      .section ".tdata","awT",@progbits'
+    fi
     tls_as_opt=$as_32_opt
     conftest_s="$conftest_s
 foo:   .long   25
@@ -4389,16 +4383,12 @@ 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$gcc_cv_ld != x; then
-  case "$target" in
-    # 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.
-    *-*-solaris2*)
-      gcc_cv_ld_version_script=yes
-      ld_version_script_option='-M'
-      ;;
-  esac
+elif test x$solaris_ld = xyes; 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.
+  gcc_cv_ld_version_script=yes
+  ld_version_script_option='-M'
 fi
 # Don't AC_DEFINE result, only used in jit/Make-lang.in so far.
 AC_MSG_RESULT($gcc_cv_ld_version_script)
@@ -5939,7 +5929,7 @@ foo:
      [changequote(,)dnl
       if test x$gcc_cv_objdump != x \
         && $gcc_cv_objdump -W conftest.o 2>&1 \
-               | grep conftest.s > /dev/null 2>&1; then
+               | grep 'conftest\.s' > /dev/null 2>&1; then
        gcc_cv_as_working_gdwarf_n_flag=no
       else
        gcc_cv_as_working_gdwarf_n_flag=yes
@@ -6347,7 +6337,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$gnu_ld = xno && test "$ld_vers_minor" -ge 3315; then
+  && test x$solaris_ld = xyes && 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
@@ -6580,16 +6570,14 @@ elif test x$gcc_cv_ld != x; then
       gcc_cv_ld_no_as_needed_option='--pop-state'
     fi
   fi
-  case "$target:$gnu_ld" in
-    *-*-solaris2*:no)
-      # Solaris 2 ld always supports -z ignore/-z record.  Prefer the native
-      # forms.
-      gcc_cv_ld_as_needed=yes
-      gcc_cv_ld_as_needed_option="-z ignore"
-      gcc_cv_ld_no_as_needed_option="-z record"
-      gcc_cv_ld_use_as_needed_ldscript=no
-      ;;
-  esac
+  if test x$solaris_ld = xyes; then
+    # Solaris 2 ld always supports -z ignore/-z record.  Prefer the native
+    # forms.
+    gcc_cv_ld_as_needed=yes
+    gcc_cv_ld_as_needed_option="-z ignore"
+    gcc_cv_ld_no_as_needed_option="-z record"
+    gcc_cv_ld_use_as_needed_ldscript=no
+  fi
 fi
 ])
 if test x"$gcc_cv_ld_as_needed" = xyes; then