Index: lib/Basic/Targets.cpp =================================================================== --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -5696,14 +5696,6 @@ } const std::string& getCPU() const { return CPU; } void getDefaultFeatures(llvm::StringMap &Features) const override { - // The backend enables certain ABI's by default according to the - // architecture. - // Disable both possible defaults so that we don't end up with multiple - // ABI's selected and trigger an assertion. - Features["o32"] = false; - Features["n64"] = false; - - Features[ABI] = true; if (CPU == "octeon") Features["mips64r2"] = Features["cnmips"] = true; else Index: lib/Driver/Tools.h =================================================================== --- lib/Driver/Tools.h +++ lib/Driver/Tools.h @@ -109,7 +109,8 @@ ClangAs(const ToolChain &TC) : Tool("clang::as", "clang integrated assembler", TC, RF_Full) {} - + void AddMIPSTargetArgs(const llvm::opt::ArgList &Args, + llvm::opt::ArgStringList &CmdArgs) const; bool hasGoodDiagnostics() const override { return true; } bool hasIntegratedAssembler() const override { return false; } bool hasIntegratedCPP() const override { return false; } Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -1095,17 +1095,6 @@ mips::getMipsCPUAndABI(Args, Triple, CPUName, ABIName); ABIName = getGnuCompatibleMipsABIName(ABIName); - // Always override the backend's default ABI. - std::string ABIFeature = llvm::StringSwitch(ABIName) - .Case("32", "+o32") - .Case("n32", "+n32") - .Case("64", "+n64") - .Case("eabi", "+eabi") - .Default(("+" + ABIName).str()); - Features.push_back("-o32"); - Features.push_back("-n64"); - Features.push_back(Args.MakeArgString(ABIFeature)); - AddTargetFeature(Args, Features, options::OPT_mno_abicalls, options::OPT_mabicalls, "noabicalls"); @@ -4875,6 +4864,17 @@ return CLFallback.get(); } +void ClangAs::AddMIPSTargetArgs(const ArgList &Args, + ArgStringList &CmdArgs) const { + StringRef CPUName; + StringRef ABIName; + const llvm::Triple &Triple = getToolChain().getTriple(); + mips::getMipsCPUAndABI(Args, Triple, CPUName, ABIName); + + CmdArgs.push_back("-target-abi"); + CmdArgs.push_back(ABIName.data()); +} + void ClangAs::ConstructJob(Compilation &C, const JobAction &JA, const InputInfo &Output, const InputInfoList &Inputs, @@ -4982,6 +4982,19 @@ // FIXME: Add -static support, once we have it. + // Add target specific flags. + switch(getToolChain().getArch()) { + default: + break; + + case llvm::Triple::mips: + case llvm::Triple::mipsel: + case llvm::Triple::mips64: + case llvm::Triple::mips64el: + AddMIPSTargetArgs(Args, CmdArgs); + break; + } + // Consume all the warning flags. Usually this would be handled more // gracefully by -cc1 (warning about unknown warning flags, etc) but -cc1as // doesn't handle that so rather than warning about unused flags that are Index: test/Driver/mips-integrated-as.s =================================================================== --- test/Driver/mips-integrated-as.s +++ test/Driver/mips-integrated-as.s @@ -5,24 +5,19 @@ // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mabi=o32 2>&1 | \ // RUN: FileCheck -check-prefix=ABI-O32 %s // ABI-O32: -cc1as -// ABI-O32: "-target-feature" "-n64" -// ABI-O32: "-target-feature" "+o32" +// ABI-O32: "-target-abi" "o32" // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mabi=eabi 2>&1 | \ // RUN: FileCheck -check-prefix=ABI-EABI32 %s // ABI-EABI32: -cc1as -// ABI-EABI32: "-target-feature" "-o32" -// ABI-EABI32: "-target-feature" "-n64" -// ABI-EABI32: "-target-feature" "+eabi" +// ABI-EABI32: "-target-abi" "eabi" // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mips64 -mabi=n32 2>&1 | \ // RUN: FileCheck -check-prefix=ABI-N32 %s // RUN: %clang -target mips64-linux-gnu -### -fintegrated-as -c %s -mabi=n32 2>&1 | \ // RUN: FileCheck -check-prefix=ABI-N32 %s // ABI-N32: -cc1as -// ABI-N32: "-target-feature" "-o32" -// ABI-N32: "-target-feature" "-n64" -// ABI-N32: "-target-feature" "+n32" +// ABI-N32: "-target-abi" "n32" // FIXME: We should also test '-target mips-linux-gnu -mips64' defaults to the // default 64-bit ABI (N64 but GCC uses N32). It currently selects O32 @@ -39,8 +34,7 @@ // RUN: %clang -target mips64-linux-gnu -### -fintegrated-as -c %s -mips64 -mabi=n64 2>&1 | \ // RUN: FileCheck -check-prefix=ABI-N64 %s // ABI-N64: -cc1as -// ABI-N64: "-target-feature" "-o32" -// ABI-N64: "-target-feature" "+n64" +// ABI-N64: "-target-abi" "n64" // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -msoft-float 2>&1 | \ // RUN: FileCheck -check-prefix=SOFTFLOAT %s