Bug 38923 - symbol versioning disabled due to non-portable sed script
Summary: symbol versioning disabled due to non-portable sed script
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.3.3
: P3 normal
Target Milestone: 4.5.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 41333 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-01-20 15:54 UTC by Jonathan Wakely
Modified: 2009-12-15 17:04 UTC (History)
5 users (show)

See Also:
Host: ultrasparc3-sun-solaris2.10
Target: ultrasparc3-sun-solaris2.10
Build: ultrasparc3-sun-solaris2.10
Known to work: 4.5.0
Known to fail:
Last reconfirmed: 2009-09-19 11:38:09


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2009-01-20 15:54:55 UTC
libstdc++-v3/configure contains this:

    ldver=`$LD --version 2>/dev/null | head -1 | \
           sed -e 's/GNU \(go\)\{0,1\}ld \(version \)\{0,1\}\(([^)]*) \)\{0,1\}\([0-9.][0-9.]*\).*/\4/'`

that sed script fails with /usr/bin/sed on Solaris, disabling symbol versioning.

Here's an example of what I get:

++ /sbcimp/run/pd/binutils/32-bit/2.18/bin/ld --version
++ head -1
++ sed -e 's/GNU ld \(version \)\{0,1\}\(([^)]*) \)\{0,1\}\([0-9.][0-9.]*\).*/\3/'
+ ldver='GNU ld (GNU Binutils) 2.18'
++ echo GNU ld '(GNU' 'Binutils)' 2.18
++ nawk -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'
+ glibcxx_gnu_ld_version=1800

This leads to:

configure: WARNING: === Linker version 1800 is too old for 
configure: WARNING: === full symbol versioning support in this release of GCC. 
configure: WARNING: === You would need to upgrade your binutils to version 
configure: WARNING: === 21400 or later and rebuild GCC. 
configure: WARNING: === Symbol versioning will be disabled. 
configure: versioning on shared library symbols is no 

