<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 10, 2014 at 3:12 PM, Eric Fiselier <span dir="ltr"><<a href="mailto:eric@efcs.ca" target="_blank">eric@efcs.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span class=""><div>><span style="font-family:arial,sans-serif;font-size:13px">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</span></div><div style="font-size:13px;font-family:arial,sans-serif">>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</div><div style="font-size:13px;font-family:arial,sans-serif">>is not desirable, is it?</div><div style="font-size:13px;font-family:arial,sans-serif"><br></div></span><div style="font-size:13px;font-family:arial,sans-serif">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.</div></div></blockquote><div><br></div><div>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</div><div>of this specific case, where user provides "-lc" + "-nostdlib".</div><div><br></div><div>We can workaround this by forcing to link in libprofile deps even if -nostdlib is specified (assuming the user passing</div><div>this weird combination knows what (s)he is doing).</div><div><br></div><div>Or we can design a magic flag "--profile-lib", or smth. like this, which<br></div><div>would be matched and replaced by the path to actual static profile runtime in the driver. Then you'd be able</div><div>to write ("clang++ -nostdlib a.o b.o --profile-lib -lc -lpthread").</div><div><br></div><div>I like neither of this :(</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span class=""><div style="font-size:13px;font-family:arial,sans-serif"><br></div><div style="font-size:13px;font-family:arial,sans-serif">>I believe -whole-archive will cause issues for the profile_rt library.</div><span style="font-family:arial,sans-serif;font-size:13px">>We really do only want particular symbols pulled in.</span><div style="font-size:13px;font-family:arial,sans-serif"><br></div></span><div style="font-size:13px;font-family:arial,sans-serif">How would I go about looking into this?</div><span class="HOEnZb"><font color="#888888"><div style="font-size:13px;font-family:arial,sans-serif"><br></div><div style="font-size:13px;font-family:arial,sans-serif">/Eric</div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 10, 2014 at 4:10 PM, Justin Bogner <span dir="ltr"><<a href="mailto:mail@justinbogner.com" target="_blank">mail@justinbogner.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>Alexey Samsonov <<a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a>> writes:<br>
> Ah, I see the problem here.<br>
><br>
> 1) We add profile runtime library after the linker inputs (in particular,<br>
> after "-lc" provided by the user), because user-provided libraries can have<br>
> references to libclang_rt.profile.a, and therefore should precede it.<br>
> 2) If -nodefautlibs is there, we never add "-lc" and friends at the very end,<br>
> so some symbols in profile runtime may be left unresolved.<br>
><br>
> Interesting. This issue doesn't arise with sanitizers, because we put<br>
> sanitizer runtimes *before* the user inputs, and force it into the executable<br>
> by wrapping it in "-whole-archive". I wonder if<br>
> we can do the same trick for profile runtime. I don't really know that, but it<br>
> seems we have both GCDA profiling and new InstrProfiling stuff there, so<br>
> pulling all of them into the executable<br>
> is not desirable, is it?<br>
<br>
</span>I believe -whole-archive will cause issues for the profile_rt library.<br>
We really do only want particular symbols pulled in.<br>
</blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Alexey Samsonov<br><a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a></div></div>
</div></div>