diff --git a/include/clang/Lex/HeaderSearchOptions.h b/include/clang/Lex/HeaderSearchOptions.h
index af4e7a1..fde50d5 100644
--- a/include/clang/Lex/HeaderSearchOptions.h
+++ b/include/clang/Lex/HeaderSearchOptions.h
@@ -158,6 +158,9 @@ public:
   /// Use libc++ instead of the default libstdc++.
   unsigned UseLibcxx : 1;
 
+  /// Ignore the libc++ headers while building the Darwin system module.
+  unsigned IgnoreLibCXXHeaders : 1;
+
   /// Whether header search information should be output as for -v.
   unsigned Verbose : 1;
 
@@ -178,7 +181,8 @@ public:
         ModuleCachePruneInterval(7 * 24 * 60 * 60),
         ModuleCachePruneAfter(31 * 24 * 60 * 60), BuildSessionTimestamp(0),
         UseBuiltinIncludes(true), UseStandardSystemIncludes(true),
-        UseStandardCXXIncludes(true), UseLibcxx(false), Verbose(false),
+        UseStandardCXXIncludes(true), UseLibcxx(false), IgnoreLibCXXHeaders(false),
+        Verbose(false),
         ModulesValidateOncePerBuildSession(false),
         ModulesValidateSystemHeaders(false),
         UseDebugInfo(false) {}
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp
index 740524c..cb05cd6 100644
--- a/lib/Frontend/CompilerInstance.cpp
+++ b/lib/Frontend/CompilerInstance.cpp
@@ -333,6 +333,10 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {
                          getFrontendOpts());
 
   // Initialize the header search object.
+  HeaderSearchOptions &HSOpts = Invocation->getHeaderSearchOpts();
+  if (getLangOpts().CurrentModule == "Darwin") {
+    HSOpts.IgnoreLibCXXHeaders = true;
+  }
   ApplyHeaderSearchOptions(PP->getHeaderSearchInfo(), getHeaderSearchOpts(),
                            PP->getLangOpts(), PP->getTargetInfo().getTriple());
 
diff --git a/lib/Frontend/InitHeaderSearch.cpp b/lib/Frontend/InitHeaderSearch.cpp
index 1de4627..5326cd6 100644
--- a/lib/Frontend/InitHeaderSearch.cpp
+++ b/lib/Frontend/InitHeaderSearch.cpp
@@ -452,7 +452,7 @@ void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang,
   }
 
   if (Lang.CPlusPlus && HSOpts.UseStandardCXXIncludes &&
-      HSOpts.UseStandardSystemIncludes) {
+      HSOpts.UseStandardSystemIncludes && !HSOpts.IgnoreLibCXXHeaders) {
     if (HSOpts.UseLibcxx) {
       if (triple.isOSDarwin()) {
         // On Darwin, libc++ may be installed alongside the compiler in
