|
1 |
| -use std::collections::HashSet; |
2 | 1 | use std::env;
|
3 | 2 | use std::fs;
|
4 | 3 | use std::path::PathBuf;
|
@@ -120,136 +119,10 @@ impl Step for ToolBuild {
|
120 | 119 | &self.target,
|
121 | 120 | );
|
122 | 121 | 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; |
201 | 124 | });
|
202 | 125 |
|
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 |
| - |
253 | 126 | builder.save_toolstate(
|
254 | 127 | tool,
|
255 | 128 | if is_expected { ToolState::TestFail } else { ToolState::BuildFail },
|
|
0 commit comments