]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Hardcode Solaris v2 mapfile syntax with Solaris ld
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Sun, 5 Jul 2026 12:59:27 +0000 (14:59 +0200)
committerRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Sun, 5 Jul 2026 12:59:27 +0000 (14:59 +0200)
GCC uses two linker mapfiles for Solaris ld: clearcap.map and
libgcc-unwind.map.  Currently, both the original v1 mapfile syntax and
the new v2 one are supported, distinguished with configure checks.
However, the v2 mapfile syntax was already introduced in Solaris 11.0,
so with only Solaris 11.4 supported the checks are no longer necessary.

Besides, when doing non-bootstrap builds where the build compiler's
configured linker and the stage1 compiler differ (ld -> gld), the build
compiler was probed for mapfile syntax support, which breaks the stage1
compiler.

Now, the mapfiles are used unconditionally if the freshly built compiler
uses Solaris ld.

Bootstrapped without regressions on i386-pc-solaris2.11 and
sparc-sun-solaris2.11 with ld and gld, and x86_64-pc-linux-gnu.

2026-06-25  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc:
* configure.ac (gcc_cv_ld_clearcap): Remove.
Link clearcap.map to config/sol2-clearcap.map with Solaris ld.

* configure: Regenerate.
* config.in: Likewise.
* config/sol2-clearcap.map: Remove.
* config/sol2-clearcapv2.map: Rename to sol2-clearcap.map.
* config/t-sol2 (install-clearcap-map): Install source file
directly.
* config/sol2.h (LINK_CLEARCAP_SPEC): Guard with HAVE_SOLARIS_LD.

libgcc:
* configure.ac (solaris_ld_v2_maps): Remove.
* configure: Regenerate.
* Makefile.in (solaris_ld_v2_maps): Remove.
* config/t-slibgcc-sld (libgcc-unwind.map): Remove
solaris_ld_v2_maps handling.

gcc/config.in
gcc/config/sol2-clearcap.map
gcc/config/sol2-clearcapv2.map [deleted file]
gcc/config/sol2.h
gcc/config/t-sol2
gcc/configure
gcc/configure.ac
libgcc/Makefile.in
libgcc/config/t-slibgcc-sld
libgcc/configure
libgcc/configure.ac

index 4d9780b61423ce31fbff099581a216592dff561f..22421a6cbeb083a37050a13c3b856d4b9241c922 100644 (file)
 #endif
 
 
-/* Define if the linker supports clearing hardware capabilities via mapfile.
-   */
-#ifndef USED_FOR_TARGET
-#undef HAVE_LD_CLEARCAP
-#endif
-
-
 /* Define to the level of your linker's compressed debug section support. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_LD_COMPRESS_DEBUG
index 2d880c983e455963168794661cd8cb04cd8a3586..3c0cacedbf05b40076f6525655ea6bc905d48414 100644 (file)
@@ -1,2 +1,7 @@
 # Clear all hardware capabilities emitted by Sun as.
-hwcap_1 = V0x0 OVERRIDE;
+#
+# Uses mapfile v2 syntax which is the only way to clear AT_SUN_CAP_HW2 flags.
+$mapfile_version 2
+CAPABILITY {
+  HW = ;
+};
diff --git a/gcc/config/sol2-clearcapv2.map b/gcc/config/sol2-clearcapv2.map
deleted file mode 100644 (file)
index 3c0cace..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-# Clear all hardware capabilities emitted by Sun as.
-#
-# Uses mapfile v2 syntax which is the only way to clear AT_SUN_CAP_HW2 flags.
-$mapfile_version 2
-CAPABILITY {
-  HW = ;
-};
index 0353fd91d37aaf9881c58684f64d00af6c211e34..dbcae6c2f73ab3d8fefe19bb1cd8a928fd7e1565 100644 (file)
@@ -348,7 +348,7 @@ along with GCC; see the file COPYING3.  If not see
 
 /* Clear hardware capabilities, either explicitly or with OpenMP:
    #pragma openmp declare simd creates clones for SSE2, AVX, and AVX2.  */
-#ifdef HAVE_LD_CLEARCAP
+#if HAVE_SOLARIS_LD
 #define LINK_CLEARCAP_SPEC " %{mclear-hwcap|fopenmp*:-M %sclearcap.map}"
 #else
 #define LINK_CLEARCAP_SPEC ""
