This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Support Sun symbol versioning in libgomp


After the basic support for Sun symbol versioning in libstdc++ was in
place

	PATCH: Support Sun symbol versioning in libstdc++-v3
        http://gcc.gnu.org/ml/gcc-patches/2010-02/msg01001.html

support for libgomp fell in easily, with one exception:

As mentioned in that message, Sun ld doesn't support .symver symbol
renaming and chokes when the same symbol shows up in a mapfile twice.
libgomp is affected by this, so I've grouped the affected symbols into a
single block in libgomp.map, surrounded by comments which look like
cpp conditionals, but are just delimiters for an sed one liner to remove
that group if Sun symbol versioning is in use.

The rest should be pretty obvious.

Tested by comparing the pvs -dsvo output of libgomp.so on
i386-pc-solaris2.11 after bootstraps with Sun ld and GNU ld, finding
only the expected differences (Solaris 2 ABI symbols in the base
version, .symver renamed symbols).

Ok for mainline once 4.5 has branched?

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2010-02-22  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* acinclude.m4 (LIBGOMP_ENABLE_SYMVERS): Handle sun style.
	Define LIBGOMP_BUILD_VERSIONED_SHLIB_GNU,
	LIBGOMP_BUILD_VERSIONED_SHLIB_SUN automake conditionals.
	* configure: Regenerate.

	* Makefile.am [LIBGOMP_BUILD_VERSIONED_SHLIB]: Protect
	libgomp_version_script with LIBGOMP_BUILD_VERSIONED_SHLIB_GNU.
	Add libgomp_version_dep.
	[LIBGOMP_BUILD_VERSIONED_SHLIB_SUN]: Handle Sun symbol
	versioning.
	[!LIBGOMP_BUILD_VERSIONED_SHLIB]: Add libgomp_version_dep.
	(libgomp_la_DEPENDENCIES): Set to $(libgomp_version_dep).
	* Makefile.in: Regenerate.

	* libgomp.map (OMP_1.0): Move symbols both in OMP_1.0 and OMP_3.0
	to common block, protected by LIBGOMP_GNU_SYMBOL_VERSIONING.

diff -r d78468191df9 -r 4dd4686c4f58 libgomp/Makefile.am
--- a/libgomp/Makefile.am	Mon Feb 22 20:34:56 2010 +0100
+++ b/libgomp/Makefile.am	Mon Feb 22 20:34:56 2010 +0100
@@ -22,13 +22,35 @@
 nodist_toolexeclib_HEADERS = libgomp.spec
 
 if LIBGOMP_BUILD_VERSIONED_SHLIB
+if LIBGOMP_BUILD_VERSIONED_SHLIB_GNU
 libgomp_version_script = -Wl,--version-script,$(top_srcdir)/libgomp.map
+libgomp_version_dep = $(top_srcdir)/libgomp.map
+endif
+if LIBGOMP_BUILD_VERSIONED_SHLIB_SUN
+libgomp_version_script = -Wl,-M,libgomp.map-sun
+libgomp_version_dep = libgomp.map-sun
+# Remove LIBGOMP_GNU_SYMBOL_VERSIONING block in libgomp.map; Sun ld chokes
+# if it encounters the same symbol in multiple versions.
+libgomp.map-sun : $(top_srcdir)/libgomp.map \
+		$(top_srcdir)/../contrib/make_sunver.pl \
+		$(libgomp_la_OBJECTS) $(libgomp_la_LIBADD)
+	sed -e '/^#ifdef LIBGOMP_GNU_SYMBOL_VERSIONING/,/^#endif/d' \
+	  $(top_srcdir)/libgomp.map > libgomp.map
+	perl $(top_srcdir)/../contrib/make_sunver.pl \
+	  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 d78468191df9 -r 4dd4686c4f58 libgomp/acinclude.m4
--- a/libgomp/acinclude.m4	Mon Feb 22 20:34:56 2010 +0100
+++ b/libgomp/acinclude.m4	Mon Feb 22 20:34:56 2010 +0100
@@ -223,16 +223,43 @@
 
 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
+      solaris2*)
+	# Sun symbol versioning exists since at least Solaris 2.5, so for
+	# our purposes, for all supported Solaris 2 releases.
+	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 +296,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 +320,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 +343,7 @@
 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)
 ])
diff -r d78468191df9 -r 4dd4686c4f58 libgomp/libgomp.map
--- a/libgomp/libgomp.map	Mon Feb 22 20:34:56 2010 +0100
+++ b/libgomp/libgomp.map	Mon Feb 22 20:34:56 2010 +0100
@@ -10,6 +10,10 @@
 	omp_get_dynamic;
 	omp_set_nested;
 	omp_get_nested;
+#ifdef LIBGOMP_GNU_SYMBOL_VERSIONING
+        # 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:
 	*;
 };


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]