LTO and -g for nonELF binary

Pavol Gono via Gcc-help <[email protected]> Thu, 15 Jan 2026 22:31:27 +0100
Newsgroups gmane.comp.gcc.help
Message-ID <CAOJUd61s-dT+=ynRQ51iS1y+T2-v3q1CiPko3VgPvXVOdN4E-Q@mail.gmail.com>
Hello
I am compiling C++ binary in the MSYS2+MINGW64 environment (Target:
x86_64-w64-mingw32), using the latest g++ version (15.2+).
I am using the RelWithDebInfo build type, which means options -O2 -g
(eventually -g1).
How risky is the usage of LTO (-flto) in addition? In documentation I read:
Link-time optimization does not work well with generation of debugging
information on systems other than those using a combination of ELF and
DWARF.

Is there a risk of incorrect debugging symbols or anything worse?

Thank you
Pavol