[LLVMbugs] [Bug 13258] New: -emit-llvm breaks -fPIC

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jul 2 20:16:03 PDT 2012


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

             Bug #: 13258
           Summary: -emit-llvm breaks -fPIC
           Product: clang
           Version: 3.1
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: b.r.longbons at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


$ clang -fPIC -c foo.c -o foo.o
$ clang -shared foo.o -o foo.so
## all is well

$ clang -fPIC -c foo.c -o foo.bc -emit-llvm
$ clang -shared foo.bc -o foo.so
/usr/bin/x86_64-pc-linux-gnu-ld: /tmp/foo-73wQhE.o: relocation R_X86_64_32S
against `a' can not be used when making a shared object; recompile with -fPIC
/tmp/foo-73wQhE.o: could not read symbols: Bad value
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Oddly, passing -flto on the second stage makes it work.

(Incidentally, I also discovered a segfault if a native object has the .bc
extension)

/* foo.c */
int a;
int foo()
{
    return a;
}

A simple solution would be to imply -fPIC when -shared is used.
I'm not familiar enough with intricate differences between -fpic and -fPIC.

-- 
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