Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miri subtree update #125286

Merged
merged 45 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e928185
support `f*_algebraic`
bend-n May 11, 2024
32b2238
Auto merge of #3596 - bend-n:support_fstar_algebraic, r=RalfJung
bors May 11, 2024
bf5906f
Add non-null pointer for posix_memalign
tiif May 12, 2024
fd5e037
Auto merge of #3600 - tiif:non-null-posix-memalign, r=RalfJung
bors May 12, 2024
9fc569d
organize float intrinsic implementations a bit
RalfJung May 12, 2024
5d76ec9
merge float tests into one
RalfJung May 12, 2024
01b5430
merge two integer tests
RalfJung May 12, 2024
14ced80
Auto merge of #3601 - RalfJung:intrinsics, r=RalfJung
bors May 12, 2024
7d565df
Preparing for merge from rustc
RalfJung May 12, 2024
1e7fba9
Merge from rustc
RalfJung May 12, 2024
75d531d
Auto merge of #3602 - RalfJung:rustup, r=RalfJung
bors May 12, 2024
cd7527a
Don't print unnecessary sysroot messages
saethlin May 11, 2024
e4f81d1
Auto merge of #3599 - saethlin:quiet-when-no-change, r=RalfJung
bors May 12, 2024
10acfd9
further illumos/solaris support.
devnexen May 5, 2024
d4937cb
Auto merge of #3575 - devnexen:illumos_part3, r=RalfJung
bors May 12, 2024
c6a0e2c
intrinsics: just panic when they get used incorrectly
RalfJung May 13, 2024
d0b2c66
Auto merge of #3604 - RalfJung:intrinsics, r=RalfJung
bors May 13, 2024
99c6b2e
Give `FileDescription::{read, write}` access to the `InterpCx`
Luv-Ray May 13, 2024
b1b278b
Preparing for merge from rustc
RalfJung May 16, 2024
0334bf8
Merge from rustc
RalfJung May 16, 2024
6d314f3
alloc now works on wasi (and some formatting)
RalfJung May 16, 2024
7e5b9e2
Auto merge of #3606 - RalfJung:rustup, r=RalfJung
bors May 16, 2024
983fb09
start implementing MiriAllocBytes
Strophox Apr 3, 2024
fffc8e9
Auto merge of #3526 - Strophox:miri-memory, r=RalfJung
bors May 17, 2024
5b2fdb6
Auto merge of #3603 - Luv-Ray:issue-3572, r=RalfJung
bors May 17, 2024
318a0fe
Ignore the Helix configuration directory
marc0246 May 17, 2024
421538c
Auto merge of #3611 - marc0246:helix-ignore, r=saethlin
bors May 17, 2024
5ea21ca
support aligned_alloc for unixes support.
devnexen May 7, 2024
1ba83f2
Preparing for merge from rustc
RalfJung May 19, 2024
3460853
Merge from rustc
RalfJung May 19, 2024
8d7c8ac
Auto merge of #3615 - RalfJung:rustup, r=RalfJung
bors May 19, 2024
430298c
a bit of refactoring and tweak the aligned-allocation tests
RalfJung May 19, 2024
844de64
make basic things work on Android
RalfJung May 19, 2024
3726afa
Auto merge of #3585 - devnexen:aligned_alloc, r=RalfJung
bors May 19, 2024
0e41a80
Auto merge of #3616 - RalfJung:android, r=RalfJung
bors May 19, 2024
2b9c1ca
properly print error in 'cargo miri setup --print-sysroot'
RalfJung May 19, 2024
3c15681
Auto merge of #3619 - RalfJung:print-sysroot, r=RalfJung
bors May 19, 2024
b8a7c73
test wasm32-wasip2 instead of the deprecated wasm32-wasi target
RalfJung May 19, 2024
f7520e4
Auto merge of #3620 - RalfJung:wasi, r=RalfJung
bors May 19, 2024
9cba160
use a little arg-parsing helper for miri-script
RalfJung May 19, 2024
a32423c
Auto merge of #3621 - RalfJung:argparse, r=RalfJung
bors May 19, 2024
42cb1ff
Directly implement native exception raise methods in miri
bjorn3 Feb 24, 2024
5e41ff5
various small nits
RalfJung May 19, 2024
85ed056
Auto merge of #3319 - bjorn3:some_more_shims, r=RalfJung
bors May 19, 2024
e93268e
update lockfile
RalfJung May 19, 2024
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
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3426,9 +3426,9 @@ dependencies = [

[[package]]
name = "rustc-build-sysroot"
version = "0.4.7"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab1dbbd1bdf65fdac44c885f6cca147ba179108ce284b60a08ccc04b1f1dbac0"
checksum = "fa3ca63cc537c1cb69e4c2c0afc5fda2ccd36ac84c97d5a4ae05e69b1c834afb"
dependencies = [
"anyhow",
"rustc_version",
Expand Down
1 change: 1 addition & 0 deletions src/tools/miri/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ tex/*/out
*.out
*.rs.bk
.vscode
.helix
*.mm_profdata
perf.data
perf.data.old
Expand Down
4 changes: 2 additions & 2 deletions src/tools/miri/cargo-miri/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ dependencies = [

[[package]]
name = "rustc-build-sysroot"
version = "0.4.7"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab1dbbd1bdf65fdac44c885f6cca147ba179108ce284b60a08ccc04b1f1dbac0"
checksum = "fa3ca63cc537c1cb69e4c2c0afc5fda2ccd36ac84c97d5a4ae05e69b1c834afb"
dependencies = [
"anyhow",
"rustc_version",
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/cargo-miri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ directories = "5"
rustc_version = "0.4"
serde_json = "1.0.40"
cargo_metadata = "0.18.0"
rustc-build-sysroot = "0.4.6"
rustc-build-sysroot = "0.5.2"

# Enable some feature flags that dev-dependencies need but dependencies
# do not. This makes `./miri install` after `./miri build` faster.
Expand Down
87 changes: 44 additions & 43 deletions src/tools/miri/cargo-miri/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

use std::env;
use std::ffi::OsStr;
use std::fmt::Write;
use std::path::PathBuf;
use std::process::{self, Command};

use rustc_build_sysroot::{BuildMode, SysrootBuilder, SysrootConfig};
use rustc_build_sysroot::{BuildMode, SysrootBuilder, SysrootConfig, SysrootStatus};
use rustc_version::VersionMeta;

use crate::util::*;
Expand All @@ -24,6 +23,7 @@ pub fn setup(
let only_setup = matches!(subcommand, MiriCommand::Setup);
let ask_user = !only_setup;
let print_sysroot = only_setup && has_arg_flag("--print-sysroot"); // whether we just print the sysroot path
let show_setup = only_setup && !print_sysroot;
if !only_setup {
if let Some(sysroot) = std::env::var_os("MIRI_SYSROOT") {
// Skip setup step if MIRI_SYSROOT is explicitly set, *unless* we are `cargo miri setup`.
Expand Down Expand Up @@ -115,18 +115,16 @@ pub fn setup(
// `config.toml`.
command.env("RUSTC_WRAPPER", "");

if only_setup && !print_sysroot {
if show_setup {
// Forward output. Even make it verbose, if requested.
command.stdout(process::Stdio::inherit());
command.stderr(process::Stdio::inherit());
for _ in 0..verbose {
command.arg("-v");
}
if quiet {
command.arg("--quiet");
}
} else {
// Suppress output.
command.stdout(process::Stdio::null());
command.stderr(process::Stdio::null());
}

command
Expand All @@ -137,49 +135,52 @@ pub fn setup(
// not apply `RUSTFLAGS` to the sysroot either.
let rustflags = &["-Cdebug-assertions=off", "-Coverflow-checks=on"];

// Do the build.
if print_sysroot || quiet {
// Be silent.
} else {
let mut msg = String::new();
write!(msg, "Preparing a sysroot for Miri (target: {target})").unwrap();
if verbose > 0 {
write!(msg, " in {}", sysroot_dir.display()).unwrap();
}
write!(msg, "...").unwrap();
if only_setup {
// We want to be explicit.
eprintln!("{msg}");
} else {
// We want to be quiet, but still let the user know that something is happening.
eprint!("{msg} ");
let mut after_build_output = String::new(); // what should be printed when the build is done.
let notify = || {
if !quiet {
eprint!("Preparing a sysroot for Miri (target: {target})");
if verbose > 0 {
eprint!(" in {}", sysroot_dir.display());
}
if show_setup {
// Cargo will print things, so we need to finish this line.
eprintln!("...");
after_build_output = format!(
"A sysroot for Miri is now available in `{}`.\n",
sysroot_dir.display()
);
} else {
// Keep all output on a single line.
eprint!("... ");
after_build_output = format!("done\n");
}
}
}
SysrootBuilder::new(&sysroot_dir, target)
};

// Do the build.
let status = SysrootBuilder::new(&sysroot_dir, target)
.build_mode(BuildMode::Check)
.rustc_version(rustc_version.clone())
.sysroot_config(sysroot_config)
.rustflags(rustflags)
.cargo(cargo_cmd)
.build_from_source(&rust_src)
.unwrap_or_else(|err| {
if print_sysroot {
show_error!("failed to build sysroot")
} else if only_setup {
show_error!("failed to build sysroot: {err:?}")
} else {
show_error!(
"failed to build sysroot; run `cargo miri setup` to see the error details"
)
}
});
if print_sysroot || quiet {
// Be silent.
} else if only_setup {
eprintln!("A sysroot for Miri is now available in `{}`.", sysroot_dir.display());
} else {
eprintln!("done");
.when_build_required(notify)
.build_from_source(&rust_src);
match status {
Ok(SysrootStatus::AlreadyCached) =>
if !quiet && show_setup {
eprintln!(
"A sysroot for Miri is already available in `{}`.",
sysroot_dir.display()
);
},
Ok(SysrootStatus::SysrootBuilt) => {
// Print what `notify` prepared.
eprint!("{after_build_output}");
}
Err(err) => show_error!("failed to build sysroot: {err:?}"),
}

if print_sysroot {
// Print just the sysroot and nothing else to stdout; this way we do not need any escaping.
println!("{}", sysroot_dir.display());
Expand Down
20 changes: 10 additions & 10 deletions src/tools/miri/ci/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,16 @@ case $HOST_TARGET in
TEST_TARGET=arm-unknown-linux-gnueabi run_tests
TEST_TARGET=s390x-unknown-linux-gnu run_tests # big-endian architecture of choice
# Partially supported targets (tier 2)
VERY_BASIC="integer vec string btreemap" # common things we test on all of them (if they have std), requires no target-specific shims
BASIC="$VERY_BASIC hello hashmap alloc align" # ensures we have the shims for stdout and basic data structures
TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal $BASIC panic/panic concurrency/simple atomic threadname libc-mem libc-misc libc-random libc-time fs env num_cpus
TEST_TARGET=i686-unknown-freebsd run_tests_minimal $BASIC panic/panic concurrency/simple atomic threadname libc-mem libc-misc libc-random libc-time fs env num_cpus
TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $VERY_BASIC hello panic/panic concurrency/simple pthread-sync libc-mem libc-misc libc-random
TEST_TARGET=x86_64-pc-solaris run_tests_minimal $VERY_BASIC hello panic/panic concurrency/simple pthread-sync libc-mem libc-misc libc-random
TEST_TARGET=aarch64-linux-android run_tests_minimal $VERY_BASIC hello panic/panic
TEST_TARGET=wasm32-wasi run_tests_minimal $VERY_BASIC wasm
TEST_TARGET=wasm32-unknown-unknown run_tests_minimal $VERY_BASIC wasm
TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std
BASIC="empty_main integer vec string btreemap hello hashmap heap_alloc align" # ensures we have the basics: stdout/stderr, system allocator, randomness (for HashMap initialization)
UNIX="panic/panic panic/unwind concurrency/simple atomic libc-mem libc-misc libc-random env num_cpus" # the things that are very similar across all Unixes, and hence easily supported there
TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal $BASIC $UNIX threadname libc-time fs
TEST_TARGET=i686-unknown-freebsd run_tests_minimal $BASIC $UNIX threadname libc-time fs
TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $BASIC $UNIX pthread-sync
TEST_TARGET=x86_64-pc-solaris run_tests_minimal $BASIC $UNIX pthread-sync
TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX
TEST_TARGET=wasm32-wasip2 run_tests_minimal empty_main wasm heap_alloc libc-mem
TEST_TARGET=wasm32-unknown-unknown run_tests_minimal empty_main wasm
TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std
# Custom target JSON file
TEST_TARGET=tests/avr.json MIRI_NO_STD=1 run_tests_minimal no_std
;;
Expand Down
136 changes: 136 additions & 0 deletions src/tools/miri/miri-script/src/args.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
use std::env;
use std::iter;

use anyhow::{bail, Result};

pub struct Args {
args: iter::Peekable<env::Args>,
/// Set to `true` once we saw a `--`.
terminated: bool,
}

impl Args {
pub fn new() -> Self {
let mut args = Args { args: env::args().peekable(), terminated: false };
args.args.next().unwrap(); // skip program name
args
}

/// Get the next argument without any interpretation.
pub fn next_raw(&mut self) -> Option<String> {
self.args.next()
}

/// Consume a `-$f` flag if present.
pub fn get_short_flag(&mut self, flag: char) -> Result<bool> {
if self.terminated {
return Ok(false);
}
if let Some(next) = self.args.peek() {
if let Some(next) = next.strip_prefix("-") {
if let Some(next) = next.strip_prefix(flag) {
if next.is_empty() {
self.args.next().unwrap(); // consume this argument
return Ok(true);
} else {
bail!("`-{flag}` followed by value");
}
}
}
}
Ok(false)
}

/// Consume a `--$name` flag if present.
pub fn get_long_flag(&mut self, name: &str) -> Result<bool> {
if self.terminated {
return Ok(false);
}
if let Some(next) = self.args.peek() {
if let Some(next) = next.strip_prefix("--") {
if next == name {
self.args.next().unwrap(); // consume this argument
return Ok(true);
}
}
}
Ok(false)
}

/// Consume a `--$name val` or `--$name=val` option if present.
pub fn get_long_opt(&mut self, name: &str) -> Result<Option<String>> {
assert!(!name.is_empty());
if self.terminated {
return Ok(None);
}
let Some(next) = self.args.peek() else { return Ok(None) };
let Some(next) = next.strip_prefix("--") else { return Ok(None) };
let Some(next) = next.strip_prefix(name) else { return Ok(None) };
// Starts with `--flag`.
Ok(if let Some(val) = next.strip_prefix("=") {
// `--flag=val` form
let val = val.into();
self.args.next().unwrap(); // consume this argument
Some(val)
} else if next.is_empty() {
// `--flag val` form
self.args.next().unwrap(); // consume this argument
let Some(val) = self.args.next() else { bail!("`--{name}` not followed by value") };
Some(val)
} else {
// Some unrelated flag, like `--flag-more` or so.
None
})
}

/// Consume a `--$name=val` or `--$name` option if present; the latter
/// produces a default value. (`--$name val` is *not* accepted for this form
/// of argument, it understands `val` already as the next argument!)
pub fn get_long_opt_with_default(
&mut self,
name: &str,
default: &str,
) -> Result<Option<String>> {
assert!(!name.is_empty());
if self.terminated {
return Ok(None);
}
let Some(next) = self.args.peek() else { return Ok(None) };
let Some(next) = next.strip_prefix("--") else { return Ok(None) };
let Some(next) = next.strip_prefix(name) else { return Ok(None) };
// Starts with `--flag`.
Ok(if let Some(val) = next.strip_prefix("=") {
// `--flag=val` form
let val = val.into();
self.args.next().unwrap(); // consume this argument
Some(val)
} else if next.is_empty() {
// `--flag` form
self.args.next().unwrap(); // consume this argument
Some(default.into())
} else {
// Some unrelated flag, like `--flag-more` or so.
None
})
}

/// Returns the next free argument or uninterpreted flag, or `None` if there are no more
/// arguments left. `--` is returned as well, but it is interpreted in the sense that no more
/// flags will be parsed after this.
pub fn get_other(&mut self) -> Option<String> {
if self.terminated {
return self.args.next();
}
let next = self.args.next()?;
if next == "--" {
self.terminated = true; // don't parse any more flags
// This is where our parser is special, we do yield the `--`.
}
Some(next)
}

/// Return the rest of the aguments entirely unparsed.
pub fn remainder(self) -> Vec<String> {
self.args.collect()
}
}
Loading
Loading