1
Fork 0

std support for wasm32 panic=unwind

This commit is contained in:
Noa 2024-02-21 17:32:58 -06:00
parent f8131a48a4
commit 3908a935ef
No known key found for this signature in database
GPG key ID: 7F9F7DB1768C59CF
4 changed files with 59 additions and 7 deletions

View file

@ -5,6 +5,7 @@ use crate::errors::{
};
use crate::llvm;
use libc::c_int;
use rustc_codegen_ssa::base::wants_wasm_eh;
use rustc_codegen_ssa::traits::PrintBackendInfo;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::small_c_str::SmallCStr;
@ -98,8 +99,12 @@ unsafe fn configure_llvm(sess: &Session) {
}
}
if sess.target.os == "emscripten" && sess.panic_strategy() == PanicStrategy::Unwind {
add("-enable-emscripten-cxx-exceptions", false);
if sess.panic_strategy() == PanicStrategy::Unwind {
if sess.target.os == "emscripten" {
add("-enable-emscripten-cxx-exceptions", false);
} else if wants_wasm_eh(sess) {
add("-wasm-enable-eh", false);
}
}
// HACK(eddyb) LLVM inserts `llvm.assume` calls to preserve align attributes
@ -520,6 +525,10 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str
.map(String::from),
);
if wants_wasm_eh(sess) && sess.panic_strategy() == PanicStrategy::Unwind {
features.push("+exception-handling".into());
}
// -Ctarget-features
let supported_features = sess.target.supported_target_features();
let mut featsmap = FxHashMap::default();