diff mbox

[libitm,build] Support sun symbol versioning

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

Commit Message

Rainer Orth Nov. 21, 2011, 2:06 p.m. UTC
Symbol versioning support in libitm is currently based on an old version
of the code in libgomp, which doesn't support sun style versioning.  The
following patch corrects this by merging the changes made to libgomp
versioning support since, with the exception of parts that aren't used
in libitm (symbol renaming).  This is yet another copy of that code, and
I still mean to unify all this in one place, but stage 3 isn't the right
time to do so.

I noticed a few issues while testing this patch: 

* libitm.so wasn't versioned even with gld, since libitm_la_LDFLAGS
  wasn't passed when linking it.

* The make_sunver.pl script didn't handle the '?' wildcard in version
  scripts, thus a few symbols in libitm.map were missing from the shared
  object.

* _ITM_getThreadnum is the only symbol in libitm.map that isn't present
  in the library.  It's documented as missing and should perhaps be
  removed from the map?

Bootstrapped without regressions on i386-pc-solaris2.11 with as/ld,
gas/ld, gas/gld, the version info in libitm.so is identical in all 3
cases.  Also bootstrapped on x86_64-unknown-linux-gnu,
i386-pc-solaris2.8 bootstrap in progress, but version info already
identical between S8 and S11.

Ok for mainline?

	Rainer


2011-11-19  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	libitm:
	* acinclude.m4 (LIBITM_CHECK_LINKER_FEATURES): Handle gold.
	(LIBITM_ENABLE_SYMVERS): Handle sun style.
	* Makefile.am: Handle sun style versioning.
	(libitm_la_LINK): Add $(libitm_la_LDFLAGS).
	* configure: Regenerate.
	* Makefile.in: Regenerate.

	contrib:
	* make_sunver.pl: Convert '?' in glob patterns to '.'.

Comments

Richard Henderson Nov. 21, 2011, 4:57 p.m. UTC | #1
On 11/21/2011 06:06 AM, Rainer Orth wrote:
> * libitm.so wasn't versioned even with gld, since libitm_la_LDFLAGS
>   wasn't passed when linking it.

foo_LDFLAGS is supposed to be one of those auto variables that gets used when linking foo.  I know that the library was successfully versioned when I put all that stuff in on the branch...  But, whatever, autotomfoolery is disgustingly fragile.

> * _ITM_getThreadnum is the only symbol in libitm.map that isn't present
>   in the library.  It's documented as missing and should perhaps be
>   removed from the map?

Probably.

> 	libitm:
> 	* acinclude.m4 (LIBITM_CHECK_LINKER_FEATURES): Handle gold.
> 	(LIBITM_ENABLE_SYMVERS): Handle sun style.
> 	* Makefile.am: Handle sun style versioning.
> 	(libitm_la_LINK): Add $(libitm_la_LDFLAGS).
> 	* configure: Regenerate.
> 	* Makefile.in: Regenerate.
> 
> 	contrib:
> 	* make_sunver.pl: Convert '?' in glob patterns to '.'.

Ok.


r~
Michael Matz Nov. 21, 2011, 5:04 p.m. UTC | #2
Hi,

On Mon, 21 Nov 2011, Richard Henderson wrote:

> On 11/21/2011 06:06 AM, Rainer Orth wrote:
> > * libitm.so wasn't versioned even with gld, since libitm_la_LDFLAGS
> >   wasn't passed when linking it.
> 
> foo_LDFLAGS is supposed to be one of those auto variables that gets used 
> when linking foo.

Only if you don't override foo_LINK at the same time, which ...

> I know that the library was successfully versioned when I put all that 
> stuff in on the branch...

... seems to be done after your tests to "Force link with C, not C++."
;-)


Ciao,
Michael.
Torvald Riegel Nov. 21, 2011, 7:35 p.m. UTC | #3
On Mon, 2011-11-21 at 15:06 +0100, Rainer Orth wrote:
> * _ITM_getThreadnum is the only symbol in libitm.map that isn't present
>   in the library.  It's documented as missing and should perhaps be
>   removed from the map?

Yes, this is not supported anymore.

Thanks,
Torvald
Jack Howarth Nov. 21, 2011, 7:50 p.m. UTC | #4
On Mon, Nov 21, 2011 at 08:35:39PM +0100, Torvald Riegel wrote:
> On Mon, 2011-11-21 at 15:06 +0100, Rainer Orth wrote:
> > * _ITM_getThreadnum is the only symbol in libitm.map that isn't present
> >   in the library.  It's documented as missing and should perhaps be
> >   removed from the map?
> 
> Yes, this is not supported anymore.
> 
> Thanks,
> Torvald

  I'm not sure if this patch is the cause, but we seem to have soversion bumped libitm
