aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimm Bäder <tbaeder@redhat.com>2022-05-23 15:22:27 +0200
committerTimm Bäder <tbaeder@redhat.com>2022-05-23 15:22:27 +0200
commit0eccc92fa0fd1794988cd6bfeca2314107567fdb (patch)
tree3a4e16cd511c9bc794a4e9685ffc4d6154cd6069
parent818cc9b285e8577d1255f8b046f87fc487fd3bd0 (diff)
downloadllvm-0eccc92fa0fd1794988cd6bfeca2314107567fdb.zip
llvm-0eccc92fa0fd1794988cd6bfeca2314107567fdb.tar.gz
llvm-0eccc92fa0fd1794988cd6bfeca2314107567fdb.tar.bz2
Revert "[clang][driver] Dynamically select gcc-toolset/devtoolset version"
This reverts commit 8717b492dfcd12d6387543a2f8322e0cf9059982. The new unittest fails on Windows buildbots, e.g. https://lab.llvm.org/buildbot/#/builders/119/builds/8647
-rw-r--r--clang/lib/Driver/ToolChains/Gnu.cpp36
-rw-r--r--clang/unittests/Driver/ToolChainTest.cpp88
2 files changed, 11 insertions, 113 deletions
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index 29e6295..38280a2 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2130,31 +2130,17 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
// and gcc-toolsets.
if (SysRoot.empty() && TargetTriple.getOS() == llvm::Triple::Linux &&
D.getVFS().exists("/opt/rh")) {
- // Find the directory in /opt/rh/ starting with gcc-toolset-* or
- // devtoolset-* with the highest version number and add that
- // one to our prefixes.
- std::string ChosenToolsetDir;
- unsigned ChosenToolsetVersion = 0;
- std::error_code EC;
- for (llvm::vfs::directory_iterator LI = D.getVFS().dir_begin("/opt/rh", EC),
- LE;
- !EC && LI != LE; LI = LI.increment(EC)) {
- StringRef ToolsetDir = llvm::sys::path::filename(LI->path());
- unsigned ToolsetVersion;
- if ((!ToolsetDir.startswith("gcc-toolset-") &&
- !ToolsetDir.startswith("devtoolset-")) ||
- ToolsetDir.substr(ToolsetDir.rfind('-') + 1)
- .getAsInteger(10, ToolsetVersion))
- continue;
-
- if (ToolsetVersion > ChosenToolsetVersion) {
- ChosenToolsetVersion = ToolsetVersion;
- ChosenToolsetDir = "/opt/rh/" + ToolsetDir.str();
- }
- }
-
- if (ChosenToolsetVersion > 0)
- Prefixes.push_back(ChosenToolsetDir);
+ Prefixes.push_back("/opt/rh/gcc-toolset-11/root/usr");
+ Prefixes.push_back("/opt/rh/gcc-toolset-10/root/usr");
+ Prefixes.push_back("/opt/rh/devtoolset-11/root/usr");
+ Prefixes.push_back("/opt/rh/devtoolset-10/root/usr");
+ Prefixes.push_back("/opt/rh/devtoolset-9/root/usr");
+ Prefixes.push_back("/opt/rh/devtoolset-8/root/usr");
+ Prefixes.push_back("/opt/rh/devtoolset-7/root/usr");
+ Prefixes.push_back("/opt/rh/devtoolset-6/root/usr");
+ Prefixes.push_back("/opt/rh/devtoolset-4/root/usr");
+ Prefixes.push_back("/opt/rh/devtoolset-3/root/usr");
+ Prefixes.push_back("/opt/rh/devtoolset-2/root/usr");
}
// Fall back to /usr which is used by most non-Solaris systems.
diff --git a/clang/unittests/Driver/ToolChainTest.cpp b/clang/unittests/Driver/ToolChainTest.cpp
index 4d2d938..c652b09 100644
--- a/clang/unittests/Driver/ToolChainTest.cpp
+++ b/clang/unittests/Driver/ToolChainTest.cpp
@@ -610,92 +610,4 @@ TEST(DxcModeTest, ValidatorVersionValidation) {
DiagConsumer->clear();
}
-TEST(ToolChainTest, Toolsets) {
- IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions();
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
- struct TestDiagnosticConsumer : public DiagnosticConsumer {};
-
- // Check (newer) GCC toolset installation.
- {
- IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
-
- // These should be ignored
- InMemoryFileSystem->addFile("/opt/rh/gcc-toolset-2", 0,
- llvm::MemoryBuffer::getMemBuffer("\n"));
- InMemoryFileSystem->addFile("/opt/rh/gcc-toolset-", 0,
- llvm::MemoryBuffer::getMemBuffer("\n"));
- InMemoryFileSystem->addFile("/opt/rh/gcc-toolset--", 0,
- llvm::MemoryBuffer::getMemBuffer("\n"));
- InMemoryFileSystem->addFile("/opt/rh/gcc-toolset--1", 0,
- llvm::MemoryBuffer::getMemBuffer("\n"));
-
- // File needed for GCC installation detection.
- InMemoryFileSystem->addFile(
- "/opt/rh/gcc-toolset-12/lib/gcc/x86_64-redhat-linux/11/crtbegin.o", 0,
- llvm::MemoryBuffer::getMemBuffer("\n"));
-
- DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer);
- Driver TheDriver("/bin/clang", "x86_64-redhat-linux", Diags,
- "clang LLVM compiler", InMemoryFileSystem);
- std::unique_ptr<Compilation> C(TheDriver.BuildCompilation({"-v"}));
- ASSERT_TRUE(C);
- std::string S;
- {
- llvm::raw_string_ostream OS(S);
- C->getDefaultToolChain().printVerboseInfo(OS);
- }
- if (is_style_windows(llvm::sys::path::Style::native))
- std::replace(S.begin(), S.end(), '\\', '/');
- EXPECT_EQ("Found candidate GCC installation: "
- "/opt/rh/gcc-toolset-12/lib/gcc/x86_64-redhat-linux/11\n"
- "Selected GCC installation: "
- "/opt/rh/gcc-toolset-12/lib/gcc/x86_64-redhat-linux/11\n"
- "Candidate multilib: .;@m64\n"
- "Selected multilib: .;@m64\n",
- S);
- }
-
- // And older devtoolset.
- {
- IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
-
- // These should be ignored
- InMemoryFileSystem->addFile("/opt/rh/devtoolset-2", 0,
- llvm::MemoryBuffer::getMemBuffer("\n"));
- InMemoryFileSystem->addFile("/opt/rh/devtoolset-", 0,
- llvm::MemoryBuffer::getMemBuffer("\n"));
- InMemoryFileSystem->addFile("/opt/rh/devtoolset--", 0,
- llvm::MemoryBuffer::getMemBuffer("\n"));
- InMemoryFileSystem->addFile("/opt/rh/devtoolset--1", 0,
- llvm::MemoryBuffer::getMemBuffer("\n"));
-
- // File needed for GCC installation detection.
- InMemoryFileSystem->addFile(
- "/opt/rh/devtoolset-12/lib/gcc/x86_64-redhat-linux/11/crtbegin.o", 0,
- llvm::MemoryBuffer::getMemBuffer("\n"));
-
- DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer);
- Driver TheDriver("/bin/clang", "x86_64-redhat-linux", Diags,
- "clang LLVM compiler", InMemoryFileSystem);
- std::unique_ptr<Compilation> C(TheDriver.BuildCompilation({"-v"}));
- ASSERT_TRUE(C);
- std::string S;
- {
- llvm::raw_string_ostream OS(S);
- C->getDefaultToolChain().printVerboseInfo(OS);
- }
- if (is_style_windows(llvm::sys::path::Style::native))
- std::replace(S.begin(), S.end(), '\\', '/');
- EXPECT_EQ("Found candidate GCC installation: "
- "/opt/rh/devtoolset-12/lib/gcc/x86_64-redhat-linux/11\n"
- "Selected GCC installation: "
- "/opt/rh/devtoolset-12/lib/gcc/x86_64-redhat-linux/11\n"
- "Candidate multilib: .;@m64\n"
- "Selected multilib: .;@m64\n",
- S);
- }
-}
-
} // end anonymous namespace.