<div dir="ltr">GCC doesn't parse -Wl options and also doesn't use -pie linker option for PIC code generation on Android.<div>I see different handling of -fpic option on GCC and LLVM when running with -flto:</div><div>
GCC running with -fpic -flto will generate PIC code but LLVM with -fpic -flto will not.</div><div>This happens both on Android and Linux.</div><div>Fixing this problem could solve original problem with -flto on Android.</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-02-18 19:55 GMT+04:00 Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On 18 February 2014 10:45, Alexey Volkov <<a href="mailto:avolkov.intel@gmail.com">avolkov.intel@gmail.com</a>> wrote:<br>

> Hi Rafael,<br>
><br>
> Before clang parses -Wl options there is some logic based on PIE, e.g. crt<br>
> object name selection.<br>
> One possible solution is to move -Wl options before crt objects.<br>
> But I am not sure if such reordering of linker arguments is possible.<br>
> Another solution is to parse -Wl option value directly before it is passed<br>
> to CmdArgs.<br>
> Do you have any other ideas?<br>
<br>
</div>Unfortunately no. It does raise the question of when -Wl should be<br>
interpreted by the clang driver. If we parse it to decide if we are<br>
producing a shared object and don't need to also pass a PIE option, we<br>
should probably also parse it for deciding which crt object to use.<br>
<br>
On the other hand, if we don't parse it when deciding which crt object<br>
to use, then the correct behavior is probably to not parse the -Wl<br>
options at all and expect the user to use the driver equivalent ones<br>
(-shared for example). This would match gcc's behavior, no?<br>
<br>
Cheers,<br>
Rafael<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Alexey Volkov<div>Intel Corporation</div></div>
</div>