https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64504
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Andrey Vihrov from comment #0) > -fwhole-program is that it can be used with one source file that includes > standard library headers and links with the standard library. If this is > wrong, then I'm sorry for filing a bogus bug report. I don't know if it's supposed to work (I would expect not), but using -fwhole-program with _GLIBCXX_DEBUG seems silly to me. The Debug Mode macro can slow things down by an order of magnitude, so the advantages of -fwhole-program will be minimal anyway. Is there a reason you can't use -flto instead?