Skip to content

Commit d6580b1

Browse files
committed
Rework Toolchain model and drop relative file path overrides
Relative path overrides permit a freshly downloaded source tree to execute arbitrary code on any rustup command that executes a binary from the configured toolchain, and its a reasonable tradeoff for us to remove this feature. Absolute path overrides are kept intact - these were added to support users of large monorepo tool systems, and can be kept with reasonable safety. Introduce an interior model for toolchain names which allows the elimination of conditional code for custom vs named vs path based toolchains. Fixes #3130. Finishes the separation of Toolchain vs DistributableToolchain vs CustomToolchain started some time ago. Moves some test support into the src tree in order to keep symbols private and adds a 'test' feature required for self-testing, ensuring that that code doesn't affect production builds.
1 parent 4b29b79 commit d6580b1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2312
-2365
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
1. Fork it!
44
2. Create your feature branch: `git checkout -b my-new-feature`
5-
3. Test it: `cargo test`
5+
3. Test it: `cargo test --features=test`
66
4. Lint it: `cargo +beta clippy --all --all-targets -- -D warnings`
77
> We use `cargo clippy` to ensure high-quality code and to enforce a set of best practices for Rust programming. However, not all lints provided by `cargo clippy` are relevant or applicable to our project.
88
> We may choose to ignore some lints if they are unstable, experimental, or specific to our project.
@@ -312,7 +312,7 @@ And [look in Jaeger for a trace](http://localhost:16686/search?service=rustup).
312312

313313
The custom macro `rustup_macros::test` adds a prelude and suffix to each test to
314314
ensure that there is a tracing context setup, that the test function is a span,
315-
and that the spans from the test are flushed. Build with features=otel to
315+
and that the spans from the test are flushed. Build with features=otel,test to
316316
use this feature.
317317

318318
### Adding instrumentation

Cargo.lock

Lines changed: 22 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,29 @@ otel = [
4141
"dep:tokio",
4242
]
4343

44+
# Exports code dependent on private interfaces for the integration test suite
45+
test = ["dep:once_cell", "dep:walkdir"]
46+
4447
# Sorted by alphabetic order
4548
[dependencies]
4649
anyhow.workspace = true
4750
cfg-if = "1.0"
4851
chrono = "0.4"
4952
clap = { version = "3", features = ["wrap_help"] }
5053
clap_complete = "3"
54+
derivative.workspace = true
5155
download = { path = "download", default-features = false }
5256
effective-limits = "0.5.5"
5357
enum-map = "2.5.0"
5458
flate2 = "1"
59+
fs_at.workspace = true
5560
git-testament = "0.2"
5661
home = "0.5.4"
5762
lazy_static.workspace = true
5863
libc = "0.2"
5964
num_cpus = "1.15"
60-
once_cell.workspace = true
65+
once_cell = { workspace = true, optional = true }
6166
opener = "0.6.0"
62-
# Used by `curl` or `reqwest` backend although it isn't imported by our rustup :
63-
# this allows controlling the vendoring status without exposing the presence of
64-
# the download crate.
65-
openssl = { version = "0.10", optional = true }
6667
opentelemetry = { workspace = true, optional = true }
6768
opentelemetry-otlp = { workspace = true, optional = true }
6869
pulldown-cmark = { version = "0.9", default-features = false }
@@ -78,8 +79,7 @@ sharded-slab = "0.1.1"
7879
strsim = "0.10"
7980
tar = "0.4.26"
8081
tempfile.workspace = true
81-
# FIXME(issue #1818, #1826, and friends)
82-
term = "=0.5.1"
82+
term = "=0.5.1" # FIXME(issue #1818, #1826, and friends)
8383
thiserror.workspace = true
8484
threadpool = "1"
8585
tokio = { workspace = true, optional = true }
@@ -91,9 +91,17 @@ tracing-subscriber = { workspace = true, optional = true, features = [
9191
tracing.workspace = true
9292
url.workspace = true
9393
wait-timeout = "0.2"
94+
walkdir = { workspace = true, optional = true }
9495
xz2 = "0.1.3"
9596
zstd = "0.12"
9697

98+
[dependencies.openssl]
99+
# Used by `curl` or `reqwest` backend although it isn't imported by our rustup :
100+
# this allows controlling the vendoring status without exposing the presence of
101+
# the download crate.
102+
optional = true
103+
version = "0.10"
104+
97105
[dependencies.retry]
98106
default-features = false
99107
features = ["random"]
@@ -133,13 +141,27 @@ features = [
133141
]
134142
version = "0.3"
135143

144+
[target."cfg(windows)".dependencies.windows-sys]
145+
features = [
146+
"Win32_Foundation",
147+
"Win32_Storage_FileSystem",
148+
"Win32_System_SystemServices",
149+
"Win32_System_Threading",
150+
"Win32_System_WindowsProgramming",
151+
"Win32_Security",
152+
"Win32_System_Kernel",
153+
"Win32_System_IO",
154+
"Win32_System_Ioctl",
155+
]
156+
version = "0.45.0"
157+
158+
136159
[dev-dependencies]
137160
enum-map = "2.5.0"
138161
once_cell.workspace = true
139162
rustup-macros.workspace = true
140163
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
141164
trycmd = "0.14.13"
142-
walkdir = "2"
143165

144166
[build-dependencies]
145167
lazy_static = "1"
@@ -150,6 +172,8 @@ members = ["download", "rustup-macros"]
150172

151173
[workspace.dependencies]
152174
anyhow = "1.0.69"
175+
derivative = "2.2.0"
176+
fs_at = "0.1.6"
153177
lazy_static = "1"
154178
once_cell = "1.17.1"
155179
opentelemetry = { version = "0.18.0", features = ["rt-tokio"] }
@@ -162,6 +186,7 @@ tracing = "0.1"
162186
tracing-opentelemetry = { version = "0.18.0" }
163187
tracing-subscriber = "0.3.16"
164188
url = "2.3"
189+
walkdir = "2"
165190

166191
[lib]
167192
name = "rustup"

ci/run.bash

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ case "$TARGET" in
2525
* ) FEATURES+=('--features' 'reqwest-rustls-tls') ;;
2626
esac
2727

28+
case "$BUILD_PROFILE" in
29+
release ) ;;
30+
# Default case, includes tests, build tests and otel
31+
* ) FEATURES+=('--features' 'otel,test') ;;
32+
esac
33+
2834
# rustc only supports armv7: https://doc.rust-lang.org/nightly/rustc/platform-support.html
2935
if [ "$TARGET" = arm-linux-androideabi ]; then
3036
export CFLAGS='-march=armv7'

doc/src/environment-variables.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
root `rustup` folder, used for storing installed toolchains and
55
configuration options.
66

7-
- `RUSTUP_TOOLCHAIN` (default: none) If set, will [override] the toolchain
8-
used for all rust tool invocations. A toolchain with this name should be
9-
installed, or invocations will fail.
7+
- `RUSTUP_TOOLCHAIN` (default: none) If set, will [override] the toolchain used
8+
for all rust tool invocations. A toolchain with this name should be installed,
9+
or invocations will fail. This can specify custom toolchains, installable
10+
toolchains, or the absolute path to a toolchain.
1011

1112
- `RUSTUP_DIST_SERVER` (default: `https://static.rust-lang.org`) Sets the root
1213
URL for downloading static resources related to Rust. You can change this to

0 commit comments

Comments
 (0)