[cfe-dev] RFC: New clang option to force linking libclang_rt.a

Peter Smith via cfe-dev cfe-dev at lists.llvm.org
Wed Feb 6 02:57:34 PST 2019


Hello Amara,

Given the amount of possible names, sometimes target dependent, that
libclang_rt can take I think the current situation is unfriendly
enough to do something about it.

The GCC equivalent solution to this is -print-libgcc-file-name
>From the man page:
"-print-libgcc-file-name
           Same as -print-file-name=libgcc.a.

           This is useful when you use -nostdlib or -nodefaultlibs but
you do want to link with libgcc.a.  You can do:

                   gcc -nostdlib <files>... `gcc -print-libgcc-file-name`
"

Would it be worth coming up with a similar solution in clang?

Some other questions:
- On Linux there is not a single libclang_rt.a, but many separate ones
like ./clang/9.0.0/lib/linux/libclang_rt.builtins-x86_64.a would this
option be just the builtins?
- Would this extend to libgcc on linux? I don't know enough about
Windows to know about an equivalent?
- A possible alternative is that the presence of --rtlib=<library> is
sufficient to add the -l even if --nodefaultlib etc. are added.

Peter

On Tue, 5 Feb 2019 at 22:53, Duncan Exon Smith via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
>
> +cfe-dev, bcc: llvm-dev, since you're talking about changes to Clang.
>
> > On 2019 Feb  5, at 14:43, Amara Emerson <aemerson at apple.com> wrote:
> >
> > Hi all,
> >
> > 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.
> >
> > I’m proposing a new driver option to trigger this behaviour: -flink-rtlib
> >
> > Thoughts?
> >
> > Thanks,
> > Amara
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



More information about the cfe-dev mailing list