Could be fixed by requiring a POSIX sed, or by using awk to select the version (we already require POSIX awk)
Comment 1 Jonathan Wakely 2009-01-20 15:58:02 UTC
should "head -1" also be replaced by "head -n 1" or is that less portable?
Comment 2 Paolo Carlini 2009-01-20 17:02:11 UTC
(In reply to comment #1)
> should "head -1" also be replaced by "head -n 1" or is that less portable?

Isn't this a very old issue? I think you will find a straightforward answer / rationale in the archive, or, in other terms, I think we don't want ot change the current practice...
Comment 3 Jonathan Wakely 2009-01-20 17:17:17 UTC
then http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt01ch02.html#manual.intro.setup.prereq should be updated to say a POSIX sed is required.
Comment 4 Jonathan Wakely 2009-01-20 17:18:28 UTC
oh sorry, Paolo, did you only mean the "head" part?  I'm not too concerned about that bit, it works everywhere I care about, even if POSIX says otherwise
Comment 5 Paolo Carlini 2009-01-20 17:29:10 UTC
Yes, I only meant the "head -1" vs "head -n 1" part.
Comment 6 Benjamin Kosnik 2009-01-20 18:50:11 UTC
This code block appears to be capable of generating no end of issues, sadly.

For the record, POSIX head docs say -n is a requirement for conformance, at least p.2791 of EEE Std 1003.1-2008. Of course, who knows if all platforms support it. 

I don't see how s/head -1/head -n 1/ will fix the solaris symbol versioning configure error though.

FYI, libgomp also does much the same thing and we're trying to keep this stuff in sync so you'll need to do the equivalent thing to libgomp/acinclude.m4's LIBGOMP_CHECK_LINKER_FEATURES. 

Comment 7 Jonathan Wakely 2009-01-20 19:07:30 UTC
I've just noticed that the libgomp configure says:

 configure: versioning on shared library symbols is gnu

even though it seems to have the same sed script as libstdc++, which says:

 configure: WARNING: === Linker version 1800 is too old for
 configure: WARNING: === full symbol versioning support in this release of GCC.
 configure: WARNING: === You would need to upgrade your binutils to version
 configure: WARNING: === 21400 or later and rebuild GCC.
 configure: WARNING: === Symbol versioning will be disabled.
 configure: versioning on shared library symbols is no

I can't do aanother test until tomorrow now, but I'll try to verify if libgomp really does get it right, and if so, how.
Comment 8 Jonathan Wakely 2009-01-21 12:21:39 UTC
Not sure what happened yesterday, but I get the same result for both libgomp and libstdc++ today: both interpret the GNU ld version as 1800
Comment 9 David Fang 2009-03-07 20:25:56 UTC
I usually set the environment variable POSIXLY_CORRECT when I want to catch portability issues.  The GNU versions of the utils are usually good about disabling extensions and griping about violations.  
Comment 10 Jonathan Wakely 2009-06-19 15:31:43 UTC
I've just noticed this bit of install.texi:

The build process works more smoothly with the legacy Sun tools so, if you
have @file{/usr/xpg4/bin} in your @env{PATH}, we recommend that you place
@file{/usr/bin} before @file{/usr/xpg4/bin} for the duration of the build.

That directly contradicts my experience with this bug, which is that you must have /usr/xpg4/bin/sed earlier in your path than /usr/bin/sed in order to get symbol versioning in libstdc++
Comment 11 Ralf Wildenhues 2009-09-23 04:22:48 UTC
patch at <http://gcc.gnu.org/ml/gcc-patches/2009-09/msg01599.html>.
Comment 12 Ralf Wildenhues 2009-09-30 00:43:50 UTC
Subject: Bug 38923

Author: rwild
Date: Wed Sep 30 00:43:28 2009
New Revision: 152315

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=152315
Log:
sed and head portability fixes in ld version check.

libstdc++-v3/:
	PR libstdc++/38923
	* acinclude.m4 (GLIBCXX_CHECK_LINKER_FEATURES): Avoid 'head',
	use sed script portable to Solaris /bin/sed for extracting ld
	version.
	* configure: Regenerate.

libgomp/:
	* acinclude.m4 (LIBGOMP_CHECK_LINKER_FEATURES): Avoid 'head',
	use sed script portable to Solaris /bin/sed for extracting ld
	version.
	* configure: Regenerate.

Modified:
    trunk/libgomp/ChangeLog
    trunk/libgomp/acinclude.m4
    trunk/libgomp/configure
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/acinclude.m4
    trunk/libstdc++-v3/configure

Comment 13 Ralf Wildenhues 2009-09-30 00:44:59 UTC
Fixed on trunk.
Comment 14 Jonathan Wakely 2009-10-05 11:30:06 UTC
*** Bug 41333 has been marked as a duplicate of this bug. ***
Comment 15 Jakub Jelinek 2009-10-26 20:28:38 UTC
Subject: Bug 38923

Author: jakub
Date: Mon Oct 26 20:28:24 2009
New Revision: 153570

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153570
Log:
	PR libstdc++/38923
	* acinclude.m4 (GLIBCXX_CHECK_LINKER_FEATURES): Avoid using too many
	*s.  Accept ld version without text in ()s.
	* configure: Regenerated.

	* acinclude.m4 (LIBGOMP_CHECK_LINKER_FEATURES): Avoid using too many
	*s.  Accept ld version without text in ()s.
	* configure: Regenerated.

Modified:
    trunk/libgomp/ChangeLog
    trunk/libgomp/acinclude.m4
    trunk/libgomp/configure
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/acinclude.m4
    trunk/libstdc++-v3/configure

Comment 16 Jeffrey A. Law 2009-10-29 16:38:07 UTC
Subject: Bug 38923

Author: law
Date: Thu Oct 29 16:37:47 2009
New Revision: 153711

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153711
Log:
Recorded merge of revisions 153568-153570 via svnmerge from 
svn+ssh://law@gcc.gnu.org/svn/gcc/trunk

........
  r153568 | jakub | 2009-10-26 14:18:26 -0600 (Mon, 26 Oct 2009) | 10 lines
  
  	PR debug/41828
  	* cp-lang.c (cxx_dwarf_name): Return NULL instead of
  	<anonymous ...> for anonymous aggregate names.
  
  	* dwarf2out.c (add_pubname, add_pubtype, generic_parameter_die,
  	add_name_and_src_coords_attributes, gen_namespace_die,
  	dwarf2out_set_name): Handle dwarf2_name returning NULL.
  
  	* g++.dg/debug/dwarf2/anonname1.C: New test.
........
  r153569 | jakub | 2009-10-26 14:21:09 -0600 (Mon, 26 Oct 2009) | 6 lines
  
  	PR bootstrap/41345
  	* cfgcleanup.c (trivially_empty_bb_p): New function.
  	(try_optimize_bb): Use it instead of checking BB_HEAD == BB_END.
  
  	* gcc.dg/pr41345.c: New test.
........
  r153570 | jakub | 2009-10-26 14:28:24 -0600 (Mon, 26 Oct 2009) | 9 lines
  
  	PR libstdc++/38923
  	* acinclude.m4 (GLIBCXX_CHECK_LINKER_FEATURES): Avoid using too many
  	*s.  Accept ld version without text in ()s.
  	* configure: Regenerated.
  
  	* acinclude.m4 (LIBGOMP_CHECK_LINKER_FEATURES): Avoid using too many
  	*s.  Accept ld version without text in ()s.
  	* configure: Regenerated.
........

Modified:
    branches/reload-v2a/   (props changed)

Propchange: branches/reload-v2a/
            ('svnmerge-integrated' modified)


Comment 17 Ralf Wildenhues 2009-11-02 17:48:15 UTC
unassigning; fixed for 4.5 by Jakub.
Comment 18 Paolo Carlini 2009-12-15 17:04:58 UTC
I'm closing this as fixed for 4.5.0.