index a5f2288fd0dea32bb1a1cba96717fbb77b83aa86..18164de1ab5f32a611248a8cf94c56dd6a3cab78 100644 (file)
@@ -50,5 +50,5 @@ sol2.o: $(srcdir)/config/sol2.cc
 install: install-clearcap-map
 
 # Ignore failures: file only exists if linker supports it.
-install-clearcap-map:
-       -$(INSTALL_DATA) clearcap.map $(DESTDIR)$(libdir)
+install-clearcap-map: $(srcdir)/config/sol2-clearcap.map
+       -$(INSTALL_DATA) $< $(DESTDIR)$(libdir)
index a8c4ca7b0b9d108a5482d43dfffab31f4f1b8f12..ceb51cb63dcd80a2af5bb9a3c686630ebbdba4c9 100755 (executable)
@@ -33263,33 +33263,10 @@ $as_echo "#define USE_LD_AS_NEEDED_LDSCRIPT 1" >>confdefs.h
 
 fi
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking linker mapfile support for clearing hardware capabilities" >&5
-$as_echo_n "checking linker mapfile support for clearing hardware capabilities... " >&6; }
-saved_LDFLAGS="$LDFLAGS"
-for clearcap_map in sol2-clearcapv2.map sol2-clearcap.map; do
-  LDFLAGS="$saved_LDFLAGS -Wl,-M,${srcdir}/config/$clearcap_map"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-int main(void) {return 0;}
-_ACEOF
-if ac_fn_cxx_try_link "$LINENO"; then :
-  gcc_cv_ld_clearcap=yes; break
-else
-  gcc_cv_ld_clearcap=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-done
-LDFLAGS="$saved_LDFLAGS"
-if test "x$gcc_cv_ld_clearcap" = xyes; then
-
-$as_echo "#define HAVE_LD_CLEARCAP 1" >>confdefs.h
-
-  ac_config_links="$ac_config_links clearcap.map:${srcdir}/config/$clearcap_map"
+if test x$ld_flavor = xsolaris; then
+  ac_config_links="$ac_config_links clearcap.map:${srcdir}/config/sol2-clearcap.map"
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld_clearcap" >&5
-$as_echo "$gcc_cv_ld_clearcap" >&6; }
 
 case "$target" in
   powerpc*-*-*)
@@ -36078,7 +36055,7 @@ do
     "collect-ld") CONFIG_FILES="$CONFIG_FILES collect-ld:exec-tool.in" ;;
     "nm") CONFIG_FILES="$CONFIG_FILES nm:exec-tool.in" ;;
     "dsymutil") CONFIG_FILES="$CONFIG_FILES dsymutil:exec-tool.in" ;;
-    "clearcap.map") CONFIG_LINKS="$CONFIG_LINKS clearcap.map:${srcdir}/config/$clearcap_map" ;;
+    "clearcap.map") CONFIG_LINKS="$CONFIG_LINKS clearcap.map:${srcdir}/config/sol2-clearcap.map" ;;
     "$all_outputs") CONFIG_FILES="$CONFIG_FILES $all_outputs" ;;
     "default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
 
index 08bf6317e2a0e5b7b6abc7a680191f1d0c1ffa6f..ccd1020413a5e2f89dc470d316affa9ee8af2957 100644 (file)
@@ -6606,20 +6606,9 @@ if test x"$gcc_cv_ld_use_as_needed_ldscript" = xyes; then
 [Define if your linker supports AS_NEEDED in linker scripts.])
 fi
 
-AC_MSG_CHECKING(linker mapfile support for clearing hardware capabilities)
-saved_LDFLAGS="$LDFLAGS"
-for clearcap_map in sol2-clearcapv2.map sol2-clearcap.map; do
-  LDFLAGS="$saved_LDFLAGS -Wl,-M,${srcdir}/config/$clearcap_map"
-  AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) {return 0;}])],
-    [gcc_cv_ld_clearcap=yes; break], [gcc_cv_ld_clearcap=no])
-done
-LDFLAGS="$saved_LDFLAGS"
-if test "x$gcc_cv_ld_clearcap" = xyes; then
-  AC_DEFINE([HAVE_LD_CLEARCAP], 1,
-[Define if the linker supports clearing hardware capabilities via mapfile.])
-  AC_CONFIG_LINKS([clearcap.map:${srcdir}/config/$clearcap_map])
+if test x$ld_flavor = xsolaris; then
+  AC_CONFIG_LINKS([clearcap.map:${srcdir}/config/sol2-clearcap.map])
 fi
