[llvm-bugs] [Bug 39419] New: hello world example linker error

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Oct 24 07:10:30 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=39419

            Bug ID: 39419
           Summary: hello world example linker error
           Product: new-bugs
           Version: 7.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: Xunlei.wu at sas.com
                CC: llvm-bugs at lists.llvm.org

Hello,

First time user of LLVM here. My environment is Ubuntu18.04 64-bit in
VirtualBox. Host OS is Windows 10 professional.

VirtualBox:~/tmp$ uname -a
Linux VirtualBox 4.15.0-38-generic #41-Ubuntu SMP Wed Oct 10 10:59:38 UTC 2018
x86_64 x86_64 x86_64 GNU/Linux

VirtualBox:~/tmp$ gcc --version
gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0

Ubuntu18.04 has LLVM 6.0.0 pre-installed.
VirtualBox:~/tmp$ /usr/bin/clang --version
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

I followed the hello world example 
https://llvm.org/docs/GettingStarted.html#an-example-using-the-llvm-tool-chain
till step 7
Assemble the native assembly language file into a program:

% /opt/SUNWspro/bin/cc -xarch=v9 hello.s -o hello.native   # On Solaris

% gcc hello.s -o hello.native                              # On others

The failed message is
"
VirtualBox:~/tmp$ gcc hello.s -o hello.native
/usr/bin/ld: /tmp/ccaIxQSy.o: relocation R_X86_64_32 against `.rodata.str1.1'
can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
"

I then added -fPIC to "% clang -fPIC -O3 -emit-llvm hello.c -c -o hello.bc".
However, it did not help.

I then installed clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz. The
same issue persists.

Would you please help? Thanks a lot.

-- 
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/20181024/987689b8/attachment.html>


More information about the llvm-bugs mailing list