[cfe-dev] Linking ProfileRT when using -nodefaultlibs
vonosmas at gmail.com
Mon Nov 10 14:44:57 PST 2014
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?
On Mon, Nov 10, 2014 at 2:33 PM, Alexey Samsonov <vonosmas at gmail.com> wrote:
> On Sun, Nov 9, 2014 at 10:39 PM, Eric Fiselier <eric at efcs.ca> wrote:
>> I'm working on making libc++ generate code coverage data. This means that
>> libclang_rt.profile.x86_64.a is put into the link command before '-lc' and
>> other dependencies.
>> I suspect this change in library order causes the linker errors I see
>> while running the tests.
>> I have a couple of questions:
>> - Should -ftest-coverage be passed when linking libc++?
>> - Is there a way to link libclang_rt.profile.x86_64.a after the given
>> linker flags
>> This file shows the ld invocation with and without -nodefaultlibs as well
>> as the error produced when
>> linking tests w/ -nodefaultlibs
> Hm? On the contrary, in the attached file "libclang_rt.profile.x86_64.a"
> is listed *after* its dependencies, in particular, after "-lc".
> I think this is wrong, and we should just fix it in the driver.
> "-nodefautlibs" shouldn't be a problem here, as you seem to add "-lc",
> etc. manually to your linker invocation.
>> Any help is appreciated
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
> Alexey Samsonov
> vonosmas at gmail.com
vonosmas at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev