[libcxx-commits] [libcxx] [libcxx][modules] 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:55:57 PDT 2025
https://github.com/matts1 updated https://github.com/llvm/llvm-project/pull/158781
>From 453c9451f48c3e87bcee12151f5b54eac3c22a6d 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][modules] 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 | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/libcxx/include/__new/align_val_t.h b/libcxx/include/__new/align_val_t.h
index 03ab7cb143a2b..93f673431bfea 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
+# ifndef _LIBCPP_CXX03_LANG
enum class align_val_t : size_t {};
-# else
+# else
enum align_val_t { __zero = 0, __max = (size_t)-1 };
+# endif
+_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
# endif
#endif
-_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
#endif // _LIBCPP___NEW_ALIGN_VAL_T_H
More information about the libcxx-commits
mailing list