Update libcxx and libcxxabi from LLVM 21.1.8 to 22.1.8 - #27428
Draft
aheejin wants to merge 10 commits into
Draft
Conversation
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%) ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)
Don't copy llvm-libc files in
update_libcxx.py: e7af49cIn
update_libcxx.py, we don't copy llvm-libc files that libcxx depend on anymore, because we copy those files inupdate_llvm_libc.pytoo. We just assume llvm-libc has been updated to the same version before doing update, and I wrote that in the comments.Define
_LIBCPP_ASSERTION_SEMANTIC_DEFAULTin__config_site: b119c87[libc++][hardening] Allow setting the assertion semantic via CMake. llvm/llvm-project#167636 forces us to define
_LIBCPP_ASSERTION_SEMANTIC_DEFAULT. This defines it to follow the hardening mode.Add
copy_file_rangesyscall stub: eb90d7d, c7d4b0bAfter [libc++] Always define _LIBCPP_GLIBC_PREREQ llvm/llvm-project#169405,
_LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGEwas defined, which caused Emscripten to usecopy_file_range, but we were not building https://github.com/emscripten-core/emscripten/blob/main/system/lib/libc/musl/src/linux/copy_file_range.c. This commit includes the file in the build and provides a stub implementation returning-ENOSYS. libcxx will fall back to other mechanisms upon receiving it.Make
__cxa_thread_atexitavailable for Emscripten: 638d0e1[libc++] Enable -Wmissing-prototypes llvm/llvm-project#116261 wrapped
__cxa_thread_atexitwith#if defined(__linux__) || defined(__Fuchsia__), which caused it to be undefined in Emscripten. This addsdefined(__EMSCRIPTEN__)to make it available again.WORK IN PROGRESS; NOT DONE YET