rust/compiler
Alex Crichton 88d7d20122 Skip cleanups on unsupported targets
This commit is an update to the `AbortUnwindingCalls` MIR pass in the
compiler. Specifically a new boolean is added for "can this target
possibly unwind" and if that's `false` then terminators are all adjusted
to be unreachable/not present. The end result is that this fixes 140293
for wasm targets.

The motivation for this PR is that currently on WebAssembly targets the
usage of the `C-unwind` ABI can lead LLVM to either (a) emit
exception-handling instructions or (b) hit a LLVM-ICE-style codegen
error. WebAssembly as a base instruction set does not support unwinding
at all, and a later proposal to WebAssembly, the exception-handling
proposal, was what enabled this. This means that the current intent of
WebAssembly targets is that they maintain the baseline of "don't emit
exception-handling instructions unless enabled". The commit here is
intended to restore this behavior by skipping these instructions even
when `C-unwind` is present.

Exception-handling is a relatively tricky and also murky topic in
WebAssembly, however. There are two sets of instructions LLVM can emit
for WebAssembly exceptions, Rust's Emscripten target supports
exceptions, WASI targets do not, the LLVM flags to enable this are not
always obvious, and additionally this all touches on "changing
exception-handling behavior should be a target-level concern, not a
feature". Effectively WebAssembly's exception-handling integration into
Rust is not finalized at this time. The best idea at this time is that a
parallel set of targets will eventually be added which support
exceptions, but it's not clear if/when to do this. In the meantime the
goal is to keep existing targets working while still enabling
experimentation with exception-handling with `-Zbuild-std` and various
permutations of LLVM flags.

