[cfe-dev] Linking ProfileRT when using -nodefaultlibs

Eric Fiselier eric at efcs.ca
Mon Nov 10 15:12:02 PST 2014


>Interesting. This issue doesn't arise with sanitizers, because we put
sanitizer runtimes *before* the user inputs, and force it into the
executable by wrapping it in "-whole-archive". I wonder if
>we can do the same trick for profile runtime. I don't really know that,
but it seems we have both GCDA profiling and new InstrProfiling stuff
there, so pulling all of them into the executable
>is not desirable, is it?

I can't answer if we *should* do it put the profile runtime first, but I
tested doing so and the change worked for me.

>I believe -whole-archive will cause issues for the profile_rt library.
>We really do only want particular symbols pulled in.

How would I go about looking into this?

/Eric

On Mon, Nov 10, 2014 at 4:10 PM, Justin Bogner <mail at justinbogner.com>
wrote:

> Alexey Samsonov <vonosmas at gmail.com> writes:
> > Ah, I see the problem here.
> >
> > 1) We add profile runtime library after the linker inputs (in particular,
> > after "-lc" provided by the user), because user-provided libraries can
> have
> > references to libclang_rt.profile.a, and therefore should precede it.
> > 2) If -nodefautlibs is there, we never add "-lc" and friends at the very
> end,
> > so some symbols in profile runtime may be left unresolved.
> >
> > Interesting. This issue doesn't arise with sanitizers, because we put
> > sanitizer runtimes *before* the user inputs, and force it into the
> executable
> > by wrapping it in "-whole-archive". I wonder if
> > we can do the same trick for profile runtime. I don't really know that,
> but it
> > seems we have both GCDA profiling and new InstrProfiling stuff there, so
> > pulling all of them into the executable
> > is not desirable, is it?
>
> I believe -whole-archive will cause issues for the profile_rt library.
> We really do only want particular symbols pulled in.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141110/50367674/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: profile_rt.patch
Type: application/octet-stream
Size: 1090 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141110/50367674/attachment.obj>


More information about the cfe-dev mailing list