From c5ccb78ade8136134e0ca9dde64de97f913f0f8c Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Wed, 3 Aug 2022 14:20:02 -0400 Subject: [PATCH] [clang][Darwin] Always set the default C++ Standard Library to libc++ Newer SDKs don't even provide libstdc++ headers, so it's effectively never valid to build for libstdc++ unless the user explicitly asks for it (in which case they will need to provide include paths and more). --- clang/lib/Driver/ToolChains/Darwin.cpp | 7 +------ clang/test/Driver/darwin-iphone-defaults.m | 2 +- clang/test/Driver/darwin-stdlib.cpp | 15 ++++++--------- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index bada811..7e3fc62 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -896,12 +896,7 @@ types::ID MachO::LookupTypeForExtension(StringRef Ext) const { bool MachO::HasNativeLLVMSupport() const { return true; } ToolChain::CXXStdlibType Darwin::GetDefaultCXXStdlibType() const { - // Use libstdc++ on old targets (OSX < 10.9 and iOS < 7) - if ((isTargetMacOSBased() && isMacosxVersionLT(10, 9)) || - (isTargetIOSBased() && isIPhoneOSVersionLT(7, 0))) - return ToolChain::CST_Libstdcxx; - - // On all other targets, use libc++ + // Always use libc++ by default return ToolChain::CST_Libcxx; } diff --git a/clang/test/Driver/darwin-iphone-defaults.m b/clang/test/Driver/darwin-iphone-defaults.m index ec9507f..79d3bc8 100644 --- a/clang/test/Driver/darwin-iphone-defaults.m +++ b/clang/test/Driver/darwin-iphone-defaults.m @@ -1,4 +1,4 @@ -// RUN: %clang -target i386-apple-darwin9 -miphoneos-version-min=3.0 -arch armv7 -stdlib=platform -flto -S -o - %s | FileCheck %s +// RUN: %clang -target i386-apple-darwin -miphoneos-version-min=5.0 -arch armv7 -stdlib=platform -flto -S -o - %s | FileCheck %s // CHECK: @f0() [[F0:#[0-9]+]] // CHECK: @__f0_block_invoke diff --git a/clang/test/Driver/darwin-stdlib.cpp b/clang/test/Driver/darwin-stdlib.cpp index 0538a42..d15eb19 100644 --- a/clang/test/Driver/darwin-stdlib.cpp +++ b/clang/test/Driver/darwin-stdlib.cpp @@ -2,13 +2,10 @@ // than the platform default. (see https://llvm.org/bugs/show_bug.cgi?id=30548) // XFAIL: default-cxx-stdlib-set -// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch arm64 -miphoneos-version-min=7.0 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX -// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -mmacosx-version-min=10.8 -Wno-stdlibcxx-not-found %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBSTDCXX -// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -mmacosx-version-min=10.9 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX -// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7s -miphoneos-version-min=6.1 -Wno-stdlibcxx-not-found %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBSTDCXX -// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7s -miphoneos-version-min=7.0 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX -// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7k %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX +// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch arm64 -miphoneos-version-min=7.0 %s -### 2>&1 | FileCheck %s +// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -mmacosx-version-min=10.9 %s -### 2>&1 | FileCheck %s +// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7s -miphoneos-version-min=7.0 %s -### 2>&1 | FileCheck %s +// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7k %s -### 2>&1 | FileCheck %s -// CHECK-LIBCXX: "-stdlib=libc++" -// CHECK-LIBSTDCXX-NOT: -stdlib=libc++ -// CHECK-LIBSTDCXX-NOT: -stdlib=libstdc++ +// CHECK: "-stdlib=libc++" +// CHECK-NOT: "-stdlib=libstdc++" -- 2.7.4