std=c++14 greatly increases debuginfo size. why?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

A colleague of mine noticed that switching from -std=c++11 to -std=c++14
dramatically increased the size of our binary.

After some investigation, this seems to be due to debuginfo.

Consider the following simple example, compiled four different ways:

jscott@citra:~/src/debuginfo-bloat$ cat simple.cpp 
#include <string>

size_t length (const std::string &data)
{
  size_t len = 0;
  for (auto iter = data.cbegin(); iter != data.cend(); iter++)
  {
    len++;
  }

  return len;
}
jscott@citra:~/src/debuginfo-bloat$ g++-6 -gdwarf-4 -std=c++11 -c simple.cpp -o simple-11.o 
jscott@citra:~/src/debuginfo-bloat$ g++-6 -gdwarf-4 -std=c++14 -c simple.cpp -o simple-14.o 
jscott@citra:~/src/debuginfo-bloat$ g++-6 -gdwarf-4 -std=c++11 -c simple.cpp -o simple-11-g1.o -g1
jscott@citra:~/src/debuginfo-bloat$ g++-6 -gdwarf-4 -std=c++14 -c simple.cpp -o simple-14-g1.o -g1
jscott@citra:~/src/debuginfo-bloat$ ls -l simple*o
-rw-rw-r-- 1 jscott jscott   6904 Nov  4 22:25 simple-11-g1.o
-rw-rw-r-- 1 jscott jscott  60192 Nov  4 22:25 simple-11.o
-rw-rw-r-- 1 jscott jscott   6904 Nov  4 22:25 simple-14-g1.o
-rw-rw-r-- 1 jscott jscott 129376 Nov  4 22:25 simple-14.o


So with the default -g2, the C++14 output is almost double that of C++11. But
with -g1 they are the same.

Can someone tell me why this is so? Am I getting much better debuginfo for those
bytes?

The manual doesn't document exactly what -g2 gives over -g1, except that -g1
doesn't include info about local variables (hence I assume -g2 does). I
certainly would like to keep debuginfo for local variables. So I'm pretty sure I
don't want to go down to -g1. Are there any other compromises worth considering
to reduce the binary size here?

Thanks,

John




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux