01-commit-e0e82fc-initial.patch 3.6 KB

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