https://github.com/dragon-archer created 
https://github.com/llvm/llvm-project/pull/219979

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.

>From 6f05169d061c67a66d4429410218bf933301d11b Mon Sep 17 00:00:00 2001
From: Zhongteng Gui <[email protected]>
Date: Mon, 31 Aug 2026 21:18:03 +0800
Subject: [PATCH] Revert "[clang] [MinGW] Fix paths on Gentoo"

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.
---
 clang/lib/Driver/ToolChains/MinGW.cpp | 26 ++++----------------------
 clang/lib/Driver/ToolChains/MinGW.h   |  1 -
 clang/test/Driver/mingw-sysroot.cpp   |  3 ---
 clang/test/Driver/mingw.cpp           |  1 -
 4 files changed, 4 insertions(+), 27 deletions(-)

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"
 
 

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to