public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/60936] New: Binary code bloat with std::string
@ 2014-04-23 11:10 d.v.a at ngs dot ru
  2014-04-23 12:12 ` [Bug libstdc++/60936] " d.v.a at ngs dot ru
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: d.v.a at ngs dot ru @ 2014-04-23 11:10 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60936

            Bug ID: 60936
           Summary: Binary code bloat with std::string
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: d.v.a at ngs dot ru

Test program:

#include<string>
int hello()
{
    std::string st("abc");
    return st.length();
}


Build:

$ g++ -shared -fPIC -static-libgcc -static-libstdc++ -Wl,-s -o $@ $?


Sizes of result:

gcc-4_7-string.so: 171744
gcc-4_8-string.so: 185808
gcc-4_9-string.so: 635960


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/60936] Binary code bloat with std::string
  2014-04-23 11:10 [Bug libstdc++/60936] New: Binary code bloat with std::string d.v.a at ngs dot ru
@ 2014-04-23 12:12 ` d.v.a at ngs dot ru
  2014-04-23 12:37 ` d.v.a at ngs dot ru
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: d.v.a at ngs dot ru @ 2014-04-23 12:12 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60936

--- Comment #1 from __vic <d.v.a at ngs dot ru> ---
If we use iostream classes (without std::string) the difference isn't so
dramatic:

4.7: 800320
4.8: 838944
4.9: 868664

May be it's connected with locales? Has std::string any dependences on it in
4.9?


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/60936] Binary code bloat with std::string
  2014-04-23 11:10 [Bug libstdc++/60936] New: Binary code bloat with std::string d.v.a at ngs dot ru
  2014-04-23 12:12 ` [Bug libstdc++/60936] " d.v.a at ngs dot ru
@ 2014-04-23 12:37 ` d.v.a at ngs dot ru
  2014-07-17 10:00 ` [Bug libstdc++/60936] [4.9 Regression] " d.v.a at ngs dot ru
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: d.v.a at ngs dot ru @ 2014-04-23 12:37 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60936

--- Comment #2 from __vic <d.v.a at ngs dot ru> ---
Non-stripped binary built with 4.9 has many symbols from locale. 4.8 - doesn't.
How std::string uses locales???


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/60936] [4.9 Regression] Binary code bloat with std::string
  2014-04-23 11:10 [Bug libstdc++/60936] New: Binary code bloat with std::string d.v.a at ngs dot ru
  2014-04-23 12:12 ` [Bug libstdc++/60936] " d.v.a at ngs dot ru
  2014-04-23 12:37 ` d.v.a at ngs dot ru
@ 2014-07-17 10:00 ` d.v.a at ngs dot ru
  2014-07-19  9:57 ` redi at gcc dot gnu.org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: d.v.a at ngs dot ru @ 2014-07-17 10:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60936

__vic <d.v.a at ngs dot ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Binary code bloat with      |[4.9 Regression] Binary
                   |std::string                 |code bloat with std::string
      Known to fail|                            |4.9.0, 4.9.1

--- Comment #3 from __vic <d.v.a at ngs dot ru> ---
4.9.1 - same results


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/60936] [4.9 Regression] Binary code bloat with std::string
  2014-04-23 11:10 [Bug libstdc++/60936] New: Binary code bloat with std::string d.v.a at ngs dot ru
                   ` (2 preceding siblings ...)
  2014-07-17 10:00 ` [Bug libstdc++/60936] [4.9 Regression] " d.v.a at ngs dot ru
@ 2014-07-19  9:57 ` redi at gcc dot gnu.org
  2014-07-19 10:32 ` redi at gcc dot gnu.org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2014-07-19  9:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60936

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The __throw_range_error_fmt function added to basic_string::at() depends on
locales.

We could avoid that dependency when the library is configured with
--disable-libstdcxx-verbose


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/60936] [4.9 Regression] Binary code bloat with std::string
  2014-04-23 11:10 [Bug libstdc++/60936] New: Binary code bloat with std::string d.v.a at ngs dot ru
                   ` (3 preceding siblings ...)
  2014-07-19  9:57 ` redi at gcc dot gnu.org
@ 2014-07-19 10:32 ` redi at gcc dot gnu.org
  2014-11-19 13:27 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2014-07-19 10:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60936

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Alternatively, we could just move the __int_to_char instantiations to a
separate file from the locale facets.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/60936] [4.9 Regression] Binary code bloat with std::string
  2014-04-23 11:10 [Bug libstdc++/60936] New: Binary code bloat with std::string d.v.a at ngs dot ru
                   ` (4 preceding siblings ...)
  2014-07-19 10:32 ` redi at gcc dot gnu.org
@ 2014-11-19 13:27 ` rguenth at gcc dot gnu.org
  2015-04-15 11:36 ` [Bug libstdc++/60936] [4.9/5 " d.v.a at ngs dot ru
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-11-19 13:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60936

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.9.3


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/60936] [4.9/5 Regression] Binary code bloat with std::string
  2014-04-23 11:10 [Bug libstdc++/60936] New: Binary code bloat with std::string d.v.a at ngs dot ru
                   ` (5 preceding siblings ...)
  2014-11-19 13:27 ` rguenth at gcc dot gnu.org
@ 2015-04-15 11:36 ` d.v.a at ngs dot ru
  2015-04-15 11:38 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: d.v.a at ngs dot ru @ 2015-04-15 11:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60936

