# DP: Make LTO link pick up compile-time -g (documentation) https://gcc.gnu.org/ml/gcc-patches/2019-09/msg00501.html 2019-09-09 Richard Biener * lto-opts.c (lto_write_options): Stream -g when debug is enabled. * lto-wrapper.c (merge_and_complain): Pick up -g. (append_compiler_options): Likewise. (run_gcc): Re-instantiate handling -g0 at link-time. * doc/invoke.texi (flto): Document debug info generation. --- a/src/gcc/doc/invoke.texi +++ b/src/gcc/doc/invoke.texi @@ -10335,6 +10335,14 @@ conflicting translation units. Specific precedence; and for example @option{-ffp-contract=off} takes precedence over @option{-ffp-contract=fast}. You can override them at link time. +To enable debug info generation you need to supply @option{-g} at +compile-time. If any of the input files at link time were built +with debug info generation enabled the link will enable debug info +generation as well. Any elaborate debug info settings +like the dwarf level @option{-gdwarf-5} need to be explicitely repeated +at the linker command line and mixing different settings in different +translation units is discouraged. + If LTO encounters objects with C linkage declared with incompatible types in separate translation units to be linked together (undefined behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be