Skip to content

Commit 1d79e99

Browse files
authored
Merge pull request #4598 from rust-lang/rustup-2025-09-20
Automatic Rustup
2 parents 2810ef3 + b5229b9 commit 1d79e99

File tree

5 files changed

+58
-9
lines changed

5 files changed

+58
-9
lines changed

.github/workflows/ci.yml

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,41 @@ jobs:
117117
- name: rustdoc
118118
run: RUSTDOCFLAGS="-Dwarnings" ./miri doc --document-private-items
119119

120+
bootstrap:
121+
name: bootstrap build
122+
runs-on: ubuntu-latest
123+
steps:
124+
- uses: actions/checkout@v4
125+
# Deliberately skipping `./.github/workflows/setup` as we do our own setup
126+
- name: Add cache for cargo
127+
id: cache
128+
uses: actions/cache@v4
129+
with:
130+
path: |
131+
# Taken from <https://doc.rust-lang.org/nightly/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci>.
132+
# Cache package/registry information
133+
~/.cargo/registry/index
134+
~/.cargo/registry/cache
135+
~/.cargo/git/db
136+
# Cache bootstrap downloads
137+
../rust/build/cache
138+
key: cargo-bootstrap-${{ hashFiles('rust-version') }}
139+
restore-keys: cargo-bootstrap
140+
- name: prepare build environment
141+
run: |
142+
MIRIDIR=$(pwd)
143+
cd ..
144+
# Bootstrap needs at least depth 2 to function.
145+
git clone https://github.com/rust-lang/rust/ rust --depth 2 --revision $(cat "$MIRIDIR/rust-version")
146+
cd rust
147+
# Replace the in-tree Miri with the current version.
148+
rm src/tools/miri -rf
149+
ln -s "$MIRIDIR" src/tools/miri
150+
- name: check build
151+
run: |
152+
cd ../rust # ./x does not seem to like being invoked from elsewhere
153+
./x check miri
154+
120155
coverage:
121156
name: coverage report
122157
runs-on: ubuntu-latest
@@ -130,7 +165,7 @@ jobs:
130165
# ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
131166
# And they should be added below in `cron-fail-notify` as well.
132167
conclusion:
133-
needs: [test, style, coverage]
168+
needs: [test, style, bootstrap, coverage]
134169
# We need to ensure this job does *not* get skipped if its dependencies fail,
135170
# because a skipped job is considered a success by GitHub. So we have to
136171
# overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run
@@ -211,7 +246,7 @@ jobs:
211246
cron-fail-notify:
212247
name: cronjob failure notification
213248
runs-on: ubuntu-latest
214-
needs: [test, style, coverage]
249+
needs: [test, style, bootstrap, coverage]
215250
if: ${{ github.event_name == 'schedule' && failure() }}
216251
steps:
217252
# Send a Zulip notification

miri-script/src/commands.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,15 @@ impl Command {
130130
let new_commit = sh.read_file("rust-version")?.trim().to_owned();
131131
let current_commit = {
132132
let rustc_info = cmd!(sh, "rustc +miri --version -v").read();
133-
if rustc_info.is_err() {
134-
None
135-
} else {
136-
let metadata = rustc_version::version_meta_for(&rustc_info.unwrap())?;
133+
if let Ok(rustc_info) = rustc_info {
134+
let metadata = rustc_version::version_meta_for(&rustc_info)?;
137135
Some(
138136
metadata
139137
.commit_hash
140138
.ok_or_else(|| anyhow!("rustc metadata did not contain commit hash"))?,
141139
)
140+
} else {
141+
None
142142
}
143143
};
144144
// Check if we already are at that commit.

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3f1552a273e43e15f6ed240d00e1efdd6a53e65e
1+
ec38671075266e9cee0348701da2e133379e7c6c

src/clock.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,21 @@ impl Instant {
4646
InstantKind::Virtual { nanoseconds: earlier },
4747
) => {
4848
let duration = nanoseconds.saturating_sub(earlier);
49-
Duration::from_nanos_u128(duration)
49+
cfg_select! {
50+
bootstrap => {
51+
// `Duration` does not provide a nice constructor from a `u128` of nanoseconds,
52+
// so we have to implement this ourselves.
53+
// It is possible for second to overflow because u64::MAX < (u128::MAX / 1e9).
54+
// It will be saturated to u64::MAX seconds if the value after division exceeds u64::MAX.
55+
let seconds = u64::try_from(duration / 1_000_000_000).unwrap_or(u64::MAX);
56+
// It is impossible for nanosecond to overflow because u32::MAX > 1e9.
57+
let nanosecond = u32::try_from(duration.wrapping_rem(1_000_000_000)).unwrap();
58+
Duration::new(seconds, nanosecond)
59+
}
60+
_ => {
61+
Duration::from_nanos_u128(duration)
62+
}
63+
}
5064
}
5165
_ => panic!("all `Instant` must be of the same kind"),
5266
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#![feature(derive_coerce_pointee)]
1919
#![feature(arbitrary_self_types)]
2020
#![feature(iter_advance_by)]
21-
#![feature(duration_from_nanos_u128)]
21+
#![cfg_attr(not(bootstrap), feature(duration_from_nanos_u128))]
2222
// Configure clippy and other lints
2323
#![allow(
2424
clippy::collapsible_else_if,

0 commit comments

Comments
 (0)