Index: clang/include/clang/Basic/DiagnosticDriverKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticDriverKinds.td +++ clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -556,4 +556,6 @@ def err_cc1_round_trip_fail_then_ok : Error<"Original arguments parse failed, then succeeded in round-trip">; def err_cc1_round_trip_ok_then_fail : Error<"Generated arguments parse failed in round-trip">; def err_cc1_round_trip_mismatch : Error<"Generated arguments do not match in round-trip">; + +def warn_drv_treating_option_as : Warning<"Unknown option %0, treating as %1.">; } Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -4226,8 +4226,6 @@ defm branch_count_reg : BooleanFFlag<"branch-count-reg">, Group; defm default_inline : BooleanFFlag<"default-inline">, Group; defm fat_lto_objects : BooleanFFlag<"fat-lto-objects">, Group; -def : Flag<["-"], "flto=auto">, Group; -def : Flag<["-"], "flto=jobserver">, Group; defm float_store : BooleanFFlag<"float-store">, Group; defm friend_injection : BooleanFFlag<"friend-injection">, Group; defm function_attribute_list : BooleanFFlag<"function-attribute-list">, Group; Index: clang/lib/Driver/Driver.cpp =================================================================== --- clang/lib/Driver/Driver.cpp +++ clang/lib/Driver/Driver.cpp @@ -613,9 +613,12 @@ .Default(LTOK_Unknown); if (LTOMode == LTOK_Unknown) { + // Treat all other options as "full", but warn that the option + // value is unknown. assert(A); - Diag(diag::err_drv_unsupported_option_argument) << A->getOption().getName() - << A->getValue(); + Diag(diag::warn_drv_treating_option_as) + << A->getAsString(Args) << "-flto=full"; + LTOMode = LTOK_Full; } } Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -1707,8 +1707,7 @@ StringRef S = A->getValue(); if (S == "thin") Opts.PrepareForThinLTO = true; - else if (S != "full") - Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << S; + // -flto=full and invalid values are handled elsewhere. } if (Arg *A = Args.getLastArg(OPT_fthinlto_index_EQ)) { if (IK.getLanguage() != Language::LLVM_IR) Index: clang/test/Driver/clang_f_opts.c =================================================================== --- clang/test/Driver/clang_f_opts.c +++ clang/test/Driver/clang_f_opts.c @@ -258,7 +258,6 @@ // RUN: -fstrength-reduce -fno-strength-reduce \ // RUN: -finline-limit=1000 \ // RUN: -finline-limit \ -// RUN: -flto=1 \ // RUN: -falign-labels \ // RUN: -falign-labels=100 \ // RUN: -falign-loops \ @@ -292,7 +291,6 @@ // RUN: -fno-delete-null-pointer-checks -fdelete-null-pointer-checks \ // RUN: -fno-inline-small-functions -finline-small-functions \ // RUN: -fno-fat-lto-objects -ffat-lto-objects \ -// RUN: -flto=auto -flto=jobserver \ // RUN: -fno-merge-constants -fmerge-constants \ // RUN: -fno-caller-saves -fcaller-saves \ // RUN: -fno-reorder-blocks -freorder-blocks \ @@ -332,6 +330,8 @@ // RUN: -funroll-all-loops \ // RUN: -funswitch-loops \ // RUN: -flto=1 \ +// RUN: -flto=auto \ +// RUN: -flto=jobserver \ // RUN: -falign-labels \ // RUN: -falign-labels=100 \ // RUN: -falign-loops \ @@ -392,7 +392,9 @@ // CHECK-WARNING-DAG: optimization flag '-ftracer' is not supported // CHECK-WARNING-DAG: optimization flag '-funroll-all-loops' is not supported // CHECK-WARNING-DAG: optimization flag '-funswitch-loops' is not supported -// CHECK-WARNING-DAG: unsupported argument '1' to option 'flto=' +// CHECK-WARNING_DAG: Unknown option -flto=1, treating as -flto=full +// CHECK-WARNING_DAG: Unknown option -flto=auto, treating as -flto=full +// CHECK-WARNING_DAG: Unknown option -flto=jobserver, treating as -flto=full // CHECK-WARNING-DAG: optimization flag '-falign-labels' is not supported // CHECK-WARNING-DAG: optimization flag '-falign-labels=100' is not supported // CHECK-WARNING-DAG: optimization flag '-falign-loops' is not supported