aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxxcuda11/patches/01-commit-e0e82fc-initial.patch
blob: bd826ae06ef468fdd73e05e02061ec1054f36938 (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/__config b/include/__config
index 52bf12f..e431997 100644
--- a/include/__config
+++ b/include/__config
@@ -131,7 +131,12 @@
 // Previously libc++ used "unsigned int" exclusively.
 #    define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
 // Unstable attempt to provide a more optimized std::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 59bc291..eb3dc59 100644
--- a/include/typeinfo
+++ b/include/typeinfo
@@ -104,6 +104,11 @@ public:
 
     size_t hash_code() const _NOEXCEPT;
 
+#ifdef __EMSCRIPTEN__
+    // XXX Emscripten: adding `always_inline` fixes
+    // https://github.com/emscripten-core/emscripten/issues/13330
+    __attribute__((always_inline))
+#endif
     _LIBCPP_INLINE_VISIBILITY _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
diff --git a/src/filesystem/operations.cpp b/src/filesystem/operations.cpp
index 63a119a..61f2cc5 100644
--- a/src/filesystem/operations.cpp
+++ b/src/filesystem/operations.cpp
@@ -37,7 +37,7 @@
 #include <time.h>
 #include <fcntl.h> /* values for fchmodat */
 
-#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 c435c5f..6d5b221 100644
--- a/src/new.cpp
+++ b/src/new.cpp
@@ -37,8 +37,17 @@ operator new(std::size_t size) _THROW_BAD_ALLOC
         else
 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
             throw std::bad_alloc();
+#else
+#ifdef __EMSCRIPTEN__
+            // Abort here so that when exceptions are disabled, we do not just
+            // return 0 when malloc returns 0.
+            // We could also do this with set_new_handler, but that adds a
+            // global constructor and a table entry, overhead that we can avoid
+            // by doing it this way.
+            abort();
 #else
             break;
+#endif
 #endif
     }
     return p;
diff --git a/src/support/runtime/exception_fallback.ipp b/src/support/runtime/exception_fallback.ipp
index 3b2716d..c14c375 100644
--- a/src/support/runtime/exception_fallback.ipp
+++ b/src/support/runtime/exception_fallback.ipp
@@ -47,6 +47,7 @@ get_terminate() noexcept
   return __libcpp_atomic_load(&__terminate_handler);
 }
 
+#ifndef __EMSCRIPTEN__ // We provide this in JS
 _LIBCPP_NORETURN
 void
 terminate() noexcept
@@ -69,7 +70,9 @@ terminate() noexcept
     }
 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
 }
+#endif // !__EMSCRIPTEN__
 
+#if !defined(__EMSCRIPTEN__)
 bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; }
 
 int uncaught_exceptions() noexcept
@@ -78,6 +81,7 @@ int uncaught_exceptions() noexcept
   fprintf(stderr, "uncaught_exceptions not yet implemented\n");
   ::abort();
 }
+#endif // !__EMSCRIPTEN__
 
 
 exception::~exception() noexcept