rnk added a comment.
I think there's an issue with the whole idea of dropping .debug_info from
objects without live sections. Consider:
// a.cpp
int main() {
return f();
}
// b.cpp
struct Foo {
int x, y;
};
int f() {
volatile Foo var;
var.x = 13;
var.y = 42;
return var.x + var.y;
}
When compiled and linked with thinlto, `f` is imported into the a.cpp TU, but
the full definition of the `Foo` type remains in the b.cpp TU, because
importing the full type would be expensive and wasteful.
I used these commands to show the change in behavior before and after this
change:
$ clang -O2 -flto=thin -c -ffunction-sections a.cpp b.cpp -g
# before
$ ninja lld
[1 processes, 3/3 @ 0.8/s : 3.582s ] Linking CXX executable bin/lld
$ clang -Wl,--gc-sections -flto=thin -fuse-ld=lld a.o b.o -o t.exe
$ gdb -ex 'b foo' -ex r -ex s -ex 'p var' -batch t.exe
...
Breakpoint 1 at 0x201168: file a.cpp, line 2.
Breakpoint 1, foo () at b.cpp:7
7 var.y = 42;
8 return var.x + var.y;
$1 = {x = 13, y = 42}
# after
$ ninja lld
$ clang -Wl,--gc-sections -flto=thin -fuse-ld=lld a.o b.o -o t.exe
$ gdb -ex 'b foo' -ex r -ex s -ex 'p var' -batch t.exe
...
Breakpoint 1 at 0x201168: file a.cpp, line 2.
Breakpoint 1, foo () at b.cpp:7
7 var.y = 42;
8 return var.x + var.y;
$1 = <incomplete type>
So, before `Foo` had a complete type, but now it does not.
I can't seem to construct an example where LLD will throw away useful debug
info without thinlto, but Clang often makes assumptions that other object files
will provide certain bits of debug info as a size optimization.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D54747/new/
https://reviews.llvm.org/D54747
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits