From: David Greene Date: Mon, 22 Oct 2018 13:46:12 +0000 (+0000) Subject: Always search sysroot for GCC installs X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ef01f7fbf3d553dea10333f00818ad7e0104509c;p=clang Always search sysroot for GCC installs Previously, if clang was configured with -DGCC_INSTALL_PREFIX, then it would not search a provided sysroot for a gcc install. This caused a number of regression tests to fail. If a sysroot is given, skip searching GCC_INSTALL_PREFIX as it is likely not valid for the provided sysroot. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@344901 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp index c397f05749..77fb6513cd 100644 --- a/lib/Driver/ToolChains/Gnu.cpp +++ b/lib/Driver/ToolChains/Gnu.cpp @@ -1651,10 +1651,18 @@ Generic_GCC::GCCVersion Generic_GCC::GCCVersion::Parse(StringRef VersionText) { return GoodVersion; } -static llvm::StringRef getGCCToolchainDir(const ArgList &Args) { +static llvm::StringRef getGCCToolchainDir(const ArgList &Args, + llvm::StringRef SysRoot) { const Arg *A = Args.getLastArg(clang::driver::options::OPT_gcc_toolchain); if (A) return A->getValue(); + + // If we have a SysRoot, ignore GCC_INSTALL_PREFIX. + // GCC_INSTALL_PREFIX specifies the gcc installation for the default + // sysroot and is likely not valid with a different sysroot. + if (!SysRoot.empty()) + return ""; + return GCC_INSTALL_PREFIX; } @@ -1686,7 +1694,7 @@ void Generic_GCC::GCCInstallationDetector::init( SmallVector Prefixes(D.PrefixDirs.begin(), D.PrefixDirs.end()); - StringRef GCCToolchainDir = getGCCToolchainDir(Args); + StringRef GCCToolchainDir = getGCCToolchainDir(Args, D.SysRoot); if (GCCToolchainDir != "") { if (GCCToolchainDir.back() == '/') GCCToolchainDir = GCCToolchainDir.drop_back(); // remove the /