[cfe-dev] Linking ProfileRT when using -nodefaultlibs
mail at justinbogner.com
Mon Nov 10 17:49:23 PST 2014
Alexey Samsonov <vonosmas at gmail.com> writes:
> On Mon, Nov 10, 2014 at 3:12 PM, Eric Fiselier <eric at efcs.ca> wrote:
> >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.
> What do you mean? We can't put it first, because user libraries depend on it.
> We fail when we put it last either, because
> of this specific case, where user provides "-lc" + "-nostdlib".
> We can workaround this by forcing to link in libprofile deps even if -nostdlib
> is specified (assuming the user passing
> this weird combination knows what (s)he is doing).
> Or we can design a magic flag "--profile-lib", or smth. like this, which
> would be matched and replaced by the path to actual static profile runtime in
> the driver. Then you'd be able
> to write ("clang++ -nostdlib a.o b.o --profile-lib -lc -lpthread").
Can we just teach clang where to find compiler-rt libraries and spell
this like so?
clang++ -nostdlib a.o b.o -lclang_rt.profile -lc -lpthread
I don't think I'd mind that so much, as it makes sense for clang to know
where to find it's own runtime libraries.
More information about the cfe-dev