Bug 215317

Summary: Static linking doesn't work together with -Os
Product: [Fedora] Fedora Reporter: Thomas Moschny <thomas.moschny>
Component: boostAssignee: Benjamin Kosnik <bkoz>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6CC: jakub, mnewsome, pmachata, triage
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard: bzcl34nup
Fixed In Version: 6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-04-04 06:55:59 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Thomas Moschny 2006-11-13 14:14:33 UTC
Description of problem:
Trying to link statically e.g. against boost_regexp yields a bunch of linking 
errors, if the program is also optimized for space.

Version-Release number of selected component (if applicable):
gcc-4.1.1-30
binutils-2.17.50.0.3-6
boost-devel-1.33.1-6.1

How reproducible:
Compile and link this code sniplet:

// save as test.cc
#include <boost/regex.hpp>
using namespace boost;
int main () { regex expr("foo"); return 0; }
// snip

Steps to Reproduce:
g++ -Os -o test test.cc -Wl,-Bstatic -lboost_regex -Wl,-Bdynamic
 
Actual results:
`.gnu.linkonce.t._ZN5boost9re_detail18basic_regex_parserIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE20parse_perl_extensionEv' 
referenced in section 
`.gnu.linkonce.r._ZN5boost9re_detail18basic_regex_parserIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE20parse_perl_extensionEv' 
of /usr/lib/gcc/i386-redhat-linux/4.1.1/../../../libboost_regex.a(instances.o): 
defined in discarded section 
`.gnu.linkonce.t._ZN5boost9re_detail18basic_regex_parserIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE20parse_perl_extensionEv' 
of /usr/lib/gcc/i386-redhat-linux/4.1.1/../../../libboost_regex.a(instances.o)
`.gnu.linkonce.t._ZN5boost9re_detail18basic_regex_parserIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE20parse_perl_extensionEv' 
referenced in section 
`.gnu.linkonce.r._ZN5boost9re_detail18basic_regex_parserIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE20parse_perl_extensionEv' 
of /usr/lib/gcc/i386-redhat-linux/4.1.1/../../../libboost_regex.a(instances.o): 
defined in discarded section 
`.gnu.linkonce.t._ZN5boost9re_detail18basic_regex_parserIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE20parse_perl_extensionEv' 
of /usr/lib/gcc/i386-redhat-linux/4.1.1/../../../libboost_regex.a(instances.o)
`.gnu.linkonce.t._ZN5boost9re_detail18basic_regex_parserIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE20parse_perl_extensionEv' 
referenced in section 
`.gnu.linkonce.r._ZN5boost9re_detail18basic_regex_parserIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE20parse_perl_extensionEv' 
of /usr/lib/gcc/i386-redhat-linux/4.1.1/../../../libboost_regex.a(instances.o): 
defined in discarded section 
`.gnu.linkonce.t._ZN5boost9re_detail18basic_regex_parserIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE20parse_perl_extensionEv' 
of /usr/lib/gcc/i386-redhat-linux/4.1.1/../../../libboost_regex.a(instances.o)
[...removed many similar messages...]
collect2: ld returned 1 exit status
Error 1

Additional info:
This seems to be a regression. There are various bug reports on the net 
showing that this might be a gcc bug uncovered by newer binutils, however 
these reports are against gcc 3.X, so I'm not sure if this is relevant here.

Comment 1 Benjamin Kosnik 2006-11-15 18:50:39 UTC
Jakub this still happens on FC6 with the latest packages. I rebuilt
boost-1.33.1-9 from cvs/boost/devel in dist-fc7, but don't know how to get onto
an active rawhide host to test with the rebuilt package, sorry.

I am also curious.

Comment 2 Benjamin Kosnik 2006-11-15 18:55:50 UTC
Rebuilt package + binutils with the HAVE_COMDAT_GROUPS fix, I mean.

Comment 3 Jakub Jelinek 2006-12-19 15:32:43 UTC
The testcase works with:
gcc-4.1.1-44
boost-devel-1.33.1-10.fc7
(rawhidish) while doesn't work with
gcc-4.1.1-30
boost-devel-1.33.1-6.1
(FC6ish), so I think this is very likely the configury problem with parsing FC6
binutils ld --version that caused HAVE_COMDAT_GROUP not to be defined in
gcc < 4.1.1-33.


Comment 4 Jakub Jelinek 2006-12-21 21:00:26 UTC
gcc-4.1.1-47.fc6 is now in FC6 testing updates, once it is moved over to
final and boost in FC6 is rebuilt with it, this bug should be fixed.

Comment 5 Jakub Jelinek 2007-01-17 10:31:55 UTC
Now that gcc has been officially updated in FC6, boost needs rebuilding and
this problem should go away.

Comment 6 Benjamin Kosnik 2007-01-22 10:57:19 UTC
Jakub, should I just rebuild FC6 boost-1.33.1-10?

Comment 7 Thomas Moschny 2007-04-12 07:11:23 UTC
Seems to work using these packages:

binutils-2.17.50.0.6-2.fc6
gcc-[c++-]4.1.1-51.fc6
boost-devel-1.33.1-11.fc6

Comment 8 Bug Zapper 2008-04-04 04:39:14 UTC
Fedora apologizes that these issues have not been resolved yet. We're
sorry it's taken so long for your bug to be properly triaged and acted
on. We appreciate the time you took to report this issue and want to
make sure no important bugs slip through the cracks.

If you're currently running a version of Fedora Core between 1 and 6,
please note that Fedora no longer maintains these releases. We strongly
encourage you to upgrade to a current Fedora release. In order to
refocus our efforts as a project we are flagging all of the open bugs
for releases which are no longer maintained and closing them.
http://fedoraproject.org/wiki/LifeCycle/EOL

If this bug is still open against Fedora Core 1 through 6, thirty days
from now, it will be closed 'WONTFIX'. If you can reporduce this bug in
the latest Fedora version, please change to the respective version. If
you are unable to do this, please add a comment to this bug requesting
the change.

Thanks for your help, and we apologize again that we haven't handled
these issues to this point.

The process we are following is outlined here:
http://fedoraproject.org/wiki/BugZappers/F9CleanUp

We will be following the process here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping to ensure this
doesn't happen again.

And if you'd like to join the bug triage team to help make things
better, check out http://fedoraproject.org/wiki/BugZappers