Page MenuHomePhabricator

[clang][driver] Treat unkonwn -flto= values as -flto
ClosedPublic

Authored by tbaeder on May 14 2021, 4:33 AM.

Details

Summary

The current behavior was introduced in https://github.com/llvm/llvm-project/commit/1628486548420f85b3467026d54663d1516404f5 and simply ignores the options, which will of course not turn on any form of LTO. When they are passed, I think it's sensible to at least turn on full LTO.

This makes clang basically accept all -flto=val values and treat them like -flto=full. I didn't implement anything that checks for only =auto or =jobserver, I'm not sure if that would be the right thing to do.

Thoughts?

Diff Detail

Event Timeline

tbaeder created this revision.May 14 2021, 4:33 AM
tbaeder requested review of this revision.May 14 2021, 4:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 14 2021, 4:33 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
tbaeder updated this revision to Diff 345763.May 17 2021, 12:10 AM

On second thought, rather only handle =auto and =jobserver and don't warn.

tbaeder updated this revision to Diff 346058.May 17 2021, 11:59 PM

I don't think current implementation is the best idea. I think is better to make the gcc compatible LTO value to be a clang Driver only option, give them an option name, and handle them separately in driver to invoke correct fullLTO cc1 command, so that:

  • The value remain invalid option for cc1 (CompilerInvocation should just error on that, just like now).
  • The ignored value should not appear in the help or autocompletion.
tbaeder updated this revision to Diff 346634.May 19 2021, 10:53 PM
tbaeder updated this revision to Diff 346635.May 19 2021, 10:58 PM

Thanks for the feedback, I think this should work better.

tbaeder updated this revision to Diff 346737.May 20 2021, 7:56 AM

Use hasFlag() instead of hasArg() in Driver.cpp

This revision is now accepted and ready to land.May 20 2021, 9:40 AM
This revision was automatically updated to reflect the committed changes.