Skip to content

Commit 7e8ca9f

Browse files
committed
Auto merge of #52919 - alexcrichton:update-cargo, r=Mark-Simulacrum
Update tool submodules, update feature unification strategy * Bring in some fixes for `cargo fix` * Update RLS/rustfmt to keep them compiling * Update all tools to [depend on `rustc-workspace-hack`](#52919 (comment)) * Change how we deal with feature unification amongst these builds.
2 parents 1e3c45a + 0e034d1 commit 7e8ca9f

File tree

11 files changed

+244
-39
lines changed

11 files changed

+244
-39
lines changed

src/Cargo.lock

+149-34
Large diffs are not rendered by default.

src/Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,15 @@ debug-assertions = false
5252
[patch."https://github.com/rust-lang/cargo"]
5353
cargo = { path = "tools/cargo" }
5454

55-
[patch."https://github.com/rust-lang-nursery/rustfmt"]
55+
[patch.crates-io]
5656
# Similar to Cargo above we want the RLS to use a vendored version of `rustfmt`
5757
# that we're shipping as well (to ensure that the rustfmt in RLS and the
5858
# `rustfmt` executable are the same exact version).
5959
rustfmt-nightly = { path = "tools/rustfmt" }
6060

61+
# See comments in `tools/rustc-workspace-hack/README.md` for what's going on
62+
# here
63+
rustc-workspace-hack = { path = 'tools/rustc-workspace-hack' }
64+
6165
[patch."https://github.com/rust-lang-nursery/rust-clippy"]
6266
clippy_lints = { path = "tools/clippy/clippy_lints" }

src/bootstrap/test.rs

+2
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ impl Step for Rls {
298298
cargo.env("RLS_TEST_WORKSPACE_DIR", test_workspace_path);
299299

300300
builder.add_rustc_lib_path(compiler, &mut cargo);
301+
cargo.arg("--")
302+
.args(builder.config.cmd.test_args());
301303

302304
if try_run(builder, &mut cargo) {
303305
builder.save_toolstate("rls", ToolState::TestPass);

src/bootstrap/tool.rs

+4
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ impl Step for ToolBuild {
221221
prev.0, &prev_features - &cur_features, prev.1);
222222
}
223223
println!("");
224+
println!("to fix this you will probably want to edit the local \
225+
src/tools/rustc-workspace-hack/Cargo.toml crate, as \
226+
that will update the dependency graph to ensure that \
227+
these crates all share the same feature set");
224228
panic!("tools should not compile multiple copies of the same crate");
225229
}
226230

src/tools/cargo

Submodule cargo updated 92 files

src/tools/clippy

src/tools/rls

Submodule rls updated from 4c7cc91 to 0e8d1f3
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[package]
2+
name = "rustc-workspace-hack"
3+
version = "1.0.0"
4+
authors = ["Alex Crichton <[email protected]>"]
5+
license = 'MIT/Apache-2.0'
6+
description = """
7+
Hack for the compiler's own build system
8+
"""
9+
10+
[lib]
11+
path = "lib.rs"
12+
13+
# For documentation about what this is and why in the world these dependencies
14+
# are appearing, see `README.md`.
15+
16+
[build-dependencies]
17+
# Currently Cargo/RLS depend on `failure` which depends on `synstructure` which
18+
# enables this feature. Clippy, however, does not depend on anything that
19+
# enables this feature. Enable it unconditionally.
20+
syn = { version = "0.14", features = ['extra-traits'] }
21+
22+
[target.'cfg(windows)'.dependencies.winapi]
23+
version = "0.3"
24+
features = [
25+
"profileapi",
26+
"memoryapi",
27+
"minschannel",
28+
"securitybaseapi",
29+
"jobapi2",
30+
"schannel",
31+
"sysinfoapi",
32+
"jobapi",
33+
"synchapi",
34+
"wincrypt",
35+
"winbase",
36+
"minwinbase",
37+
"ntsecapi",
38+
"basetsd",
39+
"ntstatus",
40+
"psapi",
41+
"timezoneapi",
42+
"lmcons",
43+
"wincon",
44+
]
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# `rustc-workspace-hack`
2+
3+
This crate is a bit of a hack to make workspaces in rustc work a bit better.
4+
The rationale for this existence is a bit subtle, but the general idea is that
5+
we want commands like `./x.py build src/tools/{rls,clippy,cargo}` to share as
6+
many dependencies as possible.
7+
8+
Each invocation is a different invocation of Cargo, however. Each time Cargo
9+
runs a build it will re-resolve the dependency graph, notably selecting
10+
different features sometimes for each build.
11+
12+
For example, let's say there's a very deep dependency like `num-traits` in each
13+
of these builds. For Cargo the `num-traits`'s `default` feature is turned off.
14+
In RLS, however, the `default` feature is turned. This means that building Cargo
15+
and then the RLS will actually build Cargo twice (as a transitive dependency
16+
changed). This is bad!
17+
18+
The goal of this crate is to solve this problem and ensure that the resolved
19+
dependency graph for all of these tools is the same in the various subsets of
20+
each tool, notably enabling the same features of transitive dependencies.
21+
22+
All tools vendored here depend on the `rustc-workspace-hack` crate on crates.io.
23+
When on crates.io this crate is an empty crate that is just a noop. We override
24+
it, however, in this workspace to this crate here, which means we can control
25+
crates in the dependency graph for each of these tools.

src/tools/rustc-workspace-hack/lib.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// intentionally left blank

src/tools/rustfmt

0 commit comments

Comments
 (0)