Index: cfe/trunk/include/clang/Driver/Options.td =================================================================== --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -1311,6 +1311,7 @@ def mabi_EQ : Joined<["-"], "mabi=">, Group; def miamcu : Flag<["-"], "miamcu">, Group, Flags<[DriverOption, CoreOption]>, HelpText<"Use Intel MCU ABI">; +def mno_iamcu : Flag<["-"], "mno-iamcu">, Group, Flags<[DriverOption, CoreOption]>; def malign_functions_EQ : Joined<["-"], "malign-functions=">, Group; def malign_loops_EQ : Joined<["-"], "malign-loops=">, Group; def malign_jumps_EQ : Joined<["-"], "malign-jumps=">, Group; Index: cfe/trunk/lib/Driver/Driver.cpp =================================================================== --- cfe/trunk/lib/Driver/Driver.cpp +++ cfe/trunk/lib/Driver/Driver.cpp @@ -280,8 +280,9 @@ } // Enforce -static if -miamcu is present. - if (Args.hasArg(options::OPT_miamcu)) - DAL->AddFlagArg(0, Opts->getOption(options::OPT_static)); + if (Arg *Ar = Args.getLastArg(options::OPT_miamcu, options::OPT_mno_iamcu)) + if (Ar->getOption().matches(options::OPT_miamcu)) + DAL->AddFlagArg(0, Opts->getOption(options::OPT_static)); // Add a default value of -mlinker-version=, if one was given and the user // didn't specify one. @@ -375,22 +376,24 @@ } // Handle -miamcu flag. - if (Args.hasArg(options::OPT_miamcu)) { - if (Target.get32BitArchVariant().getArch() != llvm::Triple::x86) - D.Diag(diag::err_drv_unsupported_opt_for_target) << "-miamcu" - << Target.str(); - - if (A && !A->getOption().matches(options::OPT_m32)) - D.Diag(diag::err_drv_argument_not_allowed_with) - << "-miamcu" << A->getBaseArg().getAsString(Args); - - Target.setArch(llvm::Triple::x86); - Target.setArchName("i586"); - Target.setEnvironment(llvm::Triple::UnknownEnvironment); - Target.setEnvironmentName(""); - Target.setOS(llvm::Triple::ELFIAMCU); - Target.setVendor(llvm::Triple::UnknownVendor); - Target.setVendorName("intel"); + if (Arg *Ar = Args.getLastArg(options::OPT_miamcu, options::OPT_mno_iamcu)) { + if (Ar->getOption().matches(options::OPT_miamcu)) { + if (Target.get32BitArchVariant().getArch() != llvm::Triple::x86) + D.Diag(diag::err_drv_unsupported_opt_for_target) << "-miamcu" + << Target.str(); + + if (A && !A->getOption().matches(options::OPT_m32)) + D.Diag(diag::err_drv_argument_not_allowed_with) + << "-miamcu" << A->getBaseArg().getAsString(Args); + + Target.setArch(llvm::Triple::x86); + Target.setArchName("i586"); + Target.setEnvironment(llvm::Triple::UnknownEnvironment); + Target.setEnvironmentName(""); + Target.setOS(llvm::Triple::ELFIAMCU); + Target.setVendor(llvm::Triple::UnknownVendor); + Target.setVendorName("intel"); + } } return Target; Index: cfe/trunk/lib/Driver/Tools.cpp =================================================================== --- cfe/trunk/lib/Driver/Tools.cpp +++ cfe/trunk/lib/Driver/Tools.cpp @@ -2243,10 +2243,12 @@ } // Set flags to support MCU ABI. - if (Args.hasArg(options::OPT_miamcu)) { - CmdArgs.push_back("-mfloat-abi"); - CmdArgs.push_back("soft"); - CmdArgs.push_back("-mstack-alignment=4"); + if (Arg *A = Args.getLastArg(options::OPT_miamcu, options::OPT_mno_iamcu)) { + if (A->getOption().matches(options::OPT_miamcu)) { + CmdArgs.push_back("-mfloat-abi"); + CmdArgs.push_back("soft"); + CmdArgs.push_back("-mstack-alignment=4"); + } } } Index: cfe/trunk/test/Driver/miamcu-opt.c =================================================================== --- cfe/trunk/test/Driver/miamcu-opt.c +++ cfe/trunk/test/Driver/miamcu-opt.c @@ -4,9 +4,11 @@ // RUN: %clang -miamcu -no-canonical-prefixes %s -### -o %t.o 2>&1 | FileCheck %s // RUN: %clang -miamcu -no-canonical-prefixes -m32 %s -### -o %t.o 2>&1 | FileCheck %s // RUN: %clang -miamcu -no-canonical-prefixes -target x86_64-unknown-linux-gnu %s -### -o %t.o 2>&1 | FileCheck %s +// RUN: %clang -mno-iamcu -miamcu -no-canonical-prefixes %s -### -o %t.o 2>&1 | FileCheck %s // RUN: %clang -miamcu -no-canonical-prefixes -m64 %s -### -o %t.o 2>&1 | FileCheck %s -check-prefix=M64 // RUN: %clang -miamcu -no-canonical-prefixes -dynamic %s -### -o %t.o 2>&1 | FileCheck %s -check-prefix=DYNAMIC // RUN: %clang -miamcu -no-canonical-prefixes -target armv8-eabi %s -### -o %t.o 2>&1 | FileCheck %s -check-prefix=NOT-X86 +// RUN: %clang -miamcu -mno-iamcu -no-canonical-prefixes -target x86_64-unknown-linux-gnu %s -### -o %t.o 2>&1 | FileCheck %s -check-prefix=MNOIAMCU // M64: error: invalid argument '-miamcu' not allowed with '-m64' @@ -14,6 +16,8 @@ // NOT-X86: error: unsupported option '-miamcu' for target 'armv8---eabi' +// MNOIAMCU-NOT: "-triple" "i586-intel-elfiamcu" + // CHECK: "{{.*}}clang{{.*}}" "-cc1" // CHECK: "-triple" "i586-intel-elfiamcu" // CHECK: "-static-define"