To that extent this commit does not blanket disable these landing pads
and cleanup routines for WebAssembly but instead checks to see if
panic=unwind is enabled or if `+exception-handling` is enabled. Tests
are updated here as well to account for this where, by default, using a
`C-unwind` ABI won't affect Rust codegen at all. If
`+exception-handling` is enabled, however, then Rust codegen will look
like native platforms where exceptions are caught and the program aborts.
More-or-less I've done my best to keep exceptions working on wasm where
it's possible to have them work, but turned them off where they're not
supposed to be emitted.
2025-09-11 16:13:32 -07:00
..
rustc compiler: Add Windows resources to rustc-main and rustc_driver 2025-09-05 14:06:31 -04:00
rustc_abi Rollup merge of #144066 - RalfJung:extern-c-variadics, r=workingjubilee 2025-09-02 17:08:52 +02:00
rustc_arena Introduce Arena::try_alloc_from_iter. 2025-04-19 01:13:18 +00:00
rustc_ast c-variadic: reject functions with unsupported extern ABI 2025-09-09 21:38:38 +02:00
rustc_ast_ir turn pointer width into an integer in target.json 2025-08-27 23:44:49 +02:00
rustc_ast_lowering Rollup merge of #145879 - Bryanskiy:supertraits-2, r=lcnr 2025-09-10 20:29:05 +02:00
rustc_ast_passes c-variadic: reject functions with unsupported extern ABI 2025-09-09 21:38:38 +02:00
rustc_ast_pretty Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_attr_parsing Rollup merge of #146178 - folkertdev:static-align, r=jdonszelmann,ralfjung,traviscross 2025-09-10 14:17:38 +02:00
rustc_baked_icu_data Use default locale fallback data 2025-08-28 09:48:54 +00:00
rustc_borrowck erase_regions to erase_and_anonymize_regions 2025-09-09 14:49:16 +02:00
rustc_builtin_macros Revert "Rollup merge of #122661 - estebank:assert-macro-span, r=petrochenkov" 2025-09-11 09:10:46 +08:00
rustc_codegen_cranelift Auto merge of #146233 - jieyouxu:run-make-fission, r=Kobzol 2025-09-06 18:37:35 +00:00
rustc_codegen_gcc Rollup merge of #146178 - folkertdev:static-align, r=jdonszelmann,ralfjung,traviscross 2025-09-10 14:17:38 +02:00
rustc_codegen_llvm Rollup merge of #146178 - folkertdev:static-align, r=jdonszelmann,ralfjung,traviscross 2025-09-10 14:17:38 +02:00
rustc_codegen_ssa Auto merge of #146018 - lambdageek:add-winres-version, r=wesleywiser 2025-09-09 03:56:41 +00:00
rustc_const_eval Rollup merge of #146178 - folkertdev:static-align, r=jdonszelmann,ralfjung,traviscross 2025-09-10 14:17:38 +02:00
rustc_data_structures Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_driver compiler: Add Windows resources to rustc-main and rustc_driver 2025-09-05 14:06:31 -04:00
rustc_driver_impl Strip frontmatter in fewer places 2025-09-09 19:49:40 +02:00
rustc_error_codes Changes to the uitests 2025-08-27 20:25:18 +02:00
rustc_error_messages Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_errors fix: Filter suggestion parts that match existing code 2025-09-04 17:42:13 -06:00
rustc_expand Rollup merge of #146340 - fmease:frontmatter-containment, r=fee1-dead,Urgau 2025-09-10 20:29:09 +02:00
rustc_feature allow #[rustc_align_static(N)] on statics 2025-09-09 21:54:54 +02:00
rustc_fluent_macro Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_fs_util Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_graphviz
rustc_hashes
rustc_hir Rollup merge of #144765 - Qelxiros:range-inclusive-last, r=jhpratt 2025-09-10 14:17:37 +02:00
rustc_hir_analysis Default auto traits: revert to the default supertraits 2025-09-10 15:08:06 +03:00
rustc_hir_id rustc_hir_id: Add a comment explaining why the crate exists 2025-08-20 15:04:00 -07:00
rustc_hir_pretty Rollup merge of #146102 - fmease:rm-dead-eff-code-iii, r=fee1-dead 2025-09-02 17:08:58 +02:00
rustc_hir_typeck Driveby fixes 2025-09-09 14:49:16 +02:00
rustc_incremental Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_index Rollup merge of #144765 - Qelxiros:range-inclusive-last, r=jhpratt 2025-09-10 14:17:37 +02:00
rustc_index_macros Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_infer erase_regions to erase_and_anonymize_regions 2025-09-09 14:49:16 +02:00
rustc_interface Rollup merge of #146340 - fmease:frontmatter-containment, r=fee1-dead,Urgau 2025-09-10 20:29:09 +02:00
rustc_lexer Rollup merge of #146106 - epage:whitespace, r=fee1-dead 2025-09-03 23:08:10 +10:00
rustc_lint Default auto traits: revert to the default supertraits 2025-09-10 15:08:06 +03:00
rustc_lint_defs Rollup merge of #145932 - JamieCunliffe:target-feature-inlining, r=jackh726 2025-09-04 10:01:55 +10:00
rustc_llvm Auto merge of #146360 - Zalathar:rollup-qc2hhrd, r=Zalathar 2025-09-09 11:54:44 +00:00
rustc_log Update tracing, again 2025-09-08 09:23:37 -07:00
rustc_macros Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_metadata Auto merge of #138736 - azhogin:azhogin/sanitizers-target-modificators, r=rcvalle 2025-09-04 22:51:33 +00:00
rustc_middle Rollup merge of #146391 - beepster4096:trimnt, r=saethlin 2025-09-10 14:17:40 +02:00
rustc_mir_build Driveby fixes 2025-09-09 14:49:16 +02:00
rustc_mir_dataflow erase_regions to erase_and_anonymize_regions 2025-09-09 14:49:16 +02:00
rustc_mir_transform Skip cleanups on unsupported targets 2025-09-11 16:13:32 -07:00
rustc_monomorphize Auto merge of #145717 - BoxyUwU:erase_regions_rename, r=lcnr 2025-09-09 15:04:44 +00:00
rustc_next_trait_solver Auto merge of #140375 - lcnr:subrelations-infcx, r=BoxyUwU 2025-09-08 19:39:36 +00:00
rustc_parse Rollup merge of #146422 - fmease:less-greedy-maybe-const-bounds, r=estebank 2025-09-11 14:06:32 +10:00
rustc_parse_format Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_passes Rollup merge of #146178 - folkertdev:static-align, r=jdonszelmann,ralfjung,traviscross 2025-09-10 14:17:38 +02:00
rustc_pattern_analysis Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_privacy Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_proc_macro Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_public Rollup merge of #146102 - fmease:rm-dead-eff-code-iii, r=fee1-dead 2025-09-02 17:08:58 +02:00
rustc_public_bridge Remove useless lifetime parameter. 2025-07-23 23:54:37 +00:00
rustc_query_impl fixup limit handling code 2025-09-08 15:07:12 -07:00
rustc_query_system fixup limit handling code 2025-09-08 15:07:12 -07:00
rustc_resolve Rollup merge of #146254 - yotamofek:pr/itertools-all-equal-value, r=cjgillot 2025-09-07 08:18:59 +02:00
rustc_sanitizers Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_serialize Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_session fixup limit handling code 2025-09-08 15:07:12 -07:00
rustc_span Skip cleanups on unsupported targets 2025-09-11 16:13:32 -07:00
rustc_symbol_mangling Add assertion 2025-09-09 14:49:16 +02:00
rustc_target s390x: mark soft-float target feature as incompatible 2025-09-10 22:47:29 +02:00
rustc_thread_pool Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_trait_selection Revert "Rollup merge of #122661 - estebank:assert-macro-span, r=petrochenkov" 2025-09-11 09:10:46 +08:00
rustc_traits erase_regions to erase_and_anonymize_regions 2025-09-09 14:49:16 +02:00
rustc_transmute Driveby fixes 2025-09-09 14:49:16 +02:00
rustc_ty_utils Auto merge of #145717 - BoxyUwU:erase_regions_rename, r=lcnr 2025-09-09 15:04:44 +00:00
rustc_type_ir Auto merge of #146375 - matthiaskrgr:rollup-utik9zj, r=matthiaskrgr 2025-09-09 18:14:23 +00:00
rustc_type_ir_macros Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_windows_rc compiler: Add Windows resources to rustc-main and rustc_driver 2025-09-05 14:06:31 -04:00