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 <r...@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 '.'.
# 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) ])
-- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University