Skip to content

Commit 72fe8a0

Browse files
committed
Auto merge of rust-lang#123788 - bjorn3:disable_ctrlc_on_wasi, r=Nilstrieb,lcnr
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.
2 parents 62cffee + 8b0b88a commit 72fe8a0

File tree

3 files changed

+13
-34
lines changed

3 files changed

+13
-34
lines changed

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']

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

src/tools/tidy/src/deps.rs

+7-33
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Checks the licenses of third-party dependencies.
22
3-
use cargo_metadata::{DepKindInfo, Metadata, Package, PackageId};
3+
use cargo_metadata::{Metadata, Package, PackageId};
44
use std::collections::HashSet;
55
use std::path::Path;
66

@@ -191,6 +191,7 @@ const PERMITTED_DEPS_LOCATION: &str = concat!(file!(), ":", line!());
191191
/// rustc. Please check with the compiler team before adding an entry.
192192
const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
193193
// tidy-alphabetical-start
194+
"addr2line",
194195
"adler",
195196
"ahash",
196197
"aho-corasick",
@@ -468,6 +469,7 @@ const PERMITTED_CRANELIFT_DEPENDENCIES: &[&str] = &[
468469
"mach",
469470
"memchr",
470471
"object",
472+
"once_cell",
471473
"proc-macro2",
472474
"quote",
473475
"regalloc2",
@@ -668,27 +670,7 @@ fn check_permitted_dependencies(
668670
let mut deps = HashSet::new();
669671
for to_check in restricted_dependency_crates {
670672
let to_check = pkg_from_name(metadata, to_check);
671-
use cargo_platform::Cfg;
672-
use std::str::FromStr;
673-
// We don't expect the compiler to ever run on wasm32, so strip
674-
// out those dependencies to avoid polluting the permitted list.
675-
deps_of_filtered(metadata, &to_check.id, &mut deps, &|dep_kinds| {
676-
dep_kinds.iter().any(|dep_kind| {
677-
dep_kind
678-
.target
679-
.as_ref()
680-
.map(|target| {
681-
!target.matches(
682-
"wasm32-unknown-unknown",
683-
&[
684-
Cfg::from_str("target_arch=\"wasm32\"").unwrap(),
685-
Cfg::from_str("target_os=\"unknown\"").unwrap(),
686-
],
687-
)
688-
})
689-
.unwrap_or(true)
690-
})
691-
});
673+
deps_of(metadata, &to_check.id, &mut deps);
692674
}
693675

694676
// Check that the PERMITTED_DEPENDENCIES does not have unused entries.
@@ -740,18 +722,13 @@ fn compute_runtime_crates<'a>(metadata: &'a Metadata) -> HashSet<&'a PackageId>
740722
let mut result = HashSet::new();
741723
for name in RUNTIME_CRATES {
742724
let id = &pkg_from_name(metadata, name).id;
743-
deps_of_filtered(metadata, id, &mut result, &|_| true);
725+
deps_of(metadata, id, &mut result);
744726
}
745727
result
746728
}
747729

748730
/// Recursively find all dependencies.
749-
fn deps_of_filtered<'a>(
750-
metadata: &'a Metadata,
751-
pkg_id: &'a PackageId,
752-
result: &mut HashSet<&'a PackageId>,
753-
filter: &dyn Fn(&[DepKindInfo]) -> bool,
754-
) {
731+
fn deps_of<'a>(metadata: &'a Metadata, pkg_id: &'a PackageId, result: &mut HashSet<&'a PackageId>) {
755732
if !result.insert(pkg_id) {
756733
return;
757734
}
@@ -764,9 +741,6 @@ fn deps_of_filtered<'a>(
764741
.find(|n| &n.id == pkg_id)
765742
.unwrap_or_else(|| panic!("could not find `{pkg_id}` in resolve"));
766743
for dep in &node.deps {
767-
if !filter(&dep.dep_kinds) {
768-
continue;
769-
}
770-
deps_of_filtered(metadata, &dep.pkg, result, filter);
744+
deps_of(metadata, &dep.pkg, result);
771745
}
772746
}

0 commit comments

Comments
 (0)