From ac8131465d7183046f4d2cfb5d44fbbc87191755 Mon Sep 17 00:00:00 2001 From: Simon Atanasyan Date: Tue, 26 Nov 2013 11:57:14 +0000 Subject: [PATCH] [Mips] Do not detect a used MIPS toolchain. Build a path suffix for FSF toolchain first and check the path existence. If the path does not exist build and check a path suffix for Code Sourcery toolchain. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195751 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/ToolChains.cpp | 97 +++++++++++++++++++-------------------- lib/Driver/ToolChains.h | 1 - 2 files changed, 47 insertions(+), 51 deletions(-) diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index b5f4c19b5c..b9e97fdc38 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -1019,7 +1019,7 @@ static StringRef getGCCToolchainDir(const ArgList &Args) { /// triple. Generic_GCC::GCCInstallationDetector::GCCInstallationDetector( const Driver &D, const llvm::Triple &TargetTriple, const ArgList &Args) - : IsValid(false), D(D) { + : IsValid(false) { llvm::Triple BiarchVariantTriple = TargetTriple.isArch32Bit() ? TargetTriple.get64BitArchVariant() : TargetTriple.get32BitArchVariant(); @@ -1410,65 +1410,62 @@ void Generic_GCC::GCCInstallationDetector::findMIPSABIDirSuffix( // /mips32 // /usr // /lib <= crt*.o files compiled with '-mips32' - // - // Unfortunately different toolchains use different and partially - // overlapped naming schemes. So we have to make a trick for detection - // of using toolchain. We lookup a path which unique for each toolchains. - - bool IsMentorToolChain = hasCrtBeginObj(Path + "/mips16/soft-float"); - bool IsFSFToolChain = hasCrtBeginObj(Path + "/mips32/mips16/sof"); - if (IsMentorToolChain && IsFSFToolChain) - D.Diag(diag::err_drv_unknown_toolchain); + // Check FSF Toolchain path + Suffix.clear(); + if (TargetArch == llvm::Triple::mips || + TargetArch == llvm::Triple::mipsel) { + if (isMicroMips(Args)) + Suffix += "/micromips"; + else if (isMips32r2(Args)) + Suffix += ""; + else + Suffix += "/mips32"; - if (IsMentorToolChain) { if (isMips16(Args)) Suffix += "/mips16"; - else if (isMicroMips(Args)) - Suffix += "/micromips"; + } else { + if (isMips64r2(Args)) + Suffix += hasMipsN32ABIArg(Args) ? "/mips64r2" : "/mips64r2/64"; + else + Suffix += hasMipsN32ABIArg(Args) ? "/mips64" : "/mips64/64"; + } - if (isSoftFloatABI(Args)) - Suffix += "/soft-float"; - - if (TargetArch == llvm::Triple::mipsel || - TargetArch == llvm::Triple::mips64el) - Suffix += "/el"; - } else if (IsFSFToolChain) { - if (TargetArch == llvm::Triple::mips || - TargetArch == llvm::Triple::mipsel) { - if (isMicroMips(Args)) - Suffix += "/micromips"; - else if (isMips32r2(Args)) - Suffix += ""; - else - Suffix += "/mips32"; + if (TargetArch == llvm::Triple::mipsel || + TargetArch == llvm::Triple::mips64el) + Suffix += "/el"; - if (isMips16(Args)) - Suffix += "/mips16"; - } else { - if (isMips64r2(Args)) - Suffix += hasMipsN32ABIArg(Args) ? "/mips64r2" : "/mips64r2/64"; - else - Suffix += hasMipsN32ABIArg(Args) ? "/mips64" : "/mips64/64"; - } + if (isSoftFloatABI(Args)) + Suffix += "/sof"; + else { + if (isMipsFP64(Args)) + Suffix += "/fp64"; - if (TargetArch == llvm::Triple::mipsel || - TargetArch == llvm::Triple::mips64el) - Suffix += "/el"; + if (isMipsNan2008(Args)) + Suffix += "/nan2008"; + } - if (isSoftFloatABI(Args)) - Suffix += "/sof"; - else { - if (isMipsFP64(Args)) - Suffix += "/fp64"; + if (hasCrtBeginObj(Path + Suffix)) + return; - if (isMipsNan2008(Args)) - Suffix += "/nan2008"; - } - } + // Check Code Sourcery Toolchain path + Suffix.clear(); + if (isMips16(Args)) + Suffix += "/mips16"; + else if (isMicroMips(Args)) + Suffix += "/micromips"; + + if (isSoftFloatABI(Args)) + Suffix += "/soft-float"; + + if (TargetArch == llvm::Triple::mipsel || + TargetArch == llvm::Triple::mips64el) + Suffix += "/el"; + + if (hasCrtBeginObj(Path + Suffix)) + return; - if (!hasCrtBeginObj(Path + Suffix)) - Suffix.clear(); + Suffix.clear(); } void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple( diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index cf7be5436d..0368458b40 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -76,7 +76,6 @@ protected: /// Driver, and has logic for fuzzing that where appropriate. class GCCInstallationDetector { bool IsValid; - const Driver &D; llvm::Triple GCCTriple; // FIXME: These might be better as path objects. -- 2.40.0