[PATCH] D131274: [clang][Darwin] Re-apply "Always set the default C++ Standard Library to libc++"

Louis Dionne via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 5 11:04:25 PDT 2022


ldionne created this revision.
ldionne added a reviewer: leonardchan.
Herald added a project: All.
ldionne requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

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).

This is a re-application of c5ccb78ade81 <https://reviews.llvm.org/rGc5ccb78ade8136134e0ca9dde64de97f913f0f8c> which had been reverted in
33171df9cc7f <https://reviews.llvm.org/rG33171df9cc7f6560dea7b0b162ab51ff97417468> because it broke the Fuchsia CI bots. The issue was that
the test was XPASSing because it didn't fail anymore when the
CLANG_DEFAULT_CXX_LIB was set to libc++, which seems to be done for
Fuchsia. Instead, the test only fails if CLANG_DEFAULT_CXX_LIB is
set to libstdc++.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131274

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/darwin-iphone-defaults.m
  clang/test/Driver/darwin-stdlib.cpp
  clang/test/lit.cfg.py


Index: clang/test/lit.cfg.py
===================================================================
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -134,7 +134,7 @@
 # Set available features we allow tests to conditionalize on.
 #
 if config.clang_default_cxx_stdlib != '':
-    config.available_features.add('default-cxx-stdlib-set')
+    config.available_features.add('default-cxx-stdlib={}'.format(config.clang_default_cxx_stdlib))
 
 # As of 2011.08, crash-recovery tests still do not pass on FreeBSD.
 if platform.system() not in ['FreeBSD']:
Index: clang/test/Driver/darwin-stdlib.cpp
===================================================================
--- clang/test/Driver/darwin-stdlib.cpp
+++ clang/test/Driver/darwin-stdlib.cpp
@@ -1,14 +1,10 @@
-// This test will fail if CLANG_DEFAULT_CXX_STDLIB is set to anything different
-// than the platform default. (see https://llvm.org/bugs/show_bug.cgi?id=30548)
-// XFAIL: default-cxx-stdlib-set
+// This test will fail if CLANG_DEFAULT_CXX_STDLIB is set to libstdc++.
+// XFAIL: default-cxx-stdlib=libstdc++
 
-// 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++"
Index: clang/test/Driver/darwin-iphone-defaults.m
===================================================================
--- clang/test/Driver/darwin-iphone-defaults.m
+++ 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
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -896,12 +896,7 @@
 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;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131274.450331.patch
Type: text/x-patch
Size: 4275 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220805/e6e75d1b/attachment-0001.bin>


More information about the cfe-commits mailing list