Skip to content

Commit ed2c4e4

Browse files
committed
fix libc++ std modules compilation on Windows using clang-cl
1 parent 6bed7b7 commit ed2c4e4

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

libcxx/include/__new/new_handler.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717

1818
#if defined(_LIBCPP_ABI_VCRUNTIME)
1919
# include <new.h>
20+
// <new.h> does not define 'get_new_handler'
21+
// which makes the 'std' module build fail, this fixes it
22+
namespace std {
23+
_LIBCPP_EXPORTED_FROM_ABI new_handler get_new_handler() _NOEXCEPT;
24+
}
2025
#else
2126
_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
2227
typedef void (*new_handler)();

libcxx/modules/std.compat/ctime.inc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ export {
1414

1515
using ::timespec _LIBCPP_USING_IF_EXISTS;
1616
using ::tm _LIBCPP_USING_IF_EXISTS;
17-
1817
using ::asctime _LIBCPP_USING_IF_EXISTS;
1918
using ::clock _LIBCPP_USING_IF_EXISTS;
19+
using ::strftime _LIBCPP_USING_IF_EXISTS;
20+
21+
#ifndef _LIBCPP_ABI_VCRUNTIME
2022
using ::ctime _LIBCPP_USING_IF_EXISTS;
2123
using ::difftime _LIBCPP_USING_IF_EXISTS;
2224
using ::gmtime _LIBCPP_USING_IF_EXISTS;
2325
using ::localtime _LIBCPP_USING_IF_EXISTS;
2426
using ::mktime _LIBCPP_USING_IF_EXISTS;
25-
using ::strftime _LIBCPP_USING_IF_EXISTS;
2627
using ::time _LIBCPP_USING_IF_EXISTS;
2728
using ::timespec_get _LIBCPP_USING_IF_EXISTS;
29+
#endif
2830
} // export

libcxx/modules/std.cppm.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ module;
5151
#include <cstdio>
5252
#include <cstdlib>
5353
#include <cstring>
54+
#ifdef _LIBCPP_ABI_VCRUNTIME
55+
#define _BUILD_STD_MODULE
56+
#endif
5457
#include <ctime>
5558
#include <cuchar>
5659
#include <cwchar>

libcxx/modules/std/ctime.inc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ export namespace std {
1414

1515
using std::timespec _LIBCPP_USING_IF_EXISTS;
1616
using std::tm _LIBCPP_USING_IF_EXISTS;
17-
1817
using std::asctime _LIBCPP_USING_IF_EXISTS;
1918
using std::clock _LIBCPP_USING_IF_EXISTS;
19+
using std::strftime _LIBCPP_USING_IF_EXISTS;
20+
21+
#ifndef _LIBCPP_ABI_VCRUNTIME
2022
using std::ctime _LIBCPP_USING_IF_EXISTS;
2123
using std::difftime _LIBCPP_USING_IF_EXISTS;
2224
using std::gmtime _LIBCPP_USING_IF_EXISTS;
2325
using std::localtime _LIBCPP_USING_IF_EXISTS;
2426
using std::mktime _LIBCPP_USING_IF_EXISTS;
25-
using std::strftime _LIBCPP_USING_IF_EXISTS;
2627
using std::time _LIBCPP_USING_IF_EXISTS;
2728
using std::timespec_get _LIBCPP_USING_IF_EXISTS;
29+
#endif
2830
} // namespace std

0 commit comments

Comments
 (0)