[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:57 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Matt (matts1)
<details>
<summary>Changes</summary>
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 {};
| ^
```
---
Full diff: https://github.com/llvm/llvm-project/pull/158781.diff
1 Files Affected:
- (modified) libcxx/include/__new/align_val_t.h (+7-2)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/158781
More information about the libcxx-commits
mailing list