<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><div><span style="background-color: rgba(255, 255, 255, 0);">I'd like to make my compiler independent, just like Clang. Doesn't Clang call llc and then system's ld by itself? I don't want my compiler to depend by any other program.</span></div><div id="AppleMailSignature"><span style="background-color: rgba(255, 255, 255, 0);">I guess there will be a class in the llvm library that generates the object files based on the system's triple and data layout, and then call the system's ld?</span></div></div><div id="AppleMailSignature"><br></div><div>On Mar 19, 2016, at 11:48 AM, Bruce Hoult <<a href="mailto:bruce@hoult.org">bruce@hoult.org</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">If you've created a .bc or a .ll file then the simplest thing is to just give it to clang exactly the same as you would for a .c file. Clang will just Do The Right Thing with it.<div><br></div><div>If you don't want to link, then pass flags such as -c to clang as usual.<br><div><br></div><div>e.g.</div><div><br></div><div>---- hello.ll ----</div><div><div>declare i32 @puts(i8*)</div><div>@str = constant [12 x i8] c"Hello World\00"</div><div><br></div><div>define i32 @main() {</div><div> %1 = call i32 @puts(i8* getelementptr inbounds ([12 x i8]* @str, i64 0, i64 0))</div><div> ret i32 0</div><div>}</div></div><div>----------------</div><div><br></div><div>$ clang hello.ll -o hello && ./hello<br></div><div>warning: overriding the module target triple with x86_64-apple-macosx10.10.0</div><div>1 warning generated.</div><div>Hello World</div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 19, 2016 at 3:03 AM, Lorenzo Laneve via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I wrote my compiler and now it generates LLVM IR modules. Now i’d like to go ahead and make object file and then executable, just like clang does.<br>
<br>
What should I have to use to create the object files? and then how do I call the ld? (not llvm-ld, I want my compiler to work like Clang and I read that Clang doesn’t use llvm-ld).<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br></div>
</div></blockquote></body></html>