https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86964
--- Comment #6 from Johan.karlsson at enea dot com --- Created attachment 45636 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45636&action=edit Patch to enable skip unused extern variables. I'm attaching a patch that I've been working on. It loops over the variable pool that contains the used global variables. It grabs the declaration and lookup the DIE of the variable and mark it as used. I've also tweaked the function that loops over all dies so that instead of marking every DW_TAG_variable it only marks the ones that are not extern. With this patch we where able to get similar debug information size to GCC 4.9.2. Right now the functionality is only enabled by adding -feliminate-unused-debug-symbols, it could probably always be enable since I don't think any debug information is lost. -fno-eliminate-unused-debug-types should not be set, because if it is the the functionality is disabled. A bit strange but using that in the first place will generate a bunch of extra debug information anyway.