Skip to content
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

tidy: remove filtering for wasm32 deps, as this don't work #113449

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5453,7 +5453,6 @@ dependencies = [
name = "tidy"
version = "0.1.0"
dependencies = [
"cargo-platform",
"cargo_metadata 0.15.4",
"ignore",
"lazy_static",
Expand Down
1 change: 0 additions & 1 deletion src/tools/tidy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ autobins = false

[dependencies]
cargo_metadata = "0.15"
cargo-platform = "0.1.2"
regex = "1"
miropt-test-tools = { path = "../miropt-test-tools" }
lazy_static = "1"
Expand Down
24 changes: 3 additions & 21 deletions src/tools/tidy/src/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ const PERMITTED_DEPS_LOCATION: &str = concat!(file!(), ":", line!());
/// rustc. Please check with the compiler team before adding an entry.
const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
// tidy-alphabetical-start
"addr2line",
klensy marked this conversation as resolved.
Show resolved Hide resolved
"adler",
"ahash",
"aho-corasick",
Expand Down Expand Up @@ -429,6 +430,7 @@ const PERMITTED_CRANELIFT_DEPENDENCIES: &[&str] = &[
"mach",
"memchr",
"object",
"once_cell",
"regalloc2",
"region",
"rustc-hash",
Expand Down Expand Up @@ -614,27 +616,7 @@ fn check_permitted_dependencies(
let mut deps = HashSet::new();
for to_check in restricted_dependency_crates {
let to_check = pkg_from_name(metadata, to_check);
use cargo_platform::Cfg;
use std::str::FromStr;
// We don't expect the compiler to ever run on wasm32, so strip
// out those dependencies to avoid polluting the permitted list.
deps_of_filtered(metadata, &to_check.id, &mut deps, &|dep_kinds| {
dep_kinds.iter().any(|dep_kind| {
dep_kind
.target
.as_ref()
.map(|target| {
!target.matches(
"wasm32-unknown-unknown",
&[
Cfg::from_str("target_arch=\"wasm32\"").unwrap(),
Cfg::from_str("target_os=\"unknown\"").unwrap(),
],
)
Comment on lines -627 to -633
Copy link
Contributor Author

@klensy klensy Jul 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why, but one of suspects is https://docs.rs/cargo-platform/0.1.2/cargo_platform/enum.Platform.html#method.matches

It says "Returns whether the Platform matches the given target and cfg.", but what means "matches"?

Lets skip target part and look at cfg.

There can be 2 situations:

  1. cfg(not(windows)) matches cfg(target_arch="wasm32") (matches currently): which can be understand as: if X can be Y? But cfg(not(windows)) for example can be x86_64-unknown-linux-gnu which actually not matches cfg(target_arch="wasm32").
  2. If X has cfgs which is Y? cfg(all(target_arch="wasm32",target_os="unknown")) matches cfg(target_arch="wasm32") because target_arch is "wasm32".

But 2. can be broken again if cfg(any(target_arch="wasm32", target_arch="x86_64")) matched against cfg(target_arch="wasm32"), as it can be x86_64-unknown-linux-gnu again, which is not cfg(target_arch="wasm32").

Copy link
Contributor Author

@klensy klensy Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, looks like this don't work as i expected:
Name("wasm32-wasi").matches("", &[Cfg::from_str("target_arch=\"wasm32\"").unwrap(),]) == false, while should return true (ignore part that Platform::matches checks target or cfg).
cargo_platform works on strings and don't know to parse triples or if one cfg turn on other cfgs (for example target_env="msvc" should enable target_os="windows").

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments are messy (for me too, in month later), so, please ask question questions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should try to make this work instead of getting rid of it entirely. If we really want to remove it, we can revert the changes that were made, but I don't believe this is the best solution for this situation.

})
.unwrap_or(true)
})
});
deps_of_filtered(metadata, &to_check.id, &mut deps, &|_| true);
}

// Check that the PERMITTED_DEPENDENCIES does not have unused entries.
Expand Down
Loading