-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid __cxa_thread_atexit_impl on Emscripten #106779
Conversation
- Fixes rust-lang#91628. - Fixes emscripten-core/emscripten#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
Failed to set assignee to
|
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
r? libs |
For those curious, also raised an LLVM issue for the underlying problem llvm/llvm-project#60003, but this Rust-specific fix should be valid regardless. |
@bors r+ Seems okay. |
Avoid __cxa_thread_atexit_impl on Emscripten - Fixes rust-lang#91628. - Fixes emscripten-core/emscripten#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++.
Avoid __cxa_thread_atexit_impl on Emscripten - Fixes rust-lang#91628. - Fixes emscripten-core/emscripten#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++.
A little odd that I didn't see it unused in my testing, but okay, re-added the |
Could not assign reviewer from: |
@Mark-Simulacrum Sorry, not sure whether to trigger re-review somehow or just ask again. |
@bors r+ |
🌲 The tree is currently closed for pull requests below priority 10. This pull request will be tested once the tree is reopened. |
|
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#97373 (impl DispatchFromDyn for Cell and UnsafeCell) - rust-lang#106625 (Remove backwards compat for LLVM 12 coverage format) - rust-lang#106779 (Avoid __cxa_thread_atexit_impl on Emscripten) - rust-lang#106811 (Append .dwp to the binary filename instead of replacing the existing extension.) - rust-lang#106836 (Remove optimistic spinning from `mpsc::SyncSender`) - rust-lang#106946 (implement Hash for proc_macro::LineColumn) - rust-lang#107074 (remove unnecessary check for opaque types) - rust-lang#107287 (Improve fn pointer notes) - rust-lang#107304 (Use `can_eq` to compare types for default assoc type error) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
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++.