4.12 Methods of reducing debug information in objects and libraries
There are a number of ways to reduce the amount of debug information being generated per source file.
For example, you can:
Avoid conditional use of
#define in header files. This might make it
more difficult for the linker to eliminate duplicate information.
Modify your C or C++ source files so that header files are
in the same order.
Partition header information into smaller blocks. That is, use a larger number of
smaller header files rather than a smaller number of larger header files. This helps the
linker to eliminate more of the common blocks.
Only include a header file in a C or C++ source file if it is really
Guard against the multiple inclusion of header files. Place multiple-inclusion guards
inside the header file, rather than around the
#include statement. For
example, if you have a header file foo.h, add:
// rest of header file as before
#endif /* foo_h */
You can use the compiler option
--remarks to warn about unguarded
Compile your code with the
--no_debug_macros command-line option to
discard preprocessor macro definitions from debug tables.
Consider using (or not using)
--remove_unneeded_entities can help to reduce the amount of
debug information generated per file, it has the disadvantage of reducing the number
of debug sections that are common to many files. This reduces the number of common
debug sections that the linker is able to remove at final link time, and can result in
a final debug image that is larger than necessary. For this reason, use
--remove_unneeded_entities only when necessary.