<div dir="ltr"><div>Hi Rafael,</div><div><br></div>Binutils community said that there is no bug in linker (<a href="https://sourceware.org/ml/binutils/2014-03/msg00233.html" target="_blank">https://sourceware.org/ml/binutils/2014-03/msg00233.html</a>)<div>

Compiler shouldn't rely on output file type to determine what options it needed.</div><div>Instead of linker output GCC uses section .gnu.lto_.opts in object files with IR to pass compiler options.</div><div>Thus GCC sets pic on Android with LTO enabled.</div>

<div>I see in object files with LLVM IR attributes section with target specific options:</div><div>attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }<br>

</div><div>Is it possible to add fpic to those options?</div><div><br></div><div>Also I see that other compiler options such as -O2, -Ofast, funroll-loops are not passed through linker to LTO.</div><div>Thus compiler output with -flto seems to be the same with any optimization options.</div>
<div>Do you have any plans to support these options in LTO?</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-02-21 2:36 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 20 February 2014 09:00, Alexey Volkov <<a href="mailto:avolkov.intel@gmail.com">avolkov.intel@gmail.com</a>> wrote:<br>

> On Android there is a bit unusual situation when compiler makes PIC code but<br>
> doesn't pass -pie to linker.<br>
> This is what LLVM and gcc both do without -flto.<br>
> With -flto GCC still produces PIC code but not LLVM.<br>
> The reason is that GCC passes -fpic to compiler invocation from plugin using<br>
> temporary file with options for compiler.<br>
> I tried to implement similar solution with my first patch introducing gold<br>
> plugin option.<br>
<br>
</div>OK, so it does seem there is a bug in the android linker, right? It is<br>
produce a PIE executable but not informing the plugin of that unless<br>
it is given the -pie option.<br>
<div class=""><br>
> Anyway addition of -pie would produce correct code for Android.<br>
> As I understand my last patch with -pie is ok except change with sanitizer?<br>
<br>
</div>And the more philosophical issue of  "should we parse -Wl?".<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>