[LLVMbugs] [Bug 13427] New: -O4 (LTO) removes objects with non-trivial constructor

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Jul 21 00:34:04 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13427

             Bug #: 13427
           Summary: -O4 (LTO) removes objects with non-trivial constructor
           Product: clang
           Version: trunk
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: l.lunak at suse.cz
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


LLVM build fails in make check if LLVM is built with -O4. The reduced testcase
is:

$ clang --version
clang version 3.2 
Target: x86_64-unknown-linux-gnu
Thread model: posix
$ cat a.cpp
extern void foo();

struct A
    {
    A() { foo(); }
    };

static A a;

$ cat b.cpp
#include <stdio.h>

int main()
    {
    return 0;
    }

void foo()
    {
    fprintf( stderr, "FOO\n" );
    }

$ clang++ a.cpp -fPIC -shared -o liba.so -O3
$ clang++ b.cpp -o b liba.so -Wl,-R. -O3
$ ./b
FOO
$ clang++ a.cpp -fPIC -shared -o liba.so -O4
$ clang++ b.cpp -o b liba.so -Wl,-R. -O4
$ ./b
$

The real-world example is:

$ CC=clang CXX=clang++ CFLAGS='-O4' CXXFLAGS='-O4' cmake [llvm-sources]
$ make
$ make check
-> fail

What seems to trigger the problem is the fact that foo() is an undefined
reference at the time liba.so is created. If foo() is moved to a.cpp, the
problem disappears.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list