[libcxx-commits] [libcxx] libcxx: Ensure that __new/align_val_t.h always contains align_val_t (PR #158781)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Sep 15 22:48:27 PDT 2025
https://github.com/matts1 created https://github.com/llvm/llvm-project/pull/158781
Previously, I was getting the following error when attempting to compile libc++ on windows with modules enabled.
```
While building module 'std':
In file included from <module-includes>:1:
In file included from gen/third_party/libc++/src/include/algorithm:1865:
In file included from gen/third_party/libc++/src/include/__algorithm/inplace_merge.h:28:
In file included from gen/third_party/libc++/src/include/__memory/unique_temporary_buffer.h:17:
In file included from gen/third_party/libc++/src/include/__memory/allocator.h:19:
gen/third_party/libc++/src/include/__new/allocate.h(40,73): error:
declaration of 'align_val_t' must be imported from module
'sys_stage1.sysroot_vcruntime_new_h' before it is required
40 | return static_cast<_Tp*>(__builtin_operator_new(__size, static_cast<align_val...
| ^
../../third_party/depot_tools/win_toolchain/vs_files/e4305f407e/VC/Tools/MSVC/14.44.35207/include/vcruntime_new.h(27,33): note:
declaration here is not visible
27 | _VCRT_EXPORT_STD enum class align_val_t : size_t {};
| ^
```
>From 86f27e30fad559c491a2e4df653aca4a757a6b9f Mon Sep 17 00:00:00 2001
From: Matt Stark <msta at google.com>
Date: Tue, 16 Sep 2025 05:38:02 +0000
Subject: [PATCH] libcxx: Ensure that __new/align_val_t.h always contains
std::align_val_t.
Previously, I was getting the following error when attempting to compile
libc++ on windows with modules enabled.
```
While building module 'std':
In file included from <module-includes>:1:
In file included from gen/third_party/libc++/src/include/algorithm:1865:
In file included from gen/third_party/libc++/src/include/__algorithm/inplace_merge.h:28:
In file included from gen/third_party/libc++/src/include/__memory/unique_temporary_buffer.h:17:
In file included from gen/third_party/libc++/src/include/__memory/allocator.h:19:
gen/third_party/libc++/src/include/__new/allocate.h(40,73): error:
declaration of 'align_val_t' must be imported from module
'sys_stage1.sysroot_vcruntime_new_h' before it is required
40 | return static_cast<_Tp*>(__builtin_operator_new(__size, static_cast<align_val...
| ^
../../third_party/depot_tools/win_toolchain/vs_files/e4305f407e/VC/Tools/MSVC/14.44.35207/include/vcruntime_new.h(27,33): note:
declaration here is not visible
27 | _VCRT_EXPORT_STD enum class align_val_t : size_t {};
| ^
```
---
libcxx/include/__new/align_val_t.h | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/libcxx/include/__new/align_val_t.h b/libcxx/include/__new/align_val_t.h
index 03ab7cb143a2b..36fc9f3365062 100644
--- a/libcxx/include/__new/align_val_t.h
+++ b/libcxx/include/__new/align_val_t.h
@@ -16,14 +16,19 @@
# pragma GCC system_header
#endif
+#if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION
+#if defined(_LIBCPP_ABI_VCRUNTIME)
+// std::align_val_t is defined in vcruntime_new.h
+#include <vcruntime_new.h>
+#else
_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
-#if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION && !defined(_LIBCPP_ABI_VCRUNTIME)
# ifndef _LIBCPP_CXX03_LANG
enum class align_val_t : size_t {};
# else
enum align_val_t { __zero = 0, __max = (size_t)-1 };
# endif
-#endif
_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
+#endif
+#endif
#endif // _LIBCPP___NEW_ALIGN_VAL_T_H
More information about the libcxx-commits
mailing list