-AC_MSG_RESULT($gcc_cv_ld_clearcap)
 
 case "$target" in
   powerpc*-*-*)
index 8b8fe6e9a28530f8c135010b86487e590eacc857..59df657e282efd20754789a40b8018ad026b567f 100644 (file)
@@ -44,7 +44,6 @@ enable_vtable_verify = @enable_vtable_verify@
 enable_decimal_float = @enable_decimal_float@
 fixed_point = @fixed_point@
 with_aix_soname = @with_aix_soname@
-solaris_ld_v2_maps = @solaris_ld_v2_maps@
 enable_execute_stack = @enable_execute_stack@
 unwind_header = @unwind_header@
 md_unwind_def_header = @md_unwind_def_header@
index 03c6a65955173334f8b06bb88af6391c31a63ec5..adfc0e3bd8b94eda2f3461b0cedc43b75e809b7a 100644 (file)
@@ -8,23 +8,13 @@ ifeq ($(enable_shared),yes)
 
 # Linker mapfile to enforce direct binding to libgcc_s unwinder
 # (PR target/59788).
-# Emit v2 mapfile syntax if possible, otherwise ld -z guidance complains
-# every time the mapfile is used.
 libgcc-unwind.map: libgcc-std.ver
-ifeq ($(solaris_ld_v2_maps),yes)
        @(echo '$$mapfile_version 2';           \
        echo "SYMBOL_SCOPE {";                  \
        for f in `grep _Unwind_ $< | sort`; do  \
          echo "        $$f { FLAGS = EXTERN DIRECT };"; \
        done;                                   \
        echo "};" ) > $@
-else
-       @(echo "{";                             \
-       for f in `grep _Unwind_ $< | sort`; do  \
-         echo "        $$f = EXTERN DIRECT;";  \
-       done;                                   \
-       echo "};" ) > $@
-endif
 
 # Copy libgcc-unwind.map to the place where gcc will look for it at build-time.
 install-libgcc-unwind-map-forbuild: libgcc-unwind.map
index adfbfcbed081c958f0f25eeb15257914975ad15e..6f4845b59eeaccb74daa7e1c908b2a661ca3863f 100755 (executable)
@@ -604,7 +604,6 @@ sfp_machine_header
 set_use_emutls
 set_have_cc_tls
 vis_hide
-solaris_ld_v2_maps
 real_host_noncanonical
 accel_dir_suffix
 use_tm_clone_registry
@@ -5403,26 +5402,6 @@ EOF
   ;;
 esac
 
-# Check if Solaris linker support v2 linker mapfile syntax.
-# Link with -nostartfiles -nodefaultlibs since neither are present while
-# building libgcc.
-case ${host} in
-*-*-solaris2*)
-  solaris_ld_v2_maps=no
-  echo 'int main(void) {return 0;}' > conftest.c
-  echo '$mapfile_version 2' > conftest.map
-  if { ac_try='${CC-cc} -nostartfiles -nodefaultlibs -Wl,-M,conftest.map -o conftest conftest.c 1>&5'
-  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; }; then
-      solaris_ld_v2_maps=yes
-  fi
-  ;;
-esac
-
-
 case ${host} in
 loongarch32*-*-*)
   tmake_file="${tmake_file} loongarch/t-crtstuff-la32"
index e0686550aa024155a99be0c8fff692532167e652..a76e1e9943a5535029890d82f00070627bc04cb3 100644 (file)
@@ -529,21 +529,6 @@ EOF
   ;;
 esac
 
-# Check if Solaris linker support v2 linker mapfile syntax.
-# Link with -nostartfiles -nodefaultlibs since neither are present while
-# building libgcc.
-case ${host} in
-*-*-solaris2*)
-  solaris_ld_v2_maps=no
-  echo 'int main(void) {return 0;}' > conftest.c
-  echo '$mapfile_version 2' > conftest.map
-  if AC_TRY_COMMAND([${CC-cc} -nostartfiles -nodefaultlibs -Wl,-M,conftest.map -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD]); then
-      solaris_ld_v2_maps=yes
-  fi
-  ;;
-esac
-AC_SUBST(solaris_ld_v2_maps)
-
 case ${host} in
 loongarch32*-*-*)
   tmake_file="${tmake_file} loongarch/t-crtstuff-la32"