[PATCH] D108881: [clang][driver] Honor the last -flto= flag even if an earlier -flto is present

Steven Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 30 13:52:40 PDT 2021


steven_wu added a comment.

I agree that it might be good to change to the behavior that last arg wins but it might be simpler to set `-flto` to be an alias of `-flto=full`:

  diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
  index 1a3d1dcceec7..a796fb7fe3ac 100644
  --- a/clang/include/clang/Driver/Options.td
  +++ b/clang/include/clang/Driver/Options.td
  @@ -2086,7 +2086,7 @@ def flto_EQ : Joined<["-"], "flto=">, Flags<[CoreOption, CC1Option]>, Group<f_Gr
   def flto_EQ_jobserver : Flag<["-"], "flto=jobserver">, Group<f_Group>;
   def flto_EQ_auto : Flag<["-"], "flto=auto">, Group<f_Group>;
   def flto : Flag<["-"], "flto">, Flags<[CoreOption, CC1Option]>, Group<f_Group>,
  -  HelpText<"Enable LTO in 'full' mode">;
  +  Alias<flto_EQ>, AliasArgs<["full"]>, HelpText<"Enable LTO in 'full' mode">;
   def fno_lto : Flag<["-"], "fno-lto">, Flags<[CoreOption, CC1Option]>, Group<f_Group>,
     HelpText<"Disable LTO mode (default)">;
   def foffload_lto_EQ : Joined<["-"], "foffload-lto=">, Flags<[CoreOption]>, Group<f_Group>,

Of course, you want to clean up the option processing of `flto`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108881/new/

https://reviews.llvm.org/D108881



More information about the cfe-commits mailing list