This seemingly innocuous change 2019-09-11 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. caused PR 91763, a test failure building Go code with -flto. The problem only arose when using the GNU assembler on Solaris. The bug is that when emitting debug info but not exception info, and when using gas, the DWARF code will emit .cfi_sections .debug_frame This will direct gas to emit unwind info into .debug_frame but not .eh_frame. Go code requires unwind info, and the Go library expects it to be in .eh_frame. The Go frontend always turns on exceptions, so this .cfi_sections directive is not used. However, when using -flto, the lto1 program decides whether it is using exceptions based on what it reads from the input files. Before lto1 sees any input files, flag_exceptions will have its default value of 0. And lto1 initializes the debug info before seeing any input files, so the debug initialization thinks that exceptions are not in use, and emits the .cfi_sections directive. This problem was uncovered by the above patch because Go code also turns on debugging by default, and so lto1 now sees a -g option that it did not see before. This patch fixes the problem by moving the emission of .cfi_sections from debug init to the first time that the debug info needs to know whether CFI is supported. This is only done when actually emitting debug info, and therefore after some input files have been read. Bootstrapped and ran full testsuite on x86_64-pc-linux-gnu. Tested that formerly failing case now passes on sparc-sun-solaris2.11. OK for trunk? Ian 2019-09-17 Ian Lance Taylor PR go/91763 * dwarf2out.c (dwarf2out_assembly_start): Move ".cfi_sections .debug_frame" output from here... * dwarf2cfi.c (dwarf2out_do_cfi_asm): ...to here.