01-commit-e0e82fc-initial.patch 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. diff --git a/include/__config b/include/__config
  2. index 52bf12f..e431997 100644
  3. --- a/include/__config
  4. +++ b/include/__config
  5. @@ -131,7 +131,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. +#ifdef __EMSCRIPTEN__
  10. +// XXX EMSCRIPTEN https://github.com/emscripten-core/emscripten/issues/11022
  11. +//# define _LIBCPP_ABI_OPTIMIZED_FUNCTION
  12. +#else
  13. # define _LIBCPP_ABI_OPTIMIZED_FUNCTION
  14. +#endif
  15. // All the regex constants must be distinct and nonzero.
  16. # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
  17. // Re-worked external template instantiations for std::string with a focus on
  18. diff --git a/include/typeinfo b/include/typeinfo
  19. index 59bc291..eb3dc59 100644
  20. --- a/include/typeinfo
  21. +++ b/include/typeinfo
  22. @@ -104,6 +104,11 @@ public:
  23. size_t hash_code() const _NOEXCEPT;
  24. +#ifdef __EMSCRIPTEN__
  25. + // XXX Emscripten: adding `always_inline` fixes
  26. + // https://github.com/emscripten-core/emscripten/issues/13330
  27. + __attribute__((always_inline))
  28. +#endif
  29. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
  30. bool operator==(const type_info& __arg) const _NOEXCEPT {
  31. // When evaluated in a constant expression, both type infos simply can't come
  32. diff --git a/src/filesystem/operations.cpp b/src/filesystem/operations.cpp
  33. index 63a119a..61f2cc5 100644
  34. --- a/src/filesystem/operations.cpp
  35. +++ b/src/filesystem/operations.cpp
  36. @@ -37,7 +37,7 @@
  37. #include <time.h>
  38. #include <fcntl.h> /* values for fchmodat */
  39. -#if __has_include(<sys/sendfile.h>)
  40. +#if __has_include(<sys/sendfile.h>) && !defined(__EMSCRIPTEN__)
  41. # include <sys/sendfile.h>
  42. # define _LIBCPP_FILESYSTEM_USE_SENDFILE
  43. #elif defined(__APPLE__) || __has_include(<copyfile.h>)
  44. diff --git a/src/new.cpp b/src/new.cpp
  45. index c435c5f..6d5b221 100644
  46. --- a/src/new.cpp
  47. +++ b/src/new.cpp
  48. @@ -37,8 +37,17 @@ operator new(std::size_t size) _THROW_BAD_ALLOC
  49. else
  50. #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
  51. throw std::bad_alloc();
  52. +#else
  53. +#ifdef __EMSCRIPTEN__
  54. + // Abort here so that when exceptions are disabled, we do not just
  55. + // return 0 when malloc returns 0.
  56. + // We could also do this with set_new_handler, but that adds a
  57. + // global constructor and a table entry, overhead that we can avoid
  58. + // by doing it this way.
  59. + abort();
  60. #else
  61. break;
  62. +#endif
  63. #endif
  64. }
  65. return p;
  66. diff --git a/src/support/runtime/exception_fallback.ipp b/src/support/runtime/exception_fallback.ipp
  67. index 3b2716d..c14c375 100644
  68. --- a/src/support/runtime/exception_fallback.ipp
  69. +++ b/src/support/runtime/exception_fallback.ipp
  70. @@ -47,6 +47,7 @@ get_terminate() noexcept
  71. return __libcpp_atomic_load(&__terminate_handler);
  72. }
  73. +#ifndef __EMSCRIPTEN__ // We provide this in JS
  74. _LIBCPP_NORETURN
  75. void
  76. terminate() noexcept
  77. @@ -69,7 +70,9 @@ terminate() noexcept
  78. }
  79. #endif // _LIBCPP_HAS_NO_EXCEPTIONS
  80. }
  81. +#endif // !__EMSCRIPTEN__
  82. +#if !defined(__EMSCRIPTEN__)
  83. bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; }
  84. int uncaught_exceptions() noexcept
  85. @@ -78,6 +81,7 @@ int uncaught_exceptions() noexcept
  86. fprintf(stderr, "uncaught_exceptions not yet implemented\n");
  87. ::abort();
  88. }
  89. +#endif // !__EMSCRIPTEN__
  90. exception::~exception() noexcept