aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/patches/01-commit-e0e82fc-initial.patch
blob: 5da71f016bd56b251c52bd3b63a6f8dcc67e6d51 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
diff --git a/include/__configuration/abi.h b/include/__configuration/abi.h
index 707e10b..1e4c9cf 100644
--- a/include/__configuration/abi.h
+++ b/include/__configuration/abi.h
@@ -66,7 +66,12 @@
 // Previously libc++ used "unsigned int" exclusively.
 #  define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
 // Unstable attempt to provide a more optimized std::function
-#  define _LIBCPP_ABI_OPTIMIZED_FUNCTION
+#  ifdef __EMSCRIPTEN__
+// XXX EMSCRIPTEN https://github.com/emscripten-core/emscripten/issues/11022
+// #  define _LIBCPP_ABI_OPTIMIZED_FUNCTION
+#  else
+#    define _LIBCPP_ABI_OPTIMIZED_FUNCTION
+#  endif
 // All the regex constants must be distinct and nonzero.
 #  define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
 // Re-worked external template instantiations for std::string with a focus on
diff --git a/include/typeinfo b/include/typeinfo
index a44fa4d..51d6305 100644
--- a/include/typeinfo
+++ b/include/typeinfo
@@ -97,7 +97,13 @@ public:
 
   size_t hash_code() const _NOEXCEPT;
 
-  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const type_info& __arg) const _NOEXCEPT {
+#    ifdef __EMSCRIPTEN__
+  // XXX Emscripten: adding `always_inline` fixes
+  // https://github.com/emscripten-core/emscripten/issues/13330
+  __attribute__((always_inline))
+#    endif
+  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
+  operator==(const type_info& __arg) const _NOEXCEPT {
     // When evaluated in a constant expression, both type infos simply can't come
     // from different translation units, so it is sufficient to compare their addresses.
     if (__libcpp_is_constant_evaluated()) {
diff --git a/src/filesystem/operations.cpp b/src/filesystem/operations.cpp
index d771f20..074f10b 100644
--- a/src/filesystem/operations.cpp
+++ b/src/filesystem/operations.cpp
@@ -37,7 +37,7 @@
 #include <fcntl.h> /* values for fchmodat */
 #include <time.h>
 
-#if __has_include(<sys/sendfile.h>)
+#if __has_include(<sys/sendfile.h>) && !defined(__EMSCRIPTEN__)
 #  include <sys/sendfile.h>
 #  define _LIBCPP_FILESYSTEM_USE_SENDFILE
 #elif defined(__APPLE__) || __has_include(<copyfile.h>)
diff --git a/src/new.cpp b/src/new.cpp
index b0c7316..7f1cc67 100644
--- a/src/new.cpp
+++ b/src/new.cpp
@@ -18,7 +18,13 @@
 // The code below is copied as-is into libc++abi's libcxxabi/src/stdlib_new_delete.cpp
 // file. The version in this file is the canonical one.
 
-inline void __throw_bad_alloc_shim() { std::__throw_bad_alloc(); }
+inline void __throw_bad_alloc_shim() {
+# ifdef __EMSCRIPTEN__
+  abort();
+#else
+  std::__throw_bad_alloc();
+#endif
+}
 
 #  define _LIBCPP_ASSERT_SHIM(expr, str) _LIBCPP_ASSERT(expr, str)
 
diff --git a/src/support/runtime/exception_fallback.ipp b/src/support/runtime/exception_fallback.ipp
index bedb16e..09ec68e 100644
--- a/src/support/runtime/exception_fallback.ipp
+++ b/src/support/runtime/exception_fallback.ipp
@@ -33,6 +33,7 @@ terminate_handler set_terminate(terminate_handler func) noexcept {
 
 terminate_handler get_terminate() noexcept { return __libcpp_atomic_load(&__terminate_handler); }
 
+#ifndef __EMSCRIPTEN__ // We provide this in JS
 [[noreturn]] void terminate() noexcept {
 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
   try {
@@ -47,13 +48,16 @@ terminate_handler get_terminate() noexcept { return __libcpp_atomic_load(&__term
   }
 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
 }
+#endif // !__EMSCRIPTEN__
 
+#if !defined(__EMSCRIPTEN__)
 bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; }
 
 int uncaught_exceptions() noexcept {
 #warning uncaught_exception not yet implemented
   __libcpp_verbose_abort("uncaught_exceptions not yet implemented\n");
 }
+#endif // !__EMSCRIPTEN__
 
 exception::~exception() noexcept {}