from 0 to 1 (at least x86_64-apple-darwin11). Is this occuring on other targets and
was it intentional?
       Jack
Richard Henderson Nov. 21, 2011, 7:55 p.m. UTC | #5
On 11/21/2011 11:50 AM, Jack Howarth wrote:
> On Mon, Nov 21, 2011 at 08:35:39PM +0100, Torvald Riegel wrote:
>> On Mon, 2011-11-21 at 15:06 +0100, Rainer Orth wrote:
>>> * _ITM_getThreadnum is the only symbol in libitm.map that isn't present
>>>   in the library.  It's documented as missing and should perhaps be
>>>   removed from the map?
>>
>> Yes, this is not supported anymore.
>>
>> Thanks,
>> Torvald
> 
>   I'm not sure if this patch is the cause, but we seem to have soversion bumped libitm
> from 0 to 1 (at least x86_64-apple-darwin11). Is this occuring on other targets and
> was it intentional?

It was probably due to the version number not being applied previously.


r~
Jack Howarth Nov. 21, 2011, 7:58 p.m. UTC | #6
On Mon, Nov 21, 2011 at 11:55:00AM -0800, Richard Henderson wrote:
> On 11/21/2011 11:50 AM, Jack Howarth wrote:
> > On Mon, Nov 21, 2011 at 08:35:39PM +0100, Torvald Riegel wrote:
> >> On Mon, 2011-11-21 at 15:06 +0100, Rainer Orth wrote:
> >>> * _ITM_getThreadnum is the only symbol in libitm.map that isn't present
> >>>   in the library.  It's documented as missing and should perhaps be
> >>>   removed from the map?
> >>
> >> Yes, this is not supported anymore.
> >>
> >> Thanks,
> >> Torvald
> > 
> >   I'm not sure if this patch is the cause, but we seem to have soversion bumped libitm
> > from 0 to 1 (at least x86_64-apple-darwin11). Is this occuring on other targets and
> > was it intentional?
> 
> It was probably due to the version number not being applied previously.

Richard,
   I asked because we have libssp and libquadmath at 0 so I thought that the initial release of
libitm would soversioned the same way.
                  Jack

> 
> 
> r~
Richard Henderson Nov. 21, 2011, 8:12 p.m. UTC | #7
On 11/21/2011 11:58 AM, Jack Howarth wrote:
>> > It was probably due to the version number not being applied previously.
> Richard,
>    I asked because we have libssp and libquadmath at 0 so I thought that the initial release of
> libitm would soversioned the same way.

Those simply don't seem to define a version number properly:

 ./libitm/configure.ac:libtool_VERSION=1:0:0
 ./libitm/configure.ac:AC_SUBST(libtool_VERSION)
 ./libgo/configure.ac:libtool_VERSION=1:0:0
 ./libgo/configure.ac:AC_SUBST(libtool_VERSION)
 ./libgomp/configure.ac:libtool_VERSION=1:0:0
 ./libgomp/configure.ac:AC_SUBST(libtool_VERSION)



r~
diff mbox

Patch

# HG changeset patch
# Parent 71a5e39a12afc29fc0ed07ce5e822d817c788a49
Support sun symbol versioning

