https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101473
--- Comment #19 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think it is a bug - -fdebug-prefix-map should be fully reflected in the LTO
IL and thus we should not end up creating un-remapped references to files (we
should not create many references to files late anyway).
In particular we're remapping all files when streaming locations to LTO. But
yes, we're explicitely _not_ streaming the -f*-prefix-map arguments since
we'd have a hard time using them when they do not agree between TUs.
Your lto-test shows the difference is in the LTRANS DWARF CU header:
@@ -215,7 +215,7 @@
<9b> DW_AT_producer : (indirect string, offset: 0x1c7): GNU GIMPLE
10.3.0 -mtune=generic -march=x86-64 -g -O2 -fno-openmp -fno-openacc -fno-pie
-fcf-protection=none -ffat-lto-objects -fuse-linker-plugin -fltrans
<9f> DW_AT_language : 12 (ANSI C99)
<a0> DW_AT_name : (indirect string, offset: 0x1b2): <artificial>
- <a4> DW_AT_comp_dir : (indirect string, offset: 0x263):
/tmp/lto-test/src0
+ <a4> DW_AT_comp_dir : (indirect string, offset: 0x263):
/tmp/lto-test/src1
<a8> DW_AT_ranges : 0x40
<ac> DW_AT_low_pc : 0x0
<b4> DW_AT_stmt_list : 0xe8
and with DWARF5 in addition in the directory table:
The Directory Table (offset 0x10a, lines 1, columns 1):
Entry Name
- 0 (indirect line string, offset: 0xd): /tmp/lto-test/src0
+ 0 (indirect line string, offset: 0xd): /tmp/lto-test/src1
so indeed the prefix remapping is needed at link-time - the link time
CWD aka DW_AT_comp_dir might also not agree with the CWD at compile time.
Thus my suggestion would be to indeed add -f*-prefix-map to LDFLAGS,
at least I can't think of a good solution to the above issue. Eventually
picking a random TU and copying the CWD from its compile-time to the
link-time CUs would work. Or somehow not specifying a compilation-dir
at all for those CUs?