Bug 54173 - -D_GLIBCXX_DEBUG breaks string::_Rep::_S_empty_rep_storage weak binding.
Summary: -D_GLIBCXX_DEBUG breaks string::_Rep::_S_empty_rep_storage weak binding.
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.7.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-04 14:10 UTC by Pawel Sikora
Modified: 2014-06-13 16:12 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-08-04 00:00:00


Attachments
testcase (487 bytes, application/x-gzip)
2012-08-04 14:10 UTC, Pawel Sikora
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pawel Sikora 2012-08-04 14:10:56 UTC
Created attachment 27937 [details]
testcase

hi,
afaics, the libstdc++ debug machinery breaks some (at least static weak)
symbols binding which causes various runtime problems.

here's the testcase:

/* good */

$ LANG=C make
g++ -Wall l.cpp -fPIC -shared -o l.so -g0 -s -O1 -Wl,--version-script=l.lds -std=gnu++11
readelf -sW l.so | grep storage
    10: 0000000000000000     0 OBJECT  UNIQUE DEFAULT  UND _ZNSs4_Rep20_S_empty_rep_storageE@GLIBCXX_3.4 (2)

/* bad */

$ LANG=C make CPPFLAGS=-D_GLIBCXX_DEBUG
g++ -Wall l.cpp -fPIC -shared -o l.so -g0 -s -O1 -Wl,--version-script=l.lds -std=gnu++11 -D_GLIBCXX_DEBUG
readelf -sW l.so | grep storage
make: *** [all] Error 1
Comment 1 Paolo Carlini 2012-08-04 14:55:37 UTC
For sure, nothing changed in this area for years and years, thus must be a compiler issue. Please try to figure when it started...
Comment 2 Pawel Sikora 2012-08-04 16:13:03 UTC
(In reply to comment #1)
> For sure, nothing changed in this area for years and years, thus must be a
> compiler issue. Please try to figure when it started...

i have similar effects for 4.5/4.6/4.7/4.8 with my .lds script.
afaics in the assembly code, the non-debug (good) version only references
external _S_empty_rep_storage symbol while the debug (broken) version
defines the _S_empty_rep_storage symbol as weak/gnu-unique.
Comment 3 Paolo Carlini 2012-08-04 16:49:36 UTC
Well, whatever it is, if the problem is so old, I think we have a WONTFIX at this point, because std::string will be completely different in C++11.
Comment 4 Pawel Sikora 2014-06-13 16:12:28 UTC
currently i'm using a gcc configured with --disable-gnu-unique-object,
--disable-initfini-array (not supported by ld.so on older *enterprise*
redhat/suse distros) and --with-linker-hash-style=both (.gnu.hash section
w/o sysv .hash causes divide by 0 inside older ld.so).

finally, i'm building my application with -fms-compat-visiblity
and explicite __attribute__((visibility("default"))) exports instead
of tricky linker scripts. such options give me pretty portable binaries
(works well on rhel5, rhel6, suse11).