gcc configure option explanations

1.2k views Asked by At

I want to investigate a way for my other question (gcc: Strip unused functions) by building the latest gcc 6.3.0.

There are some options from https://gcc.gnu.org/install/configure.html and https://gcc.gnu.org/onlinedocs/libstdc++/manual/configure.html that I would like to try, but don't understand what they meant.

Specifically, these are the flags I want to try:

  • --disable-libstdcxx-verbose: I rarely use exceptions so I am not very familiar with how it works. I have never seen the "verbose messages" it mentioned before.
  • --enable-linker-build-id and --enable-gnu-unique-object: Simply don't understand what the explanations are trying to say. What are the benefits exactly?
  • --enable-cxx-flags="-ffunction-sections -fstrict-aliasing -fno-exceptions": If I use -fno-exceptions in libstdc++, doesn't that means I get no exceptions if I use libstdc++? -ffunction-sections is used, but where to put -Wl,-gc-sections?

Although I always use --enable-lto, but with ld.bfd, it seems to be quite useless compared to the famous gold linker.

If you have more flags you think I should try, please let me know!

1

There are 1 answers

3
yugr On BEST ANSWER

--disable-libstdcxx-verbose: I rarely use exceptions so I am not very familiar with how it works. I have never seen the "verbose messages" it mentioned before.

+1, you normally don't run into errors which trigger these friendly error messages you can avoid paying for them.

--enable-linker-build-id and --enable-gnu-unique-object: Simply don't understand what the explanations are trying to say. What are the benefits exactly?

There are none.

Unique objects is a badly designed feature that prevents shared libraries which contain references to globally used objects (usually vtables) from unloading on dlclose. AFAIR it's enabled by default (as it's needed to simulate C++ semantics in shared libs environment).

Build id is needed to support separate debuginfo.

--enable-cxx-flags="-ffunction-sections -fstrict-aliasing -fno-exceptions":

You won't benefit from -fstrict-aliasing as it's enabled at -O2 and higher by default.

-ffunction-sections is used, but where to put -Wl,-gc-sections?

To --enable-cxx-flags as well (note that it wants double-dash i.e. -Wl,--gc-sections).

Although I always use --enable-lto, but with ld.bfd, it seems to be quite useless compared to the famous gold linker.

This flags simply enables LTO support in GCC (it's actually equivalent to adding lto to --enable-languages). It won't cause any difference unless you enable -flto in CXXFLAGS as well. Keep in mind that LTO will normally increase executable size (as compiler will have more opportunities for inlining).

If you have more flags you think I should try, please let me know!

Speaking of size reduction, I'd say -ffunction-sections is your best bet (be sure to verify that configure machinery passes all options correctly and libstdc++.a indeed has one section per function). You could also add -fdata-sections.