[llvm-bugs] [Bug 30774] New: ThinLTO undefined ref due to imported DIGlobalVariable reference at -O0

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Oct 24 12:14:14 PDT 2016


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: unassignedbugs at nondot.org
          Reporter: tejohnson at google.com
                CC: jbc.engelen at gmail.com, llvm-bugs at lists.llvm.org,
                    mehdi.amini at apple.com, peter at pcc.me.uk,
                    tejohnson at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20161024/63ebcdc1/attachment.html>


More information about the llvm-bugs mailing list