[clang] Revert "[clang] [MinGW] Fix paths on Gentoo" (PR #219979)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 31 07:06:32 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-driver
Author: Zhongteng Gui (dragon-archer)
<details>
<summary>Changes</summary>
This reverts commit 8e218026f8d5eabfdef9141ae5e26aa91d1933e6.
Gentoo no longer uses mingw/lib and include/g++-vXX, see https://packages.gentoo.org/packages/dev-util/llvm-mingw64 and https://packages.gentoo.org/packages/dev-util/mingw64-toolchain.
On the otherhand, the original workaround unconditonally added these search paths, which is redudant to all other platforms and may cause problems for other users.
---
Full diff: https://github.com/llvm/llvm-project/pull/219979.diff
4 Files Affected:
- (modified) clang/lib/Driver/ToolChains/MinGW.cpp (+4-22)
- (modified) clang/lib/Driver/ToolChains/MinGW.h (-1)
- (modified) clang/test/Driver/mingw-sysroot.cpp (-3)
- (modified) clang/test/Driver/mingw.cpp (-1)
``````````diff
diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp
index 65120931d8181..9ecec7493e575 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -398,9 +398,8 @@ static bool isCrossCompiling(const llvm::Triple &T, bool RequireArchMatch) {
// Simplified from Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple.
static bool findGccVersion(StringRef LibDir, std::string &GccLibDir,
- std::string &Ver,
- toolchains::Generic_GCC::GCCVersion &Version) {
- Version = toolchains::Generic_GCC::GCCVersion::Parse("0.0.0");
+ std::string &Ver) {
+ auto Version = toolchains::Generic_GCC::GCCVersion::Parse("0.0.0");
std::error_code EC;
for (llvm::sys::fs::directory_iterator LI(LibDir, EC), LE; !EC && LI != LE;
LI = LI.increment(EC)) {
@@ -444,7 +443,7 @@ void toolchains::MinGW::findGccLibDir(const llvm::Triple &LiteralTriple) {
for (StringRef CandidateSysroot : SubdirNames) {
llvm::SmallString<1024> LibDir(Base);
llvm::sys::path::append(LibDir, CandidateLib, "gcc", CandidateSysroot);
- if (findGccVersion(LibDir, GccLibDir, Ver, GccVer)) {
+ if (findGccVersion(LibDir, GccLibDir, Ver)) {
SubdirName = std::string(CandidateSysroot);
return;
}
@@ -561,10 +560,6 @@ toolchains::MinGW::MinGW(const Driver &D, const llvm::Triple &Triple,
getFilePaths().push_back(
(Base + SubdirName + llvm::sys::path::get_separator() + "lib").str());
- // Gentoo
- getFilePaths().push_back(
- (Base + SubdirName + llvm::sys::path::get_separator() + "mingw/lib").str());
-
// Only include <base>/lib if we're not cross compiling (not even for
// windows->windows to a different arch), or if the sysroot has been set
// (where we presume the user has pointed it at an arch specific
@@ -749,10 +744,6 @@ void toolchains::MinGW::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
Base + SubdirName + llvm::sys::path::get_separator() +
"include");
- // Gentoo
- addSystemInclude(DriverArgs, CC1Args,
- Base + SubdirName + llvm::sys::path::get_separator() + "usr/include");
-
// Only include <base>/include if we're not cross compiling (but do allow it
// if we're on Windows and building for Windows on another architecture),
// or if the sysroot has been set (where we presume the user has pointed it
@@ -838,7 +829,7 @@ void toolchains::MinGW::AddClangCXXStdlibIncludeArgs(
}
case ToolChain::CST_Libstdcxx:
- llvm::SmallVector<llvm::SmallString<1024>, 7> CppIncludeBases;
+ llvm::SmallVector<llvm::SmallString<1024>, 4> CppIncludeBases;
CppIncludeBases.emplace_back(Base);
llvm::sys::path::append(CppIncludeBases[0], SubdirName, "include", "c++");
CppIncludeBases.emplace_back(Base);
@@ -848,15 +839,6 @@ void toolchains::MinGW::AddClangCXXStdlibIncludeArgs(
llvm::sys::path::append(CppIncludeBases[2], "include", "c++", Ver);
CppIncludeBases.emplace_back(GccLibDir);
llvm::sys::path::append(CppIncludeBases[3], "include", "c++");
- CppIncludeBases.emplace_back(GccLibDir);
- llvm::sys::path::append(CppIncludeBases[4], "include",
- "g++-v" + GccVer.Text);
- CppIncludeBases.emplace_back(GccLibDir);
- llvm::sys::path::append(CppIncludeBases[5], "include",
- "g++-v" + GccVer.MajorStr + "." + GccVer.MinorStr);
- CppIncludeBases.emplace_back(GccLibDir);
- llvm::sys::path::append(CppIncludeBases[6], "include",
- "g++-v" + GccVer.MajorStr);
for (auto &CppIncludeBase : CppIncludeBases) {
addSystemInclude(DriverArgs, CC1Args, CppIncludeBase);
CppIncludeBase += Slash;
diff --git a/clang/lib/Driver/ToolChains/MinGW.h b/clang/lib/Driver/ToolChains/MinGW.h
index c8b7a73af0a2d..336f1e4a67a2e 100644
--- a/clang/lib/Driver/ToolChains/MinGW.h
+++ b/clang/lib/Driver/ToolChains/MinGW.h
@@ -112,7 +112,6 @@ class LLVM_LIBRARY_VISIBILITY MinGW : public ToolChain {
std::string Base;
std::string GccLibDir;
- clang::driver::toolchains::Generic_GCC::GCCVersion GccVer;
std::string Ver;
std::string SubdirName;
std::string TripleDirName;
diff --git a/clang/test/Driver/mingw-sysroot.cpp b/clang/test/Driver/mingw-sysroot.cpp
index 372df0509c8d9..01c8a5c6ce70f 100644
--- a/clang/test/Driver/mingw-sysroot.cpp
+++ b/clang/test/Driver/mingw-sysroot.cpp
@@ -40,9 +40,6 @@
// CHECK_TESTROOT_GCC: "-internal-isystem" "[[BASE:[^"]+]]/testroot-gcc{{/|\\\\}}lib{{/|\\\\}}gcc{{/|\\\\}}x86_64-w64-mingw32{{/|\\\\}}10.2-posix{{/|\\\\}}include{{/|\\\\}}c++"
// CHECK_TESTROOT_GCC-SAME: {{^}} "-internal-isystem" "[[BASE]]/testroot-gcc{{/|\\\\}}lib{{/|\\\\}}gcc{{/|\\\\}}x86_64-w64-mingw32{{/|\\\\}}10.2-posix{{/|\\\\}}include{{/|\\\\}}c++{{/|\\\\}}x86_64-w64-mingw32"
// CHECK_TESTROOT_GCC-SAME: {{^}} "-internal-isystem" "[[BASE]]/testroot-gcc{{/|\\\\}}lib{{/|\\\\}}gcc{{/|\\\\}}x86_64-w64-mingw32{{/|\\\\}}10.2-posix{{/|\\\\}}include{{/|\\\\}}c++{{/|\\\\}}backward"
-// CHECK_TESTROOT_GCC: "-internal-isystem" "[[BASE]]/testroot-gcc{{/|\\\\}}lib{{/|\\\\}}gcc{{/|\\\\}}x86_64-w64-mingw32{{/|\\\\}}10.2-posix{{/|\\\\}}include{{/|\\\\}}g++-v10.2-posix"
-// CHECK_TESTROOT_GCC: "-internal-isystem" "[[BASE]]/testroot-gcc{{/|\\\\}}lib{{/|\\\\}}gcc{{/|\\\\}}x86_64-w64-mingw32{{/|\\\\}}10.2-posix{{/|\\\\}}include{{/|\\\\}}g++-v10.2"
-// CHECK_TESTROOT_GCC: "-internal-isystem" "[[BASE]]/testroot-gcc{{/|\\\\}}lib{{/|\\\\}}gcc{{/|\\\\}}x86_64-w64-mingw32{{/|\\\\}}10.2-posix{{/|\\\\}}include{{/|\\\\}}g++-v10"
// CHECK_TESTROOT_GCC: "-internal-isystem" "[[BASE]]/testroot-gcc{{/|\\\\}}x86_64-w64-mingw32{{/|\\\\}}include"
diff --git a/clang/test/Driver/mingw.cpp b/clang/test/Driver/mingw.cpp
index 9affd3ba6d5db..5f33c28d739f3 100644
--- a/clang/test/Driver/mingw.cpp
+++ b/clang/test/Driver/mingw.cpp
@@ -1,6 +1,5 @@
// RUN: %clang --target=i686-windows-gnu -rtlib=platform -c -### --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck -check-prefix=CHECK_MINGW_CLANG_TREE %s
// CHECK_MINGW_CLANG_TREE: "[[BASE:[^"]+]]/Inputs/mingw_clang_tree/mingw32{{/|\\\\}}i686-w64-mingw32{{/|\\\\}}include"
-// CHECK_MINGW_CLANG_TREE: "[[BASE:[^"]+]]/Inputs/mingw_clang_tree/mingw32{{/|\\\\}}i686-w64-mingw32{{/|\\\\}}usr{{/|\\\\}}include"
// CHECK_MINGW_CLANG_TREE: "[[BASE]]/Inputs/mingw_clang_tree/mingw32{{/|\\\\}}include"
``````````
</details>
https://github.com/llvm/llvm-project/pull/219979
More information about the cfe-commits
mailing list