rust/library
Ingvar Stepanyan 6155b9a772
Avoid __cxa_thread_atexit_impl on Emscripten
- Fixes https://github.com/rust-lang/rust/issues/91628.
 - Fixes https://github.com/emscripten-core/emscripten/issues/15722.

See discussion in both issues.

The TL;DR is that weak linkage causes LLVM to produce broken Wasm, presumably due to pointer mismatch. The code is casting a void pointer to a function pointer with specific signature, but Wasm is very strict about function pointer compatibility, so the resulting code is invalid.

Ideally LLVM should catch this earlier in the process rather than emit invalid Wasm, but it currently doesn't and this is an easy and valid fix, given that Emcripten doesn't have `__cxa_thread_atexit_impl` these days anyway.

Unfortunately, I can't add a regression test as even after looking into this issue for a long time, I couldn't reproduce it with any minimal Rust example, only with extracted LLVM IR or on a large project involving Rust + C++.

r? @alexcrichton
2023-01-12 18:47:05 +00:00
..
alloc impl: specialize impl of ToString on bool 2023-01-10 15:34:21 +13:00
backtrace@07872f28cd Update backtrace 2022-09-02 16:09:58 -04:00
core Rollup merge of #106323 - starkat99:stabilize-f16c_target_feature, r=petrochenkov 2023-01-11 22:25:48 -08:00
panic_abort Replace libstd, libcore, liballoc in line comments. 2022-12-30 14:00:42 +01:00
panic_unwind Replace libstd, libcore, liballoc in docs. 2022-12-30 14:00:40 +01:00
portable-simd Fix rustdoc lints 2022-11-06 17:21:22 -05:00
proc_macro Replace libstd, libcore, liballoc in line comments. 2022-12-30 14:00:42 +01:00
profiler_builtins Fully stabilize NLL 2022-06-03 17:16:41 -04:00
rtstartup Remove custom frame info registration on i686-pc-windows-gnu 2022-08-23 16:12:58 +08:00
rustc-std-workspace-alloc Replace libstd, libcore, liballoc in line comments. 2022-12-30 14:00:42 +01:00
rustc-std-workspace-core
rustc-std-workspace-std
std Avoid __cxa_thread_atexit_impl on Emscripten 2023-01-12 18:47:05 +00:00
stdarch@790411f93c library: update stdarch submodule 2022-10-13 09:41:16 +08:00
test Fix a few clippy lints in libtest 2023-01-03 18:55:03 +00:00
unwind Replace libstd, libcore, liballoc in line comments. 2022-12-30 14:00:42 +01:00