diff --git a/contrib/make_sunver.pl b/contrib/make_sunver.pl
--- a/contrib/make_sunver.pl
+++ b/contrib/make_sunver.pl
@@ -276,9 +276,10 @@  while (<F>) {
     if (/^([ \t]*)([^ \t;{}#]+);?[ \t]*$/) {
 	my $ws = $1;
 	my $ptn = $2;
-	# Turn the glob into a regex by replacing '*' with '.*'.
+	# Turn the glob into a regex by replacing '*' with '.*', '?' with '.'.
 	# Keep $ptn so we can still print the original form.
 	($pattern = $ptn) =~ s/\*/\.\*/g;
+	$pattern =~ s/\?/\./g;
 
 	if ($glob eq 'ign') {
 	    # We're in a local: * section; just continue.
diff --git a/libitm/Makefile.am b/libitm/Makefile.am
--- a/libitm/Makefile.am
+++ b/libitm/Makefile.am
@@ -27,15 +27,33 @@  toolexeclib_LTLIBRARIES = libitm.la
 nodist_toolexeclib_HEADERS = libitm.spec
 
 if LIBITM_BUILD_VERSIONED_SHLIB
+if LIBITM_BUILD_VERSIONED_SHLIB_GNU
 libitm_version_script = -Wl,--version-script,$(top_srcdir)/libitm.map
+libitm_version_dep = $(top_srcdir)/libitm.map
+endif
+if LIBITM_BUILD_VERSIONED_SHLIB_SUN
+libitm_version_script = -Wl,-M,libitm.map-sun
+libitm_version_dep = libitm.map-sun
+libitm.map-sun : $(top_srcdir)/libitm.map \
+		$(top_srcdir)/../contrib/make_sunver.pl \
+		$(libitm_la_OBJECTS) $(libitm_la_LIBADD)
+	perl $(top_srcdir)/../contrib/make_sunver.pl \
+	  $(top_srcdir)/libitm.map \
+	  $(libitm_la_OBJECTS:%.lo=.libs/%.o) \
+	 `echo $(libitm_la_LIBADD) | \
+	    sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
+	 > $@ || (rm -f $@ ; exit 1)
+endif
 else
 libitm_version_script =
+libitm_version_dep =
 endif
 libitm_version_info = -version-info $(libtool_VERSION)
 
 # Force link with C, not C++.  For now, while we're using C++ we don't
 # want or need libstdc++.
-libitm_la_LINK = $(LINK)
+libitm_la_DEPENDENCIES = $(libitm_version_dep)
+libitm_la_LINK = $(LINK) $(libitm_la_LDFLAGS)
 libitm_la_LDFLAGS = $(libitm_version_info) $(libitm_version_script) \
         -no-undefined
 
diff --git a/libitm/acinclude.m4 b/libitm/acinclude.m4
--- a/libitm/acinclude.m4
+++ b/libitm/acinclude.m4
@@ -169,6 +169,7 @@  dnl  OPT_LDFLAGS='-Wl,-O1' if possible
 dnl  LD (as a side effect of testing)
 dnl Sets:
 dnl  with_gnu_ld
+dnl  libitm_ld_is_gold (possibly)
 dnl  libitm_gnu_ld_version (possibly)
 dnl
 dnl The last will be a single integer, e.g., version 1.23.45.0.67.89 will
@@ -200,9 +201,13 @@  AC_DEFUN([LIBITM_CHECK_LINKER_FEATURES],
 
   # Start by getting the version number.  I think the libtool test already
   # does some of this, but throws away the result.
+  libitm_ld_is_gold=no
+  if $LD --version 2>/dev/null | grep 'GNU gold'> /dev/null 2>&1; then
+    libitm_ld_is_gold=yes
+  fi
   changequote(,)
-  ldver=`$LD --version 2>/dev/null | head -1 | \
-         sed -e 's/GNU ld \(version \)\{0,1\}\(([^)]*) \)\{0,1\}\([0-9.][0-9.]*\).*/\3/'`
+  ldver=`$LD --version 2>/dev/null |
+         sed -e 's/GNU gold /GNU ld /;s/GNU ld version /GNU ld /;s/GNU ld ([^)]*) /GNU ld /;s/GNU ld \([0-9.][0-9.]*\).*/\1/; q'`
   changequote([,])
   libitm_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
@@ -300,16 +305,46 @@  AC_DEFUN([LIBITM_ENABLE_SYMVERS], [
 
 LIBITM_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 LIBITM_CHECK_LINKER_FEATURES macro, then we
 # don't know enough about $LD to do tricks...
 AC_REQUIRE([LIBITM_CHECK_LINKER_FEATURES])
-# FIXME  The following test is too strict, in theory.
-if test $enable_shared = no ||
-        test "x$LD" = x ||
-        test x$libitm_gnu_ld_version = x; then
-  enable_symvers=no
+
+# Turn a 'yes' into a suitable default.
+if test x$enable_symvers = xyes ; then
+  # FIXME  The following test is too strict, in theory.
+  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
+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.
@@ -346,12 +381,12 @@  libitm_min_gnu_ld_version=21400
 
 # 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 $libitm_shared_libgcc = yes;
-  then
+if test $enable_symvers != no && test $libitm_shared_libgcc = yes; then
+  if test $with_gnu_ld = yes; then
     if test $libitm_gnu_ld_version -ge $libitm_min_gnu_ld_version ; then
       enable_symvers=gnu
+    elif test $libitm_ld_is_gold = yes ; then
+      enable_symvers=gnu
     else
       # The right tools, the right setup, but too old.  Fallbacks?
       AC_MSG_WARN(=== Linker version $libitm_gnu_ld_version is too old for)
@@ -370,6 +405,8 @@  if test $enable_symvers = yes; then
         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])
@@ -381,5 +418,7 @@  if test $enable_symvers = yes; then
 fi
 
 AM_CONDITIONAL(LIBITM_BUILD_VERSIONED_SHLIB, test $enable_symvers != no)
+AM_CONDITIONAL(LIBITM_BUILD_VERSIONED_SHLIB_GNU, test $enable_symvers = gnu)
+AM_CONDITIONAL(LIBITM_BUILD_VERSIONED_SHLIB_SUN, test $enable_symvers = sun)
 AC_MSG_NOTICE(versioning on shared library symbols is $enable_symvers)
 ])