[patch] Forward the -O options to the linker

Saleem Abdulrasool compnerd at compnerd.org
Sun Nov 2 09:00:15 PST 2014


On Sat, Nov 1, 2014 at 7:04 PM, Chandler Carruth <chandlerc at google.com>
wrote:

> So, I vaguely don't like this....
>
> I'm pretty comfortable with 'clang -O3 x.o y.o z.o -o my_binary' passing
> O3 to the LTO plugin, but less comfortable with passing it to the linker
> itself. I'm not really sure why though, so I'm open to be convinced
> otherwise. I don't have any principled stance here, it just seems somewhat
> off.
>
> I asked Rafael on IRC to check with GCC, and it requires "-Wl,-O3", and so
> my current vote is for us to not invent a new convenience thing here. I'd
> be interested if others disagree, and if so why.
>

I also disagree with the patch, and don't think that we should be passing
the optimization flag down to the linker if the compiler flag was
provided.  If nothing else, it doesn't leave a way for me to disable it.
The -O flags are generally assumed to only effect compilation, not
linking.  I know that the GNU linker does provide a few optimization
options, but, passing that in via -Wl,-O1 explicitly feels like the right
thing.  This would also allow you to select which optimizations you want
applied.


> On Mon, Oct 20, 2014 at 9:35 AM, Rafael EspĂ­ndola <
> rafael.espindola at gmail.com> wrote:
>
>> It is fairly common for -O to be passed to clang when linking and both
>> bfd and gold support -O options, but currently the driver doesn't
>> translate it and projects have to use -Wl,-O if they want to enable
>> those options. In fact, our own build pass -O3, but not -Wl,-O.
>>
>> The attached patch translates and forwards the -O options to the linker.
>>
>> Cheers,
>> Rafael
>>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>


-- 
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141102/862a6704/attachment.html>


More information about the cfe-commits mailing list