[libcxx-commits] [libcxx] d291bcd - [libc++] Do not define std::nothrow with VCRuntime ABI (#217694)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Aug 30 20:18:55 PDT 2026
Author: Corentin Kerisit
Date: 2026-08-31T11:18:49+08:00
New Revision: d291bcd466edac6b0e21b6f6437462d763e337de
URL: https://github.com/llvm/llvm-project/commit/d291bcd466edac6b0e21b6f6437462d763e337de
DIFF: https://github.com/llvm/llvm-project/commit/d291bcd466edac6b0e21b6f6437462d763e337de.diff
LOG: [libc++] Do not define std::nothrow with VCRuntime ABI (#217694)
Avoid defining `std::nothrow` in libc++ when `_LIBCPP_ABI_VCRUNTIME` is
enabled.
VCRuntime already owns and provides `std::nothrow`, just as it owns the
global new/delete ABI.
Assisted-by: codex (for the test)
Added:
libcxx/test/libcxx/vendor/clang-cl/static-lib-nothrow.sh.cpp
Modified:
libcxx/src/new_helpers.cpp
Removed:
################################################################################
diff --git a/libcxx/src/new_helpers.cpp b/libcxx/src/new_helpers.cpp
index 2119d82b3e00f..a60fa630aa771 100644
--- a/libcxx/src/new_helpers.cpp
+++ b/libcxx/src/new_helpers.cpp
@@ -11,9 +11,9 @@
namespace std { // purposefully not versioned
-#ifndef __GLIBCXX__
+#if !defined(__GLIBCXX__) && !defined(_LIBCPP_ABI_VCRUNTIME)
const nothrow_t nothrow{};
-#endif
+#endif // !defined(__GLIBCXX__) && !defined(_LIBCPP_ABI_VCRUNTIME)
#ifndef LIBSTDCXX
diff --git a/libcxx/test/libcxx/vendor/clang-cl/static-lib-nothrow.sh.cpp b/libcxx/test/libcxx/vendor/clang-cl/static-lib-nothrow.sh.cpp
new file mode 100644
index 0000000000000..0db6f5679e033
--- /dev/null
+++ b/libcxx/test/libcxx/vendor/clang-cl/static-lib-nothrow.sh.cpp
@@ -0,0 +1,16 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: target={{.+}}-windows-msvc
+
+// The VCRuntime library owns std::nothrow when libc++ uses its ABI. Defining
+// the object in libc++.lib as well makes whole-archive links fail with a
+// duplicate symbol.
+
+// RUN: llvm-nm --defined-only "%{lib-dir}/libc++.lib" | not grep -F '?nothrow at std@@3Unothrow_t at 1@B'
+// RUN: llvm-nm --defined-only "%{lib-dir}/libc++.lib" | grep -F '?__throw_bad_alloc at std@@YAXXZ'
More information about the libcxx-commits
mailing list