Skip to content

Update libcxx and libcxxabi from LLVM 21.1.8 to 22.1.8 - #27428

Draft
aheejin wants to merge 10 commits into
emscripten-core:mainfrom
aheejin:update_libcxx_libcxxabi_22
Draft

Update libcxx and libcxxabi from LLVM 21.1.8 to 22.1.8#27428
aheejin wants to merge 10 commits into
emscripten-core:mainfrom
aheejin:update_libcxx_libcxxabi_22

Conversation

@aheejin

@aheejin aheejin commented Jul 28, 2026

Copy link
Copy Markdown
Member

This updates libcxx and libcxxabi from 21.1.8 to LLVM 22.1.8:
https://github.com/llvm/llvm-project/releases/tag/llvmorg-22.1.8

Additional changes:
(More detailed descriptions are in the commit messages)

WORK IN PROGRESS; NOT DONE YET

aheejin added 10 commits July 28, 2026 07:21
llvm/llvm-project#167636 forces us to define
`_LIBCPP_ASSERTION_SEMANTIC_DEFAULT`. This defines it to follow the
hardening mode.
llvm/llvm-project#169405 has this:
```diff
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -41,17 +41,10 @@
 #include <time.h>

 // since Linux 4.5 and FreeBSD 13, but the Linux libc wrapper is only provided by glibc >= 2.27 and musl
-#if defined(__linux__)
-#  if defined(_LIBCPP_GLIBC_PREREQ)
-#    if _LIBCPP_GLIBC_PREREQ(2, 27)
-#      define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
-#    endif
-#  elif _LIBCPP_HAS_MUSL_LIBC
-#    define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
-#  endif
-#elif defined(__FreeBSD__)
+#if _LIBCPP_GLIBC_PREREQ(2, 27) || _LIBCPP_HAS_MUSL_LIBC || defined(__FreeBSD__)
 #  define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
 #endif
+
 #if __has_include(<sys/sendfile.h>)
 #  include <sys/sendfile.h>
 #  define _LIBCPP_FILESYSTEM_USE_SENDFILE
```

Before the PR, because we didn't define `__linux__`,
`_LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE` was not defined. But after it
`#if defined(__linux__)` check was gone, and because we defined
`_LIBCPP_HAS_MUSL_LIBC`, `_LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE` was
defined as well.

After this PR, we started to have
`error: undefined symbol: copy_file_range` error on
`core*.test_dylink_exceptions_try_catch_6_*` tests.

---

This commit fixes the linker error by wiring up `SYS_copy_file_range`
and provides a stub implementation returning `-ENOSYS` for both legacy
JS syscalls and WASMFS. This allows `copy_file_range.c` from musl to be
compiled into the system library. The libcxx implementation falls back
to other mechanisms when receiving `ENOSYS`.
llvm/llvm-project#116261 wrapped
`__cxa_thread_atexit` with
`#if defined(__linux__) || defined(__Fuchsia__)`
```diff
--- a/libcxxabi/src/cxa_thread_atexit.cpp
+++ b/libcxxabi/src/cxa_thread_atexit.cpp
@@ -106,6 +106,7 @@ namespace {

 #endif // HAVE___CXA_THREAD_ATEXIT_IMPL

+#if defined(__linux__) || defined(__Fuchsia__)
 extern "C" {

   _LIBCXXABI_FUNC_VIS int __cxa_thread_atexit(Dtor dtor, void* obj, void* dso_sym
bol) throw() {
@@ -140,6 +141,6 @@ extern "C" {
     }
 #endif // HAVE___CXA_THREAD_ATEXIT_IMPL
   }
-
 } // extern "C"
+#endif // defined(__linux__) || defined(__Fuchsia__)
 } // namespace __cxxabiv1
```

which caused it to undefined in Emscripten. This adds
`defined(__EMSCRIPTEN__)` to make it available again.
This is an automatic change generated by tools/maint/rebaseline_tests.py.

The following (14) test expectation files were updated by
running the tests with `--rebaseline`:

```
codesize/test_codesize_cxx_ctors1.json: 151784 => 153973 [+2189 bytes / +1.44%]
codesize/test_codesize_cxx_ctors2.json: 151187 => 153379 [+2192 bytes / +1.45%]
codesize/test_codesize_cxx_except.json: 195674 => 200129 [+4455 bytes / +2.28%]
codesize/test_codesize_cxx_except_wasm.json: 166908 => 169501 [+2593 bytes / +1.55%]
codesize/test_codesize_cxx_except_wasm_legacy.json: 164792 => 167361 [+2569 bytes / +1.56%]
codesize/test_codesize_cxx_lto.json: 120635 => 119586 [-1049 bytes / -0.87%]
codesize/test_codesize_cxx_mangle.json: 262056 => 266459 [+4403 bytes / +1.68%]
codesize/test_codesize_cxx_noexcept.json: 153784 => 155883 [+2099 bytes / +1.36%]
codesize/test_codesize_cxx_wasmfs.json: 179386 => 180981 [+1595 bytes / +0.89%]
codesize/test_codesize_files_wasmfs.json: 63585 => 63232 [-353 bytes / -0.56%]
codesize/test_codesize_hello_dylink_all.json: 856538 => 856693 [+155 bytes / +0.02%]
codesize/test_codesize_minimal_pthreads.json: 25967 => 25967 [+0 bytes / +0.00%]
codesize/test_minimal_runtime_code_size_hello_embind.json: 14911 => 15004 [+93 bytes / +0.62%]
codesize/test_minimal_runtime_code_size_hello_embind_val.json: 11638 => 11731 [+93 bytes / +0.80%]

Average change: +0.87% (-0.87% - +2.28%)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant