]> granicus.if.org Git - clang/commitdiff
Darwin: pass -stdlib=libc++ down to cc1 whenever we're targeting libc++
authorTim Northover <tnorthover@apple.com>
Fri, 12 Feb 2016 22:30:42 +0000 (22:30 +0000)
committerTim Northover <tnorthover@apple.com>
Fri, 12 Feb 2016 22:30:42 +0000 (22:30 +0000)
Recent refactoring meant it only got passed down when explicitly specified,
which breaks header search on Darwin.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260755 91177308-0d34-0410-b5e6-96231b3b80d8

darwin-stdlib.cpp [new file with mode: 0644]
lib/Driver/ToolChains.cpp

diff --git a/darwin-stdlib.cpp b/darwin-stdlib.cpp
new file mode 100644 (file)
index 0000000..c9be607
--- /dev/null
@@ -0,0 +1,16 @@
+// RUN: %clang -target x86_64-apple-darwin -arch arm64 -miphoneos-version-min=7.0 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX
+// RUN: %clang -target x86_64-apple-darwin -mmacosx-version-min=10.8 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBSTDCXX
+// RUN: %clang -target x86_64-apple-darwin -mmacosx-version-min=10.9 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX
+// RUN: %clang -target x86_64-apple-darwin -arch armv7s -miphoneos-version-min=6.1 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBSTDCXX
+// RUN: %clang -target x86_64-apple-darwin -arch armv7s -miphoneos-version-min=7.0 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX
+// RUN: %clang -target x86_64-apple-darwin -arch armv7k %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX
+
+// The purpose of this test is that the libc++ headers should be found
+// properly. At the moment this is done by passing -stdlib=libc++ down to the
+// cc1 invocation. If and when we change to finding them in the driver this test
+// should reflect that.
+
+// CHECK-LIBCXX: -stdlib=libc++
+
+// CHECK-LIBSTDCXX-NOT: -stdlib=libc++
+// CHECK-LIBSTDCXX-NOT: -stdlib=libstdc++
index a357863b8fa33b7dd4cddbcddeb04ae61d8eb1df..6ce84daec11813e656c9ff4d52c16b74077c308a 100644 (file)
@@ -1030,6 +1030,7 @@ DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args,
                                       const char *BoundArch) const {
   // First get the generic Apple args, before moving onto Darwin-specific ones.
   DerivedArgList *DAL = MachO::TranslateArgs(Args, BoundArch);
+  const OptTable &Opts = getDriver().getOpts();
 
   // If no architecture is bound, none of the translations here are relevant.
   if (!BoundArch)
@@ -1060,6 +1061,11 @@ DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args,
     }
   }
 
+  if (!Args.getLastArg(options::OPT_stdlib_EQ) &&
+      GetDefaultCXXStdlibType() == ToolChain::CST_Libcxx)
+    DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_stdlib_EQ),
+                      "libc++");
+
   // Validate the C++ standard library choice.
   CXXStdlibType Type = GetCXXStdlibType(*DAL);
   if (Type == ToolChain::CST_Libcxx) {