<div dir="ltr"><div dir="ltr"><div dir="ltr">On Wed, Feb 6, 2019 at 2:57 AM Peter Smith via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello Amara,<br>
<br>
Given the amount of possible names, sometimes target dependent, that<br>
libclang_rt can take I think the current situation is unfriendly<br>
enough to do something about it.<br>
<br>
The GCC equivalent solution to this is -print-libgcc-file-name<br>
>From the man page:<br>
"-print-libgcc-file-name<br>
           Same as -print-file-name=libgcc.a.<br>
<br>
           This is useful when you use -nostdlib or -nodefaultlibs but<br>
you do want to link with libgcc.a.  You can do:<br>
<br>
                   gcc -nostdlib <files>... `gcc -print-libgcc-file-name`<br>
"<br>
<br>
Would it be worth coming up with a similar solution in clang?<br></blockquote><div><br></div><div>This is already supported in Clang, we also use this solution in the CMake build for libunwind, libc++abi, libc++ and compiler-rt to find out the location of builtins (since all these libraries are being built with -nodefaultlibs), see for example <a href="https://github.com/llvm/llvm-project/blob/master/compiler-rt/cmake/Modules/HandleCompilerRT.cmake#L3">https://github.com/llvm/llvm-project/blob/master/compiler-rt/cmake/Modules/HandleCompilerRT.cmake#L3</a></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Some other questions:<br>
- On Linux there is not a single libclang_rt.a, but many separate ones<br>
like ./clang/9.0.0/lib/linux/libclang_rt.builtins-x86_64.a would this<br>
option be just the builtins?<br>
- Would this extend to libgcc on linux? I don't know enough about<br>
Windows to know about an equivalent?<br>
- A possible alternative is that the presence of --rtlib=<library> is<br>
sufficient to add the -l even if --nodefaultlib etc. are added.<br>
<br>
Peter<br>
<br>
On Tue, 5 Feb 2019 at 22:53, Duncan Exon Smith via cfe-dev<br>
<<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br>
><br>
> +cfe-dev, bcc: llvm-dev, since you're talking about changes to Clang.<br>
><br>
> > On 2019 Feb  5, at 14:43, Amara Emerson <<a href="mailto:aemerson@apple.com" target="_blank">aemerson@apple.com</a>> wrote:<br>
> ><br>
> > Hi all,<br>
> ><br>
> > As far as I’m aware, there’s no way to specify to the clang driver at link time that you want to link in libclang_rt.a even in the presence of -nostdlib or -nodefaultlib. This behavior can be desirable in some cases as users may want to avoid linking libc++ or libSystem.dylib for example, but still want to have the compiler’s own builtin routines available. Since we view compiler-rt as an intricately linked (no pun intended) part of the overall compiler toolchain, I think this is a reasonable request.<br>
> ><br>
> > I’m proposing a new driver option to trigger this behaviour: -flink-rtlib<br>
> ><br>
> > Thoughts?<br>
> ><br>
> > Thanks,<br>
> > Amara<br>
><br>
> _______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div></div></div>