[clang] 5ed9e5c - [clang] [MinGW] Consider the per-target libc++ include directory too

Martin Storsjö via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 12 03:27:47 PDT 2021


Author: Martin Storsjö
Date: 2021-08-12T13:27:09+03:00
New Revision: 5ed9e5c2c0ee9a77ed4a2a5bd817b03acf78fbac

URL: https://github.com/llvm/llvm-project/commit/5ed9e5c2c0ee9a77ed4a2a5bd817b03acf78fbac
DIFF: https://github.com/llvm/llvm-project/commit/5ed9e5c2c0ee9a77ed4a2a5bd817b03acf78fbac.diff

LOG: [clang] [MinGW] Consider the per-target libc++ include directory too

The existing logic for per-target libc++ include directories only
seem to exist for the Gnu and Fuchsia drivers, added in
ea12d779bc238c387511fe7462020f4ecf4a8246 / D89013.

This is less generic than the corresponding case in the Gnu driver,
but matches the existing level of genericity in the MinGW driver
(and others too).

Differential Revision: https://reviews.llvm.org/D107893

Added: 
    clang/test/Driver/Inputs/mingw_clang_tree/mingw32/include/i686-unknown-windows-gnu/c++/v1/.keep

Modified: 
    clang/lib/Driver/ToolChains/MinGW.cpp
    clang/test/Driver/mingw.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp
index 7ba729f36bd87..1aaa941498322 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -588,12 +588,18 @@ void toolchains::MinGW::AddClangCXXStdlibIncludeArgs(
   StringRef Slash = llvm::sys::path::get_separator();
 
   switch (GetCXXStdlibType(DriverArgs)) {
-  case ToolChain::CST_Libcxx:
+  case ToolChain::CST_Libcxx: {
+    std::string TargetDir = (Base + "include" + Slash + getTripleString() +
+                             Slash + "c++" + Slash + "v1")
+                                .str();
+    if (getDriver().getVFS().exists(TargetDir))
+      addSystemInclude(DriverArgs, CC1Args, TargetDir);
     addSystemInclude(DriverArgs, CC1Args, Base + Arch + Slash + "include" +
                                               Slash + "c++" + Slash + "v1");
     addSystemInclude(DriverArgs, CC1Args,
                      Base + "include" + Slash + "c++" + Slash + "v1");
     break;
+  }
 
   case ToolChain::CST_Libstdcxx:
     llvm::SmallVector<llvm::SmallString<1024>, 4> CppIncludeBases;

diff  --git a/clang/test/Driver/Inputs/mingw_clang_tree/mingw32/include/i686-unknown-windows-gnu/c++/v1/.keep b/clang/test/Driver/Inputs/mingw_clang_tree/mingw32/include/i686-unknown-windows-gnu/c++/v1/.keep
new file mode 100644
index 0000000000000..e69de29bb2d1d

diff  --git a/clang/test/Driver/mingw.cpp b/clang/test/Driver/mingw.cpp
index 83b61ba7d33f0..4d573f0f2125c 100644
--- a/clang/test/Driver/mingw.cpp
+++ b/clang/test/Driver/mingw.cpp
@@ -4,6 +4,7 @@
 
 
 // RUN: %clang -target i686-windows-gnu -rtlib=platform -stdlib=libc++ -c -### --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck -check-prefix=CHECK_MINGW_CLANG_TREE_LIBCXX %s
+// CHECK_MINGW_CLANG_TREE_LIBCXX: "[[BASE:[^"]+]]/Inputs/mingw_clang_tree/mingw32{{/|\\\\}}include{{/|\\\\}}i686-unknown-windows-gnu{{/|\\\\}}c++{{/|\\\\}}v1"
 // CHECK_MINGW_CLANG_TREE_LIBCXX: "[[BASE:[^"]+]]/Inputs/mingw_clang_tree/mingw32{{/|\\\\}}i686-w64-mingw32{{/|\\\\}}include{{/|\\\\}}c++{{/|\\\\}}v1"
 
 


        


More information about the cfe-commits mailing list