https://llvm.org/bugs/show_bug.cgi?id=30774
Bug ID: 30774 Summary: ThinLTO undefined ref due to imported DIGlobalVariable reference at -O0 Product: new-bugs Version: 3.9 Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: new bugs Assignee: unassignedb...@nondot.org Reporter: tejohn...@google.com CC: jbc.enge...@gmail.com, llvm-bugs@lists.llvm.org, mehdi.am...@apple.com, pe...@pcc.me.uk, tejohn...@google.com Classification: Unclassified Johan reported an issue hit using the 3.9 compiler and ThinLTO, when building with -O0 -g. The issue occurs when importing from a module with a const global variable - while we don't import the global variable definition, we do import the debug metadata, and in the 3.9 timeframe the DIGlobalVariable metadata still contained a reference to the associated GlobalVariable. At -O2 the GV declaration is eliminated as is the reference from the DIGlobalVariable, but at -O0 we get an undefined reference linker error. This doesn't occur at head due to pcc's change to reverse the GlobalVariable/DIGlobalVariable edge (https://reviews.llvm.org/rL281284). In reality, we shouldn't bother doing any importing at -O0 - inlining is disabled, so this is just wasted work. My plan is to disable importing and other ThinLTO optimizations at -O0, both in trunk and in 3.9 (which will fix this 3.9 issue). To reproduce: $ cat global_main.c extern int foo(); int main() { return foo(); } $ cat global.c const int foobar = 10; int foo() { return 1; } $ clang -c -O2 global.c global_main.c -flto=thin -g $ clang global.o global_main.o -flto=thin -g -O0 /tmp/lto-llvm-14880f.o(.debug_info+0x6f): error: undefined reference to 'foobar' clang-3.9: error: linker command failed with exit code 1 (use -v to see invocation) -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs