diff mbox

[build,libgomp] Support Sun symbol versioning in libgomp, rev. 2

Message ID yddsk43jjdi.fsf@manam.CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth July 1, 2010, 3:45 p.m. UTC
The original version of this patch

	PATCH: Support Sun symbol versioning in libgomp
        http://gcc.gnu.org/ml/gcc-patches/2010-02/msg01003.html

has seen no comments whatsoever.  I've just received approval for the
updated version of the corresponding libstdc++ patch

	[build, doc, v3] Support Sun symbol versioning in libstdc++-v3, rev. 2
        http://gcc.gnu.org/ml/gcc-patches/2010-06/msg03182.html

so the necessary infrastructure (contrib/make_sunver.pl) for this one is
in place.

Compared to the original version, this revision completely disables
symbol renaming even with GNU as and ld since the Sun ld.so.1 cannot and
will not support it.

Bootstrapped without regressions on Solaris 8 to 11, both SPARC and x86
with Sun as and GNU as, Sun ld and GNU ld.

Ok for mainline after trunk is unfrozen?

Thanks.
	Rainer

Comments

Jakub Jelinek July 2, 2010, 10:43 a.m. UTC | #1
On Thu, Jul 01, 2010 at 05:45:45PM +0200, Rainer Orth wrote:
> Bootstrapped without regressions on Solaris 8 to 11, both SPARC and x86
> with Sun as and GNU as, Sun ld and GNU ld.

Please also test on Linux (e.g. x86_64, i686, powerpc*) to make sure it
doesn't regress there.

readelf -Ws $1 | sed -n '/\.symtab/,$d;/ UND /d;/@GLIBC_PRIVATE/d;/\(GLOBAL\|WEAK\|UNIQUE\)/p' | awk '{ if ($4 == "OBJECT") { printf "%s %s %s %s %s\n", $8, $4, $5, $6, $3 } else { printf "%s %s %s %s\n", $8, $4, $5, $6 }}' | LC_ALL=C sort -u

should be identical before/after your patch.

	Jakub
Rainer Orth July 5, 2010, 4:58 p.m. UTC | #2
Jakub Jelinek <jakub@redhat.com> writes:

> On Thu, Jul 01, 2010 at 05:45:45PM +0200, Rainer Orth wrote:
>> Bootstrapped without regressions on Solaris 8 to 11, both SPARC and x86
>> with Sun as and GNU as, Sun ld and GNU ld.
>
> Please also test on Linux (e.g. x86_64, i686, powerpc*) to make sure it
> doesn't regress there.
>
> readelf -Ws $1 | sed -n '/\.symtab/,$d;/ UND /d;/@GLIBC_PRIVATE/d;/\(GLOBAL\|WEAK\|UNIQUE\)/p' | awk '{ if ($4 == "OBJECT") { printf "%s %s %s %s %s\n", $8, $4, $5, $6, $3 } else { printf "%s %s %s %s\n", $8, $4, $5, $6 }}' | LC_ALL=C sort -u
>
> should be identical before/after your patch.

I've discovered we have a single Linux machine running RHEL4, so I've
bootstrapped without regressions on x86_64-unknown-linux-gnu.  The set
of exported symbols is identical between a vanilla tree and my patch.

Since libgomp uses the same target_os-based check for symbol versioning
that has been inherited/copied from libstdc++-v3, there's no risk of
running into the Darwin problem of silently accepting the ld -M option.

Ok now?

Thanks.
	Rainer
Jakub Jelinek July 5, 2010, 5:02 p.m. UTC | #3
On Mon, Jul 05, 2010 at 06:58:22PM +0200, Rainer Orth wrote:
> Jakub Jelinek <jakub@redhat.com> writes:
> 
> > On Thu, Jul 01, 2010 at 05:45:45PM +0200, Rainer Orth wrote:
> >> Bootstrapped without regressions on Solaris 8 to 11, both SPARC and x86
> >> with Sun as and GNU as, Sun ld and GNU ld.
> >
> > Please also test on Linux (e.g. x86_64, i686, powerpc*) to make sure it
> > doesn't regress there.
> >
> > readelf -Ws $1 | sed -n '/\.symtab/,$d;/ UND /d;/@GLIBC_PRIVATE/d;/\(GLOBAL\|WEAK\|UNIQUE\)/p' | awk '{ if ($4 == "OBJECT") { printf "%s %s %s %s %s\n", $8, $4, $5, $6, $3 } else { printf "%s %s %s %s\n", $8, $4, $5, $6 }}' | LC_ALL=C sort -u
> >
> > should be identical before/after your patch.
> 
> I've discovered we have a single Linux machine running RHEL4, so I've
> bootstrapped without regressions on x86_64-unknown-linux-gnu.  The set
> of exported symbols is identical between a vanilla tree and my patch.

Thanks.

> Since libgomp uses the same target_os-based check for symbol versioning
> that has been inherited/copied from libstdc++-v3, there's no risk of
> running into the Darwin problem of silently accepting the ld -M option.
> 
> Ok now?

Ok.

	Jakub
diff mbox

Patch

diff -r 7dc43b7d2f17 libgomp/Makefile.am
--- a/libgomp/Makefile.am	Mon May 10 01:16:49 2010 +0200
+++ b/libgomp/Makefile.am	Mon May 10 01:17:58 2010 +0200
@@ -22,13 +22,39 @@ 
 nodist_toolexeclib_HEADERS = libgomp.spec
 
 if LIBGOMP_BUILD_VERSIONED_SHLIB
+if LIBGOMP_BUILD_VERSIONED_SHLIB_GNU
+if LIBGOMP_BUILD_VERSIONED_SHLIB_SOL2
+libgomp_version_script = -Wl,--version-script,libgomp.map-sol2
+libgomp_version_dep = libgomp.map-sol2
+libgomp.map-sol2 : $(top_srcdir)/libgomp.map
+	sed -e '/^#ifdef HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT/,/^#endif/d' $< \
+	 > $@ || (rm -f $@ ; exit 1)
+else
 libgomp_version_script = -Wl,--version-script,$(top_srcdir)/libgomp.map
+libgomp_version_dep = $(top_srcdir)/libgomp.map
+endif
+endif
+if LIBGOMP_BUILD_VERSIONED_SHLIB_SUN
+libgomp_version_script = -Wl,-M,libgomp.map-sun
+libgomp_version_dep = libgomp.map-sun
+libgomp.map-sun : $(top_srcdir)/libgomp.map \
+		$(top_srcdir)/../contrib/make_sunver.pl \
+		$(libgomp_la_OBJECTS) $(libgomp_la_LIBADD)
+	perl $(top_srcdir)/../contrib/make_sunver.pl \
+	  $(top_srcdir)/libgomp.map \
+	  $(libgomp_la_OBJECTS:%.lo=.libs/%.o) \
+	 `echo $(libgomp_la_LIBADD) | \
+	    sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
+	 > $@ || (rm -f $@ ; exit 1)
+endif
 else
 libgomp_version_script =
+libgomp_version_dep =
 endif
 libgomp_version_info = -version-info $(libtool_VERSION)
 libgomp_la_LDFLAGS = $(libgomp_version_info) $(libgomp_version_script) \
         -no-undefined -bindir "$(bindir)"
+libgomp_la_DEPENDENCIES = $(libgomp_version_dep)
 libgomp_la_LINK = $(LINK) $(libgomp_la_LDFLAGS)
 
 libgomp_la_SOURCES = alloc.c barrier.c critical.c env.c error.c iter.c \
diff -r 7dc43b7d2f17 libgomp/acinclude.m4
--- a/libgomp/acinclude.m4	Mon May 10 01:16:49 2010 +0200
+++ b/libgomp/acinclude.m4	Mon May 10 01:17:58 2010 +0200
@@ -223,16 +223,42 @@ 
 
 LIBGOMP_ENABLE(symvers,yes,[=STYLE],
   [enables symbol versioning of the shared library],
-  [permit yes|no|gnu])
+  [permit yes|no|gnu|sun])
 
 # If we never went through the LIBGOMP_CHECK_LINKER_FEATURES macro, then we
 # don't know enough about $LD to do tricks...
 AC_REQUIRE([LIBGOMP_CHECK_LINKER_FEATURES])
 # FIXME  The following test is too strict, in theory.
-if test $enable_shared = no ||
-        test "x$LD" = x ||
-        test x$libgomp_gnu_ld_version = x; then
+if test $enable_shared = no || test "x$LD" = x; then
   enable_symvers=no
+else
+  if test $with_gnu_ld = yes ; then
+    enable_symvers=gnu
+  else
+    case ${target_os} in
+      # Sun symbol versioning exists since Solaris 2.5.
+      solaris2.[[5-9]]* | solaris2.1[[0-9]]*)
+        enable_symvers=sun ;;
+      *)
+        enable_symvers=no ;;
+    esac
+  fi
+fi
+
+# Check if 'sun' was requested on non-Solaris 2 platforms.
+if test x$enable_symvers = xsun ; then
+  case ${target_os} in
+    solaris2*)
+      # All fine.
+      ;;
+    *)
+      # Unlikely to work.
+      AC_MSG_WARN([=== You have requested Sun symbol versioning, but])
+      AC_MSG_WARN([=== you are not targetting Solaris 2.])
+      AC_MSG_WARN([=== Symbol versioning will be disabled.])
+      enable_symvers=no
+      ;;
+  esac
 fi
 
 # Check to see if libgcc_s exists, indicating that shared libgcc is possible.
@@ -269,10 +295,8 @@ 
 
 # Check to see if unspecified "yes" value can win, given results above.
 # Change "yes" into either "no" or a style name.
-if test $enable_symvers = yes; then
-  if test $with_gnu_ld = yes &&
-     test $libgomp_shared_libgcc = yes;
-  then
+if test $enable_symvers != no && test $libgomp_shared_libgcc = yes; then
+  if test $with_gnu_ld = yes; then
     if test $libgomp_gnu_ld_version -ge $libgomp_min_gnu_ld_version ; then
       enable_symvers=gnu
     elif test $libgomp_ld_is_gold = yes ; then
@@ -295,6 +319,8 @@ 
         enable_symvers=no
       fi
     fi
+  elif test $enable_symvers = sun; then
+    : All interesting versions of Sun ld support sun style symbol versioning.
   else
     # just fail for now
     AC_MSG_WARN([=== You have requested some kind of symbol versioning, but])
@@ -316,5 +342,22 @@ 
 fi
 
 AM_CONDITIONAL(LIBGOMP_BUILD_VERSIONED_SHLIB, test $enable_symvers != no)
+AM_CONDITIONAL(LIBGOMP_BUILD_VERSIONED_SHLIB_GNU, test $enable_symvers = gnu)
+AM_CONDITIONAL(LIBGOMP_BUILD_VERSIONED_SHLIB_SUN, test $enable_symvers = sun)
 AC_MSG_NOTICE(versioning on shared library symbols is $enable_symvers)
+
+if test $enable_symvers != no ; then
+   case ${target_os} in
+     # The Solaris 2 runtime linker doesn't support the GNU extension of
+     # binding the same symbol to different versions
+     solaris2*)
+       symvers_renaming=no ;;
+     # Other platforms with GNU symbol versioning (GNU/Linux, more?) do.
+     *)
+       AC_DEFINE(HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT, 1,
+         [Define to 1 if the target runtime linker supports binding the same symbol to different versions.])
+       symvers_renaming=yes ;;
+    esac
+fi
+AM_CONDITIONAL(LIBGOMP_BUILD_VERSIONED_SHLIB_SOL2, test $symvers_renaming = no)
 ])
diff -r 7dc43b7d2f17 libgomp/libgomp.h
--- a/libgomp/libgomp.h	Mon May 10 01:16:49 2010 +0200
+++ b/libgomp/libgomp.h	Mon May 10 01:17:58 2010 +0200
@@ -514,7 +514,8 @@ 
 #if !defined (HAVE_ATTRIBUTE_VISIBILITY) \
     || !defined (HAVE_ATTRIBUTE_ALIAS) \
     || !defined (HAVE_AS_SYMVER_DIRECTIVE) \
-    || !defined (PIC)
+    || !defined (PIC) \
+    || !defined (HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT)
 # undef LIBGOMP_GNU_SYMBOL_VERSIONING
 #endif
 
diff -r 7dc43b7d2f17 libgomp/libgomp.map
--- a/libgomp/libgomp.map	Mon May 10 01:16:49 2010 +0200
+++ b/libgomp/libgomp.map	Mon May 10 01:17:58 2010 +0200
@@ -10,6 +10,10 @@ 
 	omp_get_dynamic;
 	omp_set_nested;
 	omp_get_nested;
+#ifdef HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT
+        # If the assembler used lacks the .symver directive or the linker
+	# doesn't support GNU symbol versioning, we have the same symbol in
+	# two versions, which Sun ld chokes on. 
 	omp_init_lock;
 	omp_init_nest_lock;
 	omp_destroy_lock;
@@ -22,6 +26,15 @@ 
 	omp_test_nest_lock;
 	omp_destroy_lock_;
 	omp_destroy_nest_lock_;
+	omp_init_lock_;
+	omp_init_nest_lock_;
+	omp_set_lock_;
+	omp_set_nest_lock_;
+	omp_test_lock_;
+	omp_test_nest_lock_;
+	omp_unset_lock_;
+	omp_unset_nest_lock_;
+#endif
 	omp_get_dynamic_;
 	omp_get_max_threads_;
 	omp_get_nested_;
@@ -29,20 +42,12 @@ 
 	omp_get_num_threads_;
 	omp_get_thread_num_;
 	omp_in_parallel_;
-	omp_init_lock_;
-	omp_init_nest_lock_;
 	omp_set_dynamic_;
 	omp_set_dynamic_8_;
-	omp_set_lock_;
-	omp_set_nest_lock_;
 	omp_set_nested_;
 	omp_set_nested_8_;
 	omp_set_num_threads_;
 	omp_set_num_threads_8_;
-	omp_test_lock_;
-	omp_test_nest_lock_;
-	omp_unset_lock_;
-	omp_unset_nest_lock_;
   local:
 	*;
 };