Skip to content

Commit 37f576c

Browse files
committed
Disable Ctrl-C handling on WASM
WASM fundamentally doesn't support signals. If WASI ever gets support for notifying the guest process of a Ctrl-C that happened, this would have to be done through the guest process polling for the signal, which will require thread support in WASI too to be compatible with the api provided by the ctrlc crate.
1 parent 241fc13 commit 37f576c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Diff for: compiler/rustc_driver_impl/Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ edition = "2021"
55

66
[dependencies]
77
# tidy-alphabetical-start
8-
ctrlc = "3.4.4"
98
rustc_ast = { path = "../rustc_ast" }
109
rustc_ast_lowering = { path = "../rustc_ast_lowering" }
1110
rustc_ast_passes = { path = "../rustc_ast_passes" }
@@ -66,6 +65,11 @@ features = [
6665
"Win32_System_Diagnostics_Debug",
6766
]
6867

68+
[target.'cfg(not(target_family = "wasm"))'.dependencies]
69+
# tidy-alphabetical-start
70+
ctrlc = "3.4.4"
71+
# tidy-alphabetical-end
72+
6973
[features]
7074
# tidy-alphabetical-start
7175
llvm = ['rustc_interface/llvm']

Diff for: compiler/rustc_driver_impl/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1500,6 +1500,7 @@ pub fn init_logger(early_dcx: &EarlyDiagCtxt, cfg: rustc_log::LoggerConfig) {
15001500
/// Install our usual `ctrlc` handler, which sets [`rustc_const_eval::CTRL_C_RECEIVED`].
15011501
/// Making this handler optional lets tools can install a different handler, if they wish.
15021502
pub fn install_ctrlc_handler() {
1503+
#[cfg(not(target_family = "wasm"))]
15031504
ctrlc::set_handler(move || {
15041505
// Indicate that we have been signaled to stop. If we were already signaled, exit
15051506
// immediately. In our interpreter loop we try to consult this value often, but if for

0 commit comments

Comments
 (0)