--- Comment #6 from __vic <d.v.a at ngs dot ru> ---
5.1-RC (gcc-5.1.0-RC-20150412) - the same problem. Suppose in GCC 6 too?


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/60936] [4.9/5 Regression] Binary code bloat with std::string
  2014-04-23 11:10 [Bug libstdc++/60936] New: Binary code bloat with std::string d.v.a at ngs dot ru
                   ` (6 preceding siblings ...)
  2015-04-15 11:36 ` [Bug libstdc++/60936] [4.9/5 " d.v.a at ngs dot ru
@ 2015-04-15 11:38 ` redi at gcc dot gnu.org
  2015-04-15 11:40 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2015-04-15 11:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60936

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Yes, because nothing has changed in this regard.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/60936] [4.9/5 Regression] Binary code bloat with std::string
  2014-04-23 11:10 [Bug libstdc++/60936] New: Binary code bloat with std::string d.v.a at ngs dot ru
                   ` (7 preceding siblings ...)
  2015-04-15 11:38 ` redi at gcc dot gnu.org
@ 2015-04-15 11:40 ` redi at gcc dot gnu.org
  2015-04-15 13:41 ` [Bug libstdc++/60936] [4.9/5/6 " d.v.a at ngs dot ru
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2015-04-15 11:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60936

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-04-15
   Target Milestone|4.9.3                       |6.0
     Ever confirmed|0                           |1

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I'll try to do something for 6.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/60936] [4.9/5/6 Regression] Binary code bloat with std::string
  2014-04-23 11:10 [Bug libstdc++/60936] New: Binary code bloat with std::string d.v.a at ngs dot ru
                   ` (8 preceding siblings ...)
  2015-04-15 11:40 ` redi at gcc dot gnu.org
@ 2015-04-15 13:41 ` d.v.a at ngs dot ru
  2015-04-23  7:38 ` d.v.a at ngs dot ru
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: d.v.a at ngs dot ru @ 2015-04-15 13:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60936

--- Comment #9 from __vic <d.v.a at ngs dot ru> ---
For 4.9 this change was enough for me:

--- libstdc++-v3/src/c++11/functexcept.cc    2014-01-03 02:30:10.000000000
+0400
+++ libstdc++-v3/src/c++11/functexcept.cc    2014-11-06 18:40:20.000000000
+0300
@@ -89,6 +89,7 @@
   void
   __throw_out_of_range_fmt(const char* __fmt, ...)
   {
+    __throw_out_of_range(__fmt);/*
     const size_t __len = __builtin_strlen(__fmt);
     // We expect at most 2 numbers, and 1 short string. The additional
     // 512 bytes should provide more than enough space for expansion.
@@ -100,6 +101,7 @@
     __gnu_cxx::__snprintf_lite(__s, __alloca_size, __fmt, __ap);
     _GLIBCXX_THROW_OR_ABORT(out_of_range(_(__s)));
     va_end(__ap);  // Not reached.
+*/
   }

   void

But now it doesn't solve the problem.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/60936] [4.9/5/6 Regression] Binary code bloat with std::string
  2014-04-23 11:10 [Bug libstdc++/60936] New: Binary code bloat with std::string d.v.a at ngs dot ru
                   ` (9 preceding siblings ...)
  2015-04-15 13:41 ` [Bug libstdc++/60936] [4.9/5/6 " d.v.a at ngs dot ru
@ 2015-04-23  7:38 ` d.v.a at ngs dot ru
  2015-05-20  8:44 ` meisenmann.lba@fh-salzburg.ac.at
  2015-05-20 11:31 ` redi at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: d.v.a at ngs dot ru @ 2015-04-23  7:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60936

--- Comment #11 from __vic <d.v.a at ngs dot ru> ---
Main problem hides in src/c++11/cow-string-inst.cc here:

namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION

  // These came from c++98/misc-inst.cc, repeat them for COW string
  // string related to iostreams.
  template 
    basic_istream<char>& 
    operator>>(basic_istream<char>&, string&);
  template 
    basic_ostream<char>& 
    operator<<(basic_ostream<char>&, const string&);
  template 
    basic_istream<char>& 
    getline(basic_istream<char>&, string&, char);
  template 
    basic_istream<char>& 
    getline(basic_istream<char>&, string&);

_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

It pulls all iostream + locale.

On the whole, dependences between objects within libstdc++ a organized
terribly. When I just use std::string almost all lib will be linked into my
binary!!! If I remove snippet mentioned above + apply fix from Comment 9 this
set of objects is linked:

condition_variable.o
cow-stdexcept.o
cow-string-inst.o
eh_throw.o
functexcept.o
functional.o
futex.o
future.o
ios_failure.o
regex.o
stdexcept.o
string-inst.o
system_error.o

WHY?! I just want std::string!
I use no futures, no regex, no ios::failure, etc... Is all this stuff realy
necessary for my trivial program?


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/60936] [4.9/5/6 Regression] Binary code bloat with std::string
  2014-04-23 11:10 [Bug libstdc++/60936] New: Binary code bloat with std::string d.v.a at ngs dot ru
                   ` (10 preceding siblings ...)
  2015-04-23  7:38 ` d.v.a at ngs dot ru
@ 2015-05-20  8:44 ` meisenmann.lba@fh-salzburg.ac.at
  2015-05-20 11:31 ` redi at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: meisenmann.lba@fh-salzburg.ac.at @ 2015-05-20  8:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60936

Markus Eisenmann <meisenmann.lba@fh-salzburg.ac.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |meisenmann.lba@fh-salzburg.
                   |                            |ac.at

--- Comment #12 from Markus Eisenmann <meisenmann.lba@fh-salzburg.ac.at> ---
Created attachment 35573
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35573&action=edit
Using __throw_out_of_range (instead of __throw_out_of_range_fmt), if configured
with --disable-libstdcxx-verbose

My patch (file gcc-4.9-pr60936.patch) is a fix/work-around as suggested by
Jonathan in Comment 4. Calling __throw_out_of_range_fmt is replaced by the
(simpler) function __throw_out_of_range(), if the gcc-build is configured with
the option --disable-libstdcxx-verbose.

Note: I have used the previous call to __throw_out_of_range as used in
GCC-release 4.8.4. Maybe the patch has to be applied with the option -p1 (or
change the patch-file), because the path begins with 'gcc-4.9.2/' ...

Following source-files will be changed (by this patch):
 [gcc-4.9.2/] libstdc++-v3/include/bits/basic_string.h
 [gcc-4.9.2/] libstdc++-v3/include/bits/functexcept.h
 [gcc-4.9.2/] libstdc++-v3/include/bits/stl_bvector.h
 [gcc-4.9.2/] libstdc++-v3/include/bits/stl_deque.h
 [gcc-4.9.2/] libstdc++-v3/include/bits/stl_vector.h
 [gcc-4.9.2/] libstdc++-v3/include/debug/array
 [gcc-4.9.2/] libstdc++-v3/include/experimental/string_view
 [gcc-4.9.2/] libstdc++-v3/include/ext/vstring.h
 [gcc-4.9.2/] libstdc++-v3/include/profile/array
 [gcc-4.9.2/] libstdc++-v3/include/std/array
 [gcc-4.9.2/] libstdc++-v3/include/std/bitset
 [gcc-4.9.2/] libstdc++-v3/src/c++11/functexcept.cc
 [gcc-4.9.2/] libstdc++-v3/testsuite/util/exception/safety.h

Best regards,
Markus


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/60936] [4.9/5/6 Regression] Binary code bloat with std::string
  2014-04-23 11:10 [Bug libstdc++/60936] New: Binary code bloat with std::string d.v.a at ngs dot ru
                   ` (11 preceding siblings ...)
  2015-05-20  8:44 ` meisenmann.lba@fh-salzburg.ac.at
@ 2015-05-20 11:31 ` redi at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2015-05-20 11:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60936

--- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Created attachment 35575
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35575&action=edit
Lightweight __throw_out_of_range_fmt for non-verbose builds

This is what I had in mind.


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2015-05-20 11:31 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-23 11:10 [Bug libstdc++/60936] New: Binary code bloat with std::string d.v.a at ngs dot ru
2014-04-23 12:12 ` [Bug libstdc++/60936] " d.v.a at ngs dot ru
2014-04-23 12:37 ` d.v.a at ngs dot ru
2014-07-17 10:00 ` [Bug libstdc++/60936] [4.9 Regression] " d.v.a at ngs dot ru
2014-07-19  9:57 ` redi at gcc dot gnu.org
2014-07-19 10:32 ` redi at gcc dot gnu.org
2014-11-19 13:27 ` rguenth at gcc dot gnu.org
2015-04-15 11:36 ` [Bug libstdc++/60936] [4.9/5 " d.v.a at ngs dot ru
2015-04-15 11:38 ` redi at gcc dot gnu.org
2015-04-15 11:40 ` redi at gcc dot gnu.org
2015-04-15 13:41 ` [Bug libstdc++/60936] [4.9/5/6 " d.v.a at ngs dot ru
2015-04-23  7:38 ` d.v.a at ngs dot ru
2015-05-20  8:44 ` meisenmann.lba@fh-salzburg.ac.at
2015-05-20 11:31 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).