Skip to content

Conversation

CendioOssman
Copy link

The current code did not work with a standard gcc cross-compiler layout, and there was a lot of internal confusion in the code about what different directories need to be tracked and where to track them.

This tries to do some cleanup of this, trying to get closer to the primary gcc code in Gnu.cpp.

Long term, it might be best to drop this duplication and make the MinGW toolchain use the same gcc handling code as the other gcc platforms.

A cross compiling gcc is generally installed outside of the sysroot, so
we should always search the root system for gcc as well.
These won't work reliably as we can only specify the sysroot path, not
the mock system root directory (for finding the gcc installation).
Not a general base directory that we assume has a triple subdirectory
with gcc's tooldir in it.
Later ones might be for a different gcc (e.g. system gcc rather than a
target specific one).
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Aug 25, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 25, 2025

@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Pierre Ossman (ThinLinc team) (CendioOssman)

Changes

The current code did not work with a standard gcc cross-compiler layout, and there was a lot of internal confusion in the code about what different directories need to be tracked and where to track them.

This tries to do some cleanup of this, trying to get closer to the primary gcc code in Gnu.cpp.

Long term, it might be best to drop this duplication and make the MinGW toolchain use the same gcc handling code as the other gcc platforms.


Patch is 32.08 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/155239.diff

16 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/MinGW.cpp (+95-54)
  • (modified) clang/lib/Driver/ToolChains/MinGW.h (+1)
  • (removed) clang/test/Driver/Inputs/mingw_fedora_tree/usr/lib/gcc/x86_64-w64-mingw32ucrt/12.2.1/include-fixed/.keep ()
  • (removed) clang/test/Driver/Inputs/mingw_fedora_tree/usr/x86_64-w64-mingw32ucrt/sys-root/mingw/include/.keep ()
  • (removed) clang/test/Driver/Inputs/mingw_fedora_tree/usr/x86_64-w64-mingw32ucrt/sys-root/mingw/include/c++/backward/.keep ()
  • (removed) clang/test/Driver/Inputs/mingw_fedora_tree/usr/x86_64-w64-mingw32ucrt/sys-root/mingw/include/c++/x86_64-w64-mingw32ucrt/.keep ()
  • (removed) clang/test/Driver/Inputs/mingw_mingw_builds_tree/mingw32/i686-w64-mingw32/include/c++/backward/.keep ()
  • (removed) clang/test/Driver/Inputs/mingw_mingw_builds_tree/mingw32/i686-w64-mingw32/include/c++/i686-w64-mingw32/.keep ()
  • (removed) clang/test/Driver/Inputs/mingw_mingw_builds_tree/mingw32/lib/gcc/i686-w64-mingw32/4.9.1/include-fixed/.keep ()
  • (removed) clang/test/Driver/Inputs/mingw_mingw_builds_tree/mingw32/lib/gcc/i686-w64-mingw32/4.9.1/include/.keep ()
  • (removed) clang/test/Driver/Inputs/mingw_opensuse_tree/usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/include-fixed/.keep ()
  • (removed) clang/test/Driver/Inputs/mingw_opensuse_tree/usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/include/c++/backward/.keep ()
  • (removed) clang/test/Driver/Inputs/mingw_opensuse_tree/usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/include/c++/x86_64-w64-mingw32/.keep ()
  • (removed) clang/test/Driver/Inputs/mingw_opensuse_tree/usr/x86_64-w64-mingw32/sys-root/mingw/include/.keep ()
  • (modified) clang/test/Driver/mingw-sysroot.cpp (+3-28)
  • (modified) clang/test/Driver/mingw.cpp (+16-45)
diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp
index 1bb9bcfe6aab2..999a9e1e180d9 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -422,6 +422,12 @@ static llvm::Triple getLiteralTriple(const Driver &D, const llvm::Triple &T) {
 }
 
 void toolchains::MinGW::findGccLibDir(const llvm::Triple &LiteralTriple) {
+  std::string InstallBase =
+      std::string(llvm::sys::path::parent_path(getDriver().Dir));
+  llvm::SmallVector<llvm::SmallString<32>, 3> BaseNames;
+  BaseNames.emplace_back(Base);
+  BaseNames.emplace_back(InstallBase);
+  BaseNames.emplace_back("/usr");
   llvm::SmallVector<llvm::SmallString<32>, 5> SubdirNames;
   SubdirNames.emplace_back(LiteralTriple.str());
   SubdirNames.emplace_back(getTriple().str());
@@ -430,46 +436,75 @@ void toolchains::MinGW::findGccLibDir(const llvm::Triple &LiteralTriple) {
   SubdirNames.emplace_back(getTriple().getArchName());
   SubdirNames.back() += "-w64-mingw32ucrt";
   SubdirNames.emplace_back("mingw32");
-  if (SubdirName.empty()) {
-    SubdirName = getTriple().getArchName();
-    SubdirName += "-w64-mingw32";
+  TripleDirName = getTriple().getArchName();
+  TripleDirName += "-w64-mingw32";
+  // FIXME: Should pick the newest version
+  for (StringRef CandidateBase : BaseNames) {
+    // lib: Arch Linux, Ubuntu, Windows
+    // lib64: openSUSE Linux
+    for (StringRef CandidateLib : {"lib", "lib64"}) {
+      for (StringRef CandidateTriple : SubdirNames) {
+        llvm::SmallString<1024> LibDir(CandidateBase);
+        llvm::sys::path::append(LibDir, CandidateLib, "gcc", CandidateTriple);
+        if (findGccVersion(LibDir, GccLibDir, Ver, GccVer)) {
+          llvm::SmallString<1024> ParentLib(LibDir);
+          llvm::sys::path::append(ParentLib, "..", "..");
+          GccParentLibPath = ParentLib.str();
+          TripleDirName = std::string(CandidateTriple);
+          return;
+        }
+      }
+    }
   }
-  // lib: Arch Linux, Ubuntu, Windows
-  // lib64: openSUSE Linux
+  // Let's try to find it relative a decorated gcc binary
   for (StringRef CandidateLib : {"lib", "lib64"}) {
-    for (StringRef CandidateSysroot : SubdirNames) {
-      llvm::SmallString<1024> LibDir(Base);
-      llvm::sys::path::append(LibDir, CandidateLib, "gcc", CandidateSysroot);
+    for (StringRef CandidateTriple : SubdirNames) {
+      llvm::ErrorOr<std::string> GPPName =
+        llvm::sys::findProgramByName(CandidateTriple.str() + "-gcc");
+      if (!GPPName)
+        continue;
+      llvm::SmallString<1024> LibDir;
+      llvm::sys::path::append(LibDir, llvm::sys::path::parent_path(llvm::sys::path::parent_path(GPPName.get())));
+      llvm::sys::path::append(LibDir, CandidateLib, "gcc", CandidateTriple);
       if (findGccVersion(LibDir, GccLibDir, Ver, GccVer)) {
-        SubdirName = std::string(CandidateSysroot);
+        llvm::SmallString<1024> ParentLib(LibDir);
+        llvm::sys::path::append(ParentLib, "..", "..");
+        GccParentLibPath = ParentLib.str();
+        TripleDirName = std::string(CandidateTriple);
         return;
       }
     }
   }
 }
 
-static llvm::ErrorOr<std::string> findGcc(const llvm::Triple &LiteralTriple,
-                                          const llvm::Triple &T) {
+static llvm::ErrorOr<std::string> findGccRelativeSysroot(
+    const llvm::Triple &LiteralTriple, const llvm::Triple &T) {
   llvm::SmallVector<llvm::SmallString<32>, 5> Gccs;
   Gccs.emplace_back(LiteralTriple.str());
-  Gccs.back() += "-gcc";
   Gccs.emplace_back(T.str());
-  Gccs.back() += "-gcc";
   Gccs.emplace_back(T.getArchName());
-  Gccs.back() += "-w64-mingw32-gcc";
+  Gccs.back() += "-w64-mingw32";
   Gccs.emplace_back(T.getArchName());
-  Gccs.back() += "-w64-mingw32ucrt-gcc";
-  Gccs.emplace_back("mingw32-gcc");
+  Gccs.back() += "-w64-mingw32ucrt";
+  Gccs.emplace_back("mingw32");
   // Please do not add "gcc" here
-  for (StringRef CandidateGcc : Gccs)
-    if (llvm::ErrorOr<std::string> GPPName = llvm::sys::findProgramByName(CandidateGcc))
-      return GPPName;
+  for (StringRef CandidateGcc : Gccs) {
+    llvm::ErrorOr<std::string> GPPName =
+      llvm::sys::findProgramByName(CandidateGcc.str() + "-gcc");
+    llvm::SmallString<1024> SysrootDir;
+    if (!GPPName)
+      continue;
+    llvm::sys::path::append(SysrootDir, llvm::sys::path::parent_path(llvm::sys::path::parent_path(GPPName.get())));
+    llvm::sys::path::append(SysrootDir, CandidateGcc);
+    if (llvm::sys::fs::is_directory(SysrootDir))
+      return SysrootDir.str().str();
+  }
   return make_error_code(std::errc::no_such_file_or_directory);
 }
 
 static llvm::ErrorOr<std::string>
 findClangRelativeSysroot(const Driver &D, const llvm::Triple &LiteralTriple,
-                         const llvm::Triple &T, std::string &SubdirName) {
+                         const llvm::Triple &T) {
   llvm::SmallVector<llvm::SmallString<32>, 4> Subdirs;
   Subdirs.emplace_back(LiteralTriple.str());
   Subdirs.emplace_back(T.str());
@@ -481,7 +516,8 @@ findClangRelativeSysroot(const Driver &D, const llvm::Triple &LiteralTriple,
   StringRef Sep = llvm::sys::path::get_separator();
   for (StringRef CandidateSubdir : Subdirs) {
     if (llvm::sys::fs::is_directory(ClangRoot + Sep + CandidateSubdir)) {
-      SubdirName = std::string(CandidateSubdir);
+      if (llvm::sys::fs::is_directory(ClangRoot + Sep + CandidateSubdir + Sep + "sys-root"))
+        return (ClangRoot + Sep + CandidateSubdir + Sep + "sys-root").str();
       return (ClangRoot + Sep + CandidateSubdir).str();
     }
   }
@@ -510,41 +546,38 @@ toolchains::MinGW::MinGW(const Driver &D, const llvm::Triple &Triple,
   llvm::Triple LiteralTriple = getLiteralTriple(D, getTriple());
   if (getDriver().SysRoot.size())
     Base = getDriver().SysRoot;
-  // Look for <clang-bin>/../<triplet>; if found, use <clang-bin>/.. as the
-  // base as it could still be a base for a gcc setup with libgcc.
+  // Look for <clang-bin>/../<triplet>
   else if (llvm::ErrorOr<std::string> TargetSubdir = findClangRelativeSysroot(
-               getDriver(), LiteralTriple, getTriple(), SubdirName))
-    Base = std::string(llvm::sys::path::parent_path(TargetSubdir.get()));
+               getDriver(), LiteralTriple, getTriple()))
+    Base = TargetSubdir.get();
   // If the install base of Clang seems to have mingw sysroot files directly
   // in the toplevel include and lib directories, use this as base instead of
   // looking for a triple prefixed GCC in the path.
   else if (looksLikeMinGWSysroot(InstallBase))
     Base = InstallBase;
-  else if (llvm::ErrorOr<std::string> GPPName =
-               findGcc(LiteralTriple, getTriple()))
-    Base = std::string(llvm::sys::path::parent_path(
-        llvm::sys::path::parent_path(GPPName.get())));
+  else if (llvm::ErrorOr<std::string> TargetSubdir =
+               findGccRelativeSysroot(LiteralTriple, getTriple()))
+    Base = TargetSubdir.get();
   else
     Base = InstallBase;
 
   Base += llvm::sys::path::get_separator();
   findGccLibDir(LiteralTriple);
-  TripleDirName = SubdirName;
   // GccLibDir must precede Base/lib so that the
   // correct crtbegin.o ,cetend.o would be found.
   getFilePaths().push_back(GccLibDir);
+  std::string CandidateGccLibDir = GccParentLibPath + "/../" + TripleDirName + "/lib";
+  if (getDriver().getVFS().exists(CandidateGccLibDir))
+    getFilePaths().push_back(CandidateGccLibDir);
 
-  // openSUSE/Fedora
-  std::string CandidateSubdir = SubdirName + "/sys-root/mingw";
-  if (getDriver().getVFS().exists(Base + CandidateSubdir))
+  // openSUSE/Fedora/Gentoo
+  std::string CandidateSubdir = "mingw";
+  if (getDriver().getVFS().exists(Base + CandidateSubdir)) {
     SubdirName = CandidateSubdir;
+    SubdirName += llvm::sys::path::get_separator();
+  }
 
-  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());
+  getFilePaths().push_back(Base + SubdirName + "lib");
 
   // 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
@@ -704,13 +737,10 @@ void toolchains::MinGW::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
   if (DriverArgs.hasArg(options::OPT_nostdlibinc))
     return;
 
-  addSystemInclude(DriverArgs, CC1Args,
-                   Base + SubdirName + llvm::sys::path::get_separator() +
-                       "include");
+  addSystemInclude(DriverArgs, CC1Args, Base + SubdirName + "include");
 
   // Gentoo
-  addSystemInclude(DriverArgs, CC1Args,
-                   Base + SubdirName + llvm::sys::path::get_separator() + "usr/include");
+  addSystemInclude(DriverArgs, CC1Args, Base + SubdirName + "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),
@@ -789,7 +819,7 @@ void toolchains::MinGW::AddClangCXXStdlibIncludeArgs(
     if (getDriver().getVFS().exists(TargetDir))
       addSystemInclude(DriverArgs, CC1Args, TargetDir);
     addSystemInclude(DriverArgs, CC1Args,
-                     Base + SubdirName + Slash + "include" + Slash + "c++" +
+                     Base + SubdirName + "include" + Slash + "c++" +
                          Slash + "v1");
     addSystemInclude(DriverArgs, CC1Args,
                      Base + "include" + Slash + "c++" + Slash + "v1");
@@ -797,7 +827,7 @@ void toolchains::MinGW::AddClangCXXStdlibIncludeArgs(
   }
 
   case ToolChain::CST_Libstdcxx:
-    llvm::SmallVector<llvm::SmallString<1024>, 7> CppIncludeBases;
+    llvm::SmallVector<llvm::SmallString<1024>, 9> CppIncludeBases;
     CppIncludeBases.emplace_back(Base);
     llvm::sys::path::append(CppIncludeBases[0], SubdirName, "include", "c++");
     CppIncludeBases.emplace_back(Base);
@@ -805,22 +835,33 @@ void toolchains::MinGW::AddClangCXXStdlibIncludeArgs(
                             Ver);
     CppIncludeBases.emplace_back(Base);
     llvm::sys::path::append(CppIncludeBases[2], "include", "c++", Ver);
+    CppIncludeBases.emplace_back(GccParentLibPath);
+    llvm::sys::path::append(CppIncludeBases[3], "..", TripleDirName);
+    llvm::sys::path::append(CppIncludeBases[3], "include", "c++", GccVer.Text);
+    CppIncludeBases.emplace_back(GccParentLibPath);
+    llvm::sys::path::append(CppIncludeBases[4],
+                            "gcc", TripleDirName, GccVer.Text);
+    llvm::sys::path::append(CppIncludeBases[4], "include", "c++");
+    CppIncludeBases.emplace_back(GccParentLibPath);
+    llvm::sys::path::append(CppIncludeBases[5],
+                            "..", "include", "c++", GccVer.Text);
     CppIncludeBases.emplace_back(GccLibDir);
-    llvm::sys::path::append(CppIncludeBases[3], "include", "c++");
-    CppIncludeBases.emplace_back(GccLibDir);
-    llvm::sys::path::append(CppIncludeBases[4], "include",
+    llvm::sys::path::append(CppIncludeBases[6], "include",
                             "g++-v" + GccVer.Text);
     CppIncludeBases.emplace_back(GccLibDir);
-    llvm::sys::path::append(CppIncludeBases[5], "include",
+    llvm::sys::path::append(CppIncludeBases[7], "include",
                             "g++-v" + GccVer.MajorStr + "." + GccVer.MinorStr);
     CppIncludeBases.emplace_back(GccLibDir);
-    llvm::sys::path::append(CppIncludeBases[6], "include",
+    llvm::sys::path::append(CppIncludeBases[8], "include",
                             "g++-v" + GccVer.MajorStr);
     for (auto &CppIncludeBase : CppIncludeBases) {
+      if (!getDriver().getVFS().exists(CppIncludeBase))
+        continue;
       addSystemInclude(DriverArgs, CC1Args, CppIncludeBase);
       CppIncludeBase += Slash;
       addSystemInclude(DriverArgs, CC1Args, CppIncludeBase + TripleDirName);
       addSystemInclude(DriverArgs, CC1Args, CppIncludeBase + "backward");
+      break;
     }
     break;
   }
@@ -830,19 +871,19 @@ static bool testTriple(const Driver &D, const llvm::Triple &Triple,
                        const ArgList &Args) {
   // If an explicit sysroot is set, that will be used and we shouldn't try to
   // detect anything else.
-  std::string SubdirName;
   if (D.SysRoot.size())
     return true;
   llvm::Triple LiteralTriple = getLiteralTriple(D, Triple);
   std::string InstallBase = std::string(llvm::sys::path::parent_path(D.Dir));
   if (llvm::ErrorOr<std::string> TargetSubdir =
-          findClangRelativeSysroot(D, LiteralTriple, Triple, SubdirName))
+          findClangRelativeSysroot(D, LiteralTriple, Triple))
     return true;
   // If the install base itself looks like a mingw sysroot, we'll use that
   // - don't use any potentially unrelated gcc to influence what triple to use.
   if (looksLikeMinGWSysroot(InstallBase))
     return false;
-  if (llvm::ErrorOr<std::string> GPPName = findGcc(LiteralTriple, Triple))
+  if (llvm::ErrorOr<std::string> TargetSubdir =
+          findGccRelativeSysroot(LiteralTriple, Triple))
     return true;
   // If we neither found a colocated sysroot or a matching gcc executable,
   // conclude that we can't know if this is the correct spelling of the triple.
diff --git a/clang/lib/Driver/ToolChains/MinGW.h b/clang/lib/Driver/ToolChains/MinGW.h
index 1730da48cd434..dad72fe1e90b3 100644
--- a/clang/lib/Driver/ToolChains/MinGW.h
+++ b/clang/lib/Driver/ToolChains/MinGW.h
@@ -109,6 +109,7 @@ class LLVM_LIBRARY_VISIBILITY MinGW : public ToolChain {
 
   std::string Base;
   std::string GccLibDir;
+  std::string GccParentLibPath;
   clang::driver::toolchains::Generic_GCC::GCCVersion GccVer;
   std::string Ver;
   std::string SubdirName;
diff --git a/clang/test/Driver/Inputs/mingw_fedora_tree/usr/lib/gcc/x86_64-w64-mingw32ucrt/12.2.1/include-fixed/.keep b/clang/test/Driver/Inputs/mingw_fedora_tree/usr/lib/gcc/x86_64-w64-mingw32ucrt/12.2.1/include-fixed/.keep
deleted file mode 100644
index e69de29bb2d1d..0000000000000
diff --git a/clang/test/Driver/Inputs/mingw_fedora_tree/usr/x86_64-w64-mingw32ucrt/sys-root/mingw/include/.keep b/clang/test/Driver/Inputs/mingw_fedora_tree/usr/x86_64-w64-mingw32ucrt/sys-root/mingw/include/.keep
deleted file mode 100644
index e69de29bb2d1d..0000000000000
diff --git a/clang/test/Driver/Inputs/mingw_fedora_tree/usr/x86_64-w64-mingw32ucrt/sys-root/mingw/include/c++/backward/.keep b/clang/test/Driver/Inputs/mingw_fedora_tree/usr/x86_64-w64-mingw32ucrt/sys-root/mingw/include/c++/backward/.keep
deleted file mode 100644
index e69de29bb2d1d..0000000000000
diff --git a/clang/test/Driver/Inputs/mingw_fedora_tree/usr/x86_64-w64-mingw32ucrt/sys-root/mingw/include/c++/x86_64-w64-mingw32ucrt/.keep b/clang/test/Driver/Inputs/mingw_fedora_tree/usr/x86_64-w64-mingw32ucrt/sys-root/mingw/include/c++/x86_64-w64-mingw32ucrt/.keep
deleted file mode 100644
index e69de29bb2d1d..0000000000000
diff --git a/clang/test/Driver/Inputs/mingw_mingw_builds_tree/mingw32/i686-w64-mingw32/include/c++/backward/.keep b/clang/test/Driver/Inputs/mingw_mingw_builds_tree/mingw32/i686-w64-mingw32/include/c++/backward/.keep
deleted file mode 100644
index e69de29bb2d1d..0000000000000
diff --git a/clang/test/Driver/Inputs/mingw_mingw_builds_tree/mingw32/i686-w64-mingw32/include/c++/i686-w64-mingw32/.keep b/clang/test/Driver/Inputs/mingw_mingw_builds_tree/mingw32/i686-w64-mingw32/include/c++/i686-w64-mingw32/.keep
deleted file mode 100644
index e69de29bb2d1d..0000000000000
diff --git a/clang/test/Driver/Inputs/mingw_mingw_builds_tree/mingw32/lib/gcc/i686-w64-mingw32/4.9.1/include-fixed/.keep b/clang/test/Driver/Inputs/mingw_mingw_builds_tree/mingw32/lib/gcc/i686-w64-mingw32/4.9.1/include-fixed/.keep
deleted file mode 100644
index e69de29bb2d1d..0000000000000
diff --git a/clang/test/Driver/Inputs/mingw_mingw_builds_tree/mingw32/lib/gcc/i686-w64-mingw32/4.9.1/include/.keep b/clang/test/Driver/Inputs/mingw_mingw_builds_tree/mingw32/lib/gcc/i686-w64-mingw32/4.9.1/include/.keep
deleted file mode 100644
index e69de29bb2d1d..0000000000000
diff --git a/clang/test/Driver/Inputs/mingw_opensuse_tree/usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/include-fixed/.keep b/clang/test/Driver/Inputs/mingw_opensuse_tree/usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/include-fixed/.keep
deleted file mode 100644
index e69de29bb2d1d..0000000000000
diff --git a/clang/test/Driver/Inputs/mingw_opensuse_tree/usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/include/c++/backward/.keep b/clang/test/Driver/Inputs/mingw_opensuse_tree/usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/include/c++/backward/.keep
deleted file mode 100644
index e69de29bb2d1d..0000000000000
diff --git a/clang/test/Driver/Inputs/mingw_opensuse_tree/usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/include/c++/x86_64-w64-mingw32/.keep b/clang/test/Driver/Inputs/mingw_opensuse_tree/usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/include/c++/x86_64-w64-mingw32/.keep
deleted file mode 100644
index e69de29bb2d1d..0000000000000
diff --git a/clang/test/Driver/Inputs/mingw_opensuse_tree/usr/x86_64-w64-mingw32/sys-root/mingw/include/.keep b/clang/test/Driver/Inputs/mingw_opensuse_tree/usr/x86_64-w64-mingw32/sys-root/mingw/include/.keep
deleted file mode 100644
index e69de29bb2d1d..0000000000000
diff --git a/clang/test/Driver/mingw-sysroot.cpp b/clang/test/Driver/mingw-sysroot.cpp
index 0ba2f336fd2e0..47e6c7f8ba600 100644
--- a/clang/test/Driver/mingw-sysroot.cpp
+++ b/clang/test/Driver/mingw-sysroot.cpp
@@ -34,12 +34,9 @@
 // cross toolchains installed in /usr.
 
 // RUN: env "PATH=%t.dir/testroot-gcc/bin:%PATH%" %clang --target=x86_64-w64-mingw32 -rtlib=platform -stdlib=libstdc++ --sysroot="" -c -### %s 2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_GCC %s --implicit-check-not="\"{{.*}}/testroot-gcc{{/|\\\\}}include\""
-// 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{{/|\\\\}}lib{{/|\\\\}}gcc{{/|\\\\}}x86_64-w64-mingw32{{/|\\\\}}..{{/|\\\\}}..{{/|\\\\}}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{{/|\\\\}}..{{/|\\\\}}..{{/|\\\\}}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{{/|\\\\}}..{{/|\\\\}}..{{/|\\\\}}gcc{{/|\\\\}}x86_64-w64-mingw32{{/|\\\\}}10.2-posix{{/|\\\\}}include{{/|\\\\}}c++{{/|\\\\}}backward"
 // CHECK_TESTROOT_GCC: "-internal-isystem" "[[BASE]]/testroot-gcc{{/|\\\\}}x86_64-w64-mingw32{{/|\\\\}}include"
 
 
@@ -66,28 +63,6 @@
 // RUN: env "PATH=%t.dir/testroot-gcc/bin:%PATH%" %t.dir/testroot-gcc/bin/x86_64-w64-mingw32-clang --target=x86_64-w64-mingw32 -rtlib=platform -stdlib=libstdc++ --sysroot="" -c -### %s 2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_GCC %s
 
 
-// If we're executing clang from a directory with what looks like a mingw sysroot,
-// with headers in <base>/include and libs in <base>/lib, use that rather than looking
-// for another GCC in the path.
-//
-// Note, this test has a surprising quirk: We're testing with an install directory,
-// testroot-clang-native, which lacks the "x86_64-w64-mingw32" subdirectory, it only
-// has the include and lib subdirecto...
[truncated]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants