Skip to content

Commit befa5c9

Browse files
weihangloMuscraftehuss
committed
chore: remove rustc-workspace-hack
Co-authored-by: Scott Schafer <schaferjscott@gmail.com> Co-authored-by: Eric Huss <eric@huss.org>
1 parent 1cfaa34 commit befa5c9

File tree

8 files changed

+4
-191
lines changed

8 files changed

+4
-191
lines changed

Diff for: Cargo.lock

+2-6
Original file line numberDiff line numberDiff line change
@@ -2773,7 +2773,6 @@ dependencies = [
27732773
name = "rls"
27742774
version = "2.0.0"
27752775
dependencies = [
2776-
"rustc-workspace-hack",
27772776
"serde",
27782777
"serde_json",
27792778
]
@@ -2885,11 +2884,8 @@ dependencies = [
28852884
[[package]]
28862885
name = "rustc-workspace-hack"
28872886
version = "1.0.0"
2888-
dependencies = [
2889-
"libc",
2890-
"regex",
2891-
"serde_json",
2892-
]
2887+
source = "registry+https://github.com/rust-lang/crates.io-index"
2888+
checksum = "fc71d2faa173b74b232dedc235e3ee1696581bb132fc116fa3626d6151a1a8fb"
28932889

28942890
[[package]]
28952891
name = "rustc_abi"

Diff for: Cargo.toml

-4
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,6 @@ miniz_oxide.debug = 0
100100
object.debug = 0
101101

102102
[patch.crates-io]
103-
# See comments in `src/tools/rustc-workspace-hack/README.md` for what's going on
104-
# here
105-
rustc-workspace-hack = { path = 'src/tools/rustc-workspace-hack' }
106-
107103
# See comments in `library/rustc-std-workspace-core/README.md` for what's going on
108104
# here
109105
rustc-std-workspace-core = { path = 'library/rustc-std-workspace-core' }

Diff for: src/bootstrap/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,6 @@ pub struct Build {
238238
ci_env: CiEnv,
239239
delayed_failures: RefCell<Vec<String>>,
240240
prerelease_version: Cell<Option<u32>>,
241-
tool_artifacts:
242-
RefCell<HashMap<TargetSelection, HashMap<String, (&'static str, PathBuf, Vec<String>)>>>,
243241

244242
#[cfg(feature = "build-metrics")]
245243
metrics: metrics::BuildMetrics,
@@ -458,7 +456,6 @@ impl Build {
458456
ci_env: CiEnv::current(),
459457
delayed_failures: RefCell::new(Vec::new()),
460458
prerelease_version: Cell::new(None),
461-
tool_artifacts: Default::default(),
462459

463460
#[cfg(feature = "build-metrics")]
464461
metrics: metrics::BuildMetrics::init(),

Diff for: src/bootstrap/tool.rs

+2-129
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use std::collections::HashSet;
21
use std::env;
32
use std::fs;
43
use std::path::PathBuf;
@@ -120,136 +119,10 @@ impl Step for ToolBuild {
120119
&self.target,
121120
);
122121
builder.info(&msg);
123-
let mut duplicates = Vec::new();
124-
let is_expected = compile::stream_cargo(builder, cargo, vec![], &mut |msg| {
125-
// Only care about big things like the RLS/Cargo for now
126-
match tool {
127-
"rls" | "clippy-driver" | "miri" | "rustfmt" => {}
128-
129-
_ => return,
130-
}
131-
let (id, features, filenames) = match msg {
132-
compile::CargoMessage::CompilerArtifact {
133-
package_id,
134-
features,
135-
filenames,
136-
target: _,
137-
} => (package_id, features, filenames),
138-
_ => return,
139-
};
140-
let features = features.iter().map(|s| s.to_string()).collect::<Vec<_>>();
141-
142-
for path in filenames {
143-
let val = (tool, PathBuf::from(&*path), features.clone());
144-
// we're only interested in deduplicating rlibs for now
145-
if val.1.extension().and_then(|s| s.to_str()) != Some("rlib") {
146-
continue;
147-
}
148-
149-
// Don't worry about compiles that turn out to be host
150-
// dependencies or build scripts. To skip these we look for
151-
// anything that goes in `.../release/deps` but *doesn't* go in
152-
// `$target/release/deps`. This ensure that outputs in
153-
// `$target/release` are still considered candidates for
154-
// deduplication.
155-
if let Some(parent) = val.1.parent() {
156-
if parent.ends_with("release/deps") {
157-
let maybe_target = parent
158-
.parent()
159-
.and_then(|p| p.parent())
160-
.and_then(|p| p.file_name())
161-
.and_then(|p| p.to_str())
162-
.unwrap();
163-
if maybe_target != &*target.triple {
164-
continue;
165-
}
166-
}
167-
}
168-
169-
// Record that we've built an artifact for `id`, and if one was
170-
// already listed then we need to see if we reused the same
171-
// artifact or produced a duplicate.
172-
let mut artifacts = builder.tool_artifacts.borrow_mut();
173-
let prev_artifacts = artifacts.entry(target).or_default();
174-
let prev = match prev_artifacts.get(&*id) {
175-
Some(prev) => prev,
176-
None => {
177-
prev_artifacts.insert(id.to_string(), val);
178-
continue;
179-
}
180-
};
181-
if prev.1 == val.1 {
182-
return; // same path, same artifact
183-
}
184-
185-
// If the paths are different and one of them *isn't* inside of
186-
// `release/deps`, then it means it's probably in
187-
// `$target/release`, or it's some final artifact like
188-
// `libcargo.rlib`. In these situations Cargo probably just
189-
// copied it up from `$target/release/deps/libcargo-xxxx.rlib`,
190-
// so if the features are equal we can just skip it.
191-
let prev_no_hash = prev.1.parent().unwrap().ends_with("release/deps");
192-
let val_no_hash = val.1.parent().unwrap().ends_with("release/deps");
193-
if prev.2 == val.2 || !prev_no_hash || !val_no_hash {
194-
return;
195-
}
196-
197-
// ... and otherwise this looks like we duplicated some sort of
198-
// compilation, so record it to generate an error later.
199-
duplicates.push((id.to_string(), val, prev.clone()));
200-
}
122+
let is_expected = compile::stream_cargo(builder, cargo, vec![], &mut |_msg| {
123+
return;
201124
});
202125

203-
if is_expected && !duplicates.is_empty() {
204-
eprintln!(
205-
"duplicate artifacts found when compiling a tool, this \
206-
typically means that something was recompiled because \
207-
a transitive dependency has different features activated \
208-
than in a previous build:\n"
209-
);
210-
let (same, different): (Vec<_>, Vec<_>) =
211-
duplicates.into_iter().partition(|(_, cur, prev)| cur.2 == prev.2);
212-
if !same.is_empty() {
213-
eprintln!(
214-
"the following dependencies are duplicated although they \
215-
have the same features enabled:"
216-
);
217-
for (id, cur, prev) in same {
218-
eprintln!(" {}", id);
219-
// same features
220-
eprintln!(" `{}` ({:?})\n `{}` ({:?})", cur.0, cur.1, prev.0, prev.1);
221-
}
222-
}
223-
if !different.is_empty() {
224-
eprintln!("the following dependencies have different features:");
225-
for (id, cur, prev) in different {
226-
eprintln!(" {}", id);
227-
let cur_features: HashSet<_> = cur.2.into_iter().collect();
228-
let prev_features: HashSet<_> = prev.2.into_iter().collect();
229-
eprintln!(
230-
" `{}` additionally enabled features {:?} at {:?}",
231-
cur.0,
232-
&cur_features - &prev_features,
233-
cur.1
234-
);
235-
eprintln!(
236-
" `{}` additionally enabled features {:?} at {:?}",
237-
prev.0,
238-
&prev_features - &cur_features,
239-
prev.1
240-
);
241-
}
242-
}
243-
eprintln!();
244-
eprintln!(
245-
"to fix this you will probably want to edit the local \
246-
src/tools/rustc-workspace-hack/Cargo.toml crate, as \
247-
that will update the dependency graph to ensure that \
248-
these crates all share the same feature set"
249-
);
250-
panic!("tools should not compile multiple copies of the same crate");
251-
}
252-
253126
builder.save_toolstate(
254127
tool,
255128
if is_expected { ToolState::TestFail } else { ToolState::BuildFail },

Diff for: src/tools/rls/Cargo.toml

-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,3 @@ license = "Apache-2.0/MIT"
77
[dependencies]
88
serde = { version = "1.0.143", features = ["derive"] }
99
serde_json = "1.0.83"
10-
# A noop dependency that changes in the Rust repository, it's a bit of a hack.
11-
# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust`
12-
# for more information.
13-
rustc-workspace-hack = "1.0.0"

Diff for: src/tools/rustc-workspace-hack/Cargo.toml

-19
This file was deleted.

Diff for: src/tools/rustc-workspace-hack/README.md

-25
This file was deleted.

Diff for: src/tools/rustc-workspace-hack/lib.rs

-1
This file was deleted.

0 commit comments

Comments
 (0)