diff mbox series

[build] Configure USE_HIDDEN_LINKONCE on Solaris/x86

Message ID yddh8rbb1bz.fsf@CeBiTec.Uni-Bielefeld.DE
State New
Headers show
Series [build] Configure USE_HIDDEN_LINKONCE on Solaris/x86 | expand

Commit Message

Rainer Orth Jan. 24, 2018, 5:42 p.m. UTC
Prompted by PR target/83838 (Many gcc.target/i386/indirect-thunk*.c
tests FAIL), which is caused by this snippet in i386/sol2.h

/* Only recent versions of Solaris 11 ld properly support hidden .gnu.linkonce
   sections, so don't use them.  */
#ifndef USE_GLD
#define USE_HIDDEN_LINKONCE 0
#endif

I had a fresh look at enabling it at configure time if possible.  A
first test on Solaris 10 and 11/x86 showed that even the latest Solaris
10/x86 ld doesn't work, with a couple of testsuite failures like

ld: fatal: symbol '__x86.get_pc_thunk.ax' is multiply-defined:
        (file cp_lto_20081118_0.o type=FUNC; file cp_lto_20081118_1.o type=FUNC);

which matches the fact that full support for .gnu.linkonce sections and
comdat as emitted by gcc only appeared in Solaris 11.

However, AFAICT this happened in the early OpenSolaris days, so
USE_HIDDEN_LINKONCE can safely be enabled on Solaris 11/x86.

This is what the following patch does, being careful to only affect
Solaris/x86 targets.  Two testcases had to be adjusted not to XPASS now.

Bootstrapped without regressions on i386-pc-solaris2.10,
i386-pc-solaris2.11 (both with as/ld and gas/gld), and
x86_64-pc-linux-gnu.  Now, the PR target/83838 failures are gone on
Solaris 11/x86, as expected.

Even though we're late in the GCC 8 release cycle, I believe the patch
is safe enough to be applied at this stage, so I'll do so in a day or
two unless someone objects.

	Rainer
diff mbox series

Patch

# HG changeset patch
# Parent  c7f14a8b12c25c407e4379959d7ecf27040d9ca1
Configure USE_HIDDEN_LINKONCE on Solaris/x86

diff --git a/gcc/config/i386/sol2.h b/gcc/config/i386/sol2.h
--- a/gcc/config/i386/sol2.h
+++ b/gcc/config/i386/sol2.h
@@ -253,9 +253,3 @@  along with GCC; see the file COPYING3.  
 /* We do not need NT_VERSION notes.  */
 #undef X86_FILE_START_VERSION_DIRECTIVE
 #define X86_FILE_START_VERSION_DIRECTIVE false
-
-/* Only recent versions of Solaris 11 ld properly support hidden .gnu.linkonce
-   sections, so don't use them.  */
-#ifndef USE_GLD
-#define USE_HIDDEN_LINKONCE 0
-#endif
diff --git a/gcc/configure.ac b/gcc/configure.ac
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -3070,6 +3070,31 @@  AC_DEFINE_UNQUOTED(HAVE_COMDAT_GROUP,
     || test $gcc_cv_as_comdat_group_group = yes; then echo 1; else echo 0; fi`],
 [Define 0/1 if your assembler and linker support COMDAT groups.])
 
+# Restrict this test to Solaris/x86: other targets define this statically.
+case "${target}" in
+  i?86-*-solaris2* | x86_64-*-solaris2*)
+    AC_MSG_CHECKING(support for hidden thunks in linkonce sections)
+    if test $in_tree_ld = yes || echo "$ld_ver" | grep GNU > /dev/null; then
+      hidden_linkonce=yes
+    else
+      case "${target}" in
+	# Full support for hidden thunks in linkonce sections only appeared in
+	# Solaris 11/OpenSolaris.
+        *-*-solaris2.1[[1-9]]*)
+	  hidden_linkonce=yes
+	  ;;
+	*)
+	  hidden_linkonce=no
+	  ;;
+      esac
+    fi
+    AC_MSG_RESULT($hidden_linkonce)
+    AC_DEFINE_UNQUOTED(USE_HIDDEN_LINKONCE,
+      [`if test $hidden_linkonce = yes; then echo 1; else echo 0; fi`],
+    [Define 0/1 if your linker supports hidden thunks in linkonce sections.])
+  ;;
+esac
+
 gcc_GAS_CHECK_FEATURE([line table discriminator support],
  gcc_cv_as_discriminator,
  [2,19,51],,
diff --git a/gcc/testsuite/gcc.target/i386/mcount_pic.c b/gcc/testsuite/gcc.target/i386/mcount_pic.c
--- a/gcc/testsuite/gcc.target/i386/mcount_pic.c
+++ b/gcc/testsuite/gcc.target/i386/mcount_pic.c
@@ -11,5 +11,5 @@  int main ()
 }
 
 /* { dg-final { scan-assembler "mcount" } } */
-/* { dg-final { scan-assembler "get_pc_thunk" { xfail { *-*-solaris* && { ! gld } } } } } */
+/* { dg-final { scan-assembler "get_pc_thunk" { xfail { *-*-solaris2.10* && { ! gld } } } } } */
 /* { dg-final { cleanup-profile-file } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr63620.c b/gcc/testsuite/gcc.target/i386/pr63620.c
--- a/gcc/testsuite/gcc.target/i386/pr63620.c
+++ b/gcc/testsuite/gcc.target/i386/pr63620.c
@@ -17,4 +17,4 @@  test (__float128 x, int p, func f)
   return x;
 }
 
-/* { dg-final { scan-assembler "get_pc_thunk" { xfail { *-*-solaris* && { ! gld } } } } } */
+/* { dg-final { scan-assembler "get_pc_thunk" { xfail { *-*-solaris2.10* && { ! gld } } } } } */