<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60500>60500</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Question] How do I link with lld (by calling ld.lld) with the OS's standard libraries?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
spidertyler2005
</td>
</tr>
</table>
<pre>
# background
Everything I can find is using clang.... which I do not want to do here.
I am calling `lld::elf::link` via ctypes in python. Linking works, but the binary that is generated gives me a segfault or "accessing a corrupted shared library".
the command I am running looks similar to `ld.lld -o tests/output tests/output.o <additional args>`
I am using 64 bit arch linux (`uname -r` gives `6.1.6-arch1-3`) and I am using LLVM11.
# My actual question
I have been trying for 2 days at this, but I am an absolute idiot when it comes to linking, compiling, etc. I honestly just need a working example command. I've turned the following ir into an ELF object file:
```llvm
; ModuleID = '<string>'
source_filename = "<string>"
target triple = "x86_64-unknown-linux-gnu"
declare i32 @printf(i8*, ...)
declare void @exit(i32)
declare void @sleep(i32)
declare void @usleep(i32)
; Function Attrs: nounwind
define i32 @main() #0 {
entry:
ret i32 0
}
attributes #0 = { nounwind }
```
Once I try to link this, the linker happily spits out a binary, but that binary is useless.
Can I get an example command that would make this work on my OS (or similar linux OS)?
Thanks in advance, I am sorry for the noob question. I just cannot figure this out, and the amount of documentation I can find on lld is close to zero.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVVtv4zgP_TXKCxHDlRsnechD2zT4AnQw-DCLfR3QFm1rIkteXZJ6f_2CdpJp94JdoHAj4ZDi5fAQQ9CtJdqJ1bNY7ReYYuf8LgxakY-jIS_zfLWonBp3QhZQYX1qvUtWiXwv8qf5-3omP8ZO2xaOUKOFRlsFOkAKfFcbtG2WZRlcOl13cATlwLoIF7QRouNjR54y-Oj0CNhDjcawC1HmxihRPIniiUwz_zDankSZw1kj1HEcKIC2MIyxcz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