Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,41 @@ jobs:
- name: rustdoc
run: RUSTDOCFLAGS="-Dwarnings" ./miri doc --document-private-items

bootstrap:
name: bootstrap build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Deliberately skipping `./.github/workflows/setup` as we do our own setup
- name: Add cache for cargo
id: cache
uses: actions/cache@v4
with:
path: |
# Taken from <https://doc.rust-lang.org/nightly/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci>.
# Cache package/registry information
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
# Cache bootstrap downloads
../rust/build/cache
key: cargo-bootstrap-${{ hashFiles('rust-version') }}
restore-keys: cargo-bootstrap
- name: prepare build environment
run: |
MIRIDIR=$(pwd)
cd ..
# Bootstrap needs at least depth 2 to function.
git clone https://github.com/rust-lang/rust/ rust --depth 2 --revision $(cat "$MIRIDIR/rust-version")
cd rust
# Replace the in-tree Miri with the current version.
rm src/tools/miri -rf
ln -s "$MIRIDIR" src/tools/miri
- name: check build
run: |
cd ../rust # ./x does not seem to like being invoked from elsewhere
./x check miri

coverage:
name: coverage report
runs-on: ubuntu-latest
Expand All @@ -130,7 +165,7 @@ jobs:
# ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
# And they should be added below in `cron-fail-notify` as well.
conclusion:
needs: [test, style, coverage]
needs: [test, style, bootstrap, coverage]
# We need to ensure this job does *not* get skipped if its dependencies fail,
# because a skipped job is considered a success by GitHub. So we have to
# overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run
Expand Down Expand Up @@ -211,7 +246,7 @@ jobs:
cron-fail-notify:
name: cronjob failure notification
runs-on: ubuntu-latest
needs: [test, style, coverage]
needs: [test, style, bootstrap, coverage]
if: ${{ github.event_name == 'schedule' && failure() }}
steps:
# Send a Zulip notification
Expand Down
8 changes: 4 additions & 4 deletions miri-script/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ impl Command {
let new_commit = sh.read_file("rust-version")?.trim().to_owned();
let current_commit = {
let rustc_info = cmd!(sh, "rustc +miri --version -v").read();
if rustc_info.is_err() {
None
} else {
let metadata = rustc_version::version_meta_for(&rustc_info.unwrap())?;
if let Ok(rustc_info) = rustc_info {
let metadata = rustc_version::version_meta_for(&rustc_info)?;
Some(
metadata
.commit_hash
.ok_or_else(|| anyhow!("rustc metadata did not contain commit hash"))?,
)
} else {
None
}
};
// Check if we already are at that commit.
Expand Down
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3f1552a273e43e15f6ed240d00e1efdd6a53e65e
ec38671075266e9cee0348701da2e133379e7c6c
16 changes: 15 additions & 1 deletion src/clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,21 @@ impl Instant {
InstantKind::Virtual { nanoseconds: earlier },
) => {
let duration = nanoseconds.saturating_sub(earlier);
Duration::from_nanos_u128(duration)
cfg_select! {
bootstrap => {
// `Duration` does not provide a nice constructor from a `u128` of nanoseconds,
// so we have to implement this ourselves.
// It is possible for second to overflow because u64::MAX < (u128::MAX / 1e9).
// It will be saturated to u64::MAX seconds if the value after division exceeds u64::MAX.
let seconds = u64::try_from(duration / 1_000_000_000).unwrap_or(u64::MAX);
// It is impossible for nanosecond to overflow because u32::MAX > 1e9.
let nanosecond = u32::try_from(duration.wrapping_rem(1_000_000_000)).unwrap();
Duration::new(seconds, nanosecond)
}
_ => {
Duration::from_nanos_u128(duration)
}
}
}
_ => panic!("all `Instant` must be of the same kind"),
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#![feature(derive_coerce_pointee)]
#![feature(arbitrary_self_types)]
#![feature(iter_advance_by)]
#![feature(duration_from_nanos_u128)]
#![cfg_attr(not(bootstrap), feature(duration_from_nanos_u128))]
// Configure clippy and other lints
#![allow(
clippy::collapsible_else_if,
Expand Down