Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
f9e9856
add more tests for SC access/fence consistency
RalfJung Dec 12, 2024
7b29daf
Merge pull request #4090 from RalfJung/sc-test
RalfJung Dec 21, 2024
9c87ec8
remove an unused helper method
RalfJung Dec 21, 2024
58ad698
Merge pull request #4103 from RalfJung/remove-unused
RalfJung Dec 21, 2024
38e3ebc
miri-script: support saving bench results in a baseline JSON file
RalfJung Dec 22, 2024
40b3310
miri-script: add option to compare with baseline results
RalfJung Dec 22, 2024
41f3edc
CONTRIBUTING: explain how to do benchmarking with a baseline
RalfJung Dec 22, 2024
bba6f0a
Merge pull request #4104 from RalfJung/bench
RalfJung Dec 22, 2024
d80f319
add -Zmiri-many-seeds flag to the driver itself
RalfJung Dec 23, 2024
0bd76e1
remove many-seeds mode from cargo-miri
RalfJung Dec 23, 2024
d04b972
remove --many-seeds from ./miri run
RalfJung Dec 23, 2024
0f49f0f
stop using process-wide state, now that we are running multiple inter…
RalfJung Dec 23, 2024
4116585
many-seeds: add flag to keep going even after we found a failing seed
RalfJung Dec 23, 2024
fdfd064
use std::sync::Once instead of hand-rolling a bad version of it
RalfJung Dec 23, 2024
cb73bb6
Merge pull request #4105 from RalfJung/many-seeds
oli-obk Dec 23, 2024
2de4561
show an error on some invalid flag combinations: TB + permissive prov…
RalfJung Dec 24, 2024
b109091
remove some flags that have been hard errors for a while
RalfJung Dec 24, 2024
35f10b1
we generally make later flags overwrite earlier flags, so remove some…
RalfJung Dec 24, 2024
60e3bf4
Merge pull request #4109 from RalfJung/flags
RalfJung Dec 26, 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
Prev Previous commit
Next Next commit
use std::sync::Once instead of hand-rolling a bad version of it
  • Loading branch information
RalfJung committed Dec 23, 2024
commit fdfd064c6256bfa330bf778cf19d7f2a822b3a12
25 changes: 12 additions & 13 deletions src/tools/miri/src/bin/miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ use std::num::NonZero;
use std::ops::Range;
use std::path::PathBuf;
use std::str::FromStr;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, AtomicI32, Ordering};
use std::sync::atomic::{AtomicI32, Ordering};
use std::sync::{Arc, Once};

use miri::{
BacktraceStyle, BorrowTrackerMethod, MiriConfig, ProvenanceMode, RetagFields, ValidationMode,
Expand Down Expand Up @@ -335,26 +335,24 @@ fn rustc_logger_config() -> rustc_log::LoggerConfig {

/// The global logger can only be set once per process, so track
/// whether that already happened.
static LOGGER_INITED: AtomicBool = AtomicBool::new(false);
static LOGGER_INITED: Once = Once::new();

fn init_early_loggers(early_dcx: &EarlyDiagCtxt) {
// Now for rustc. We only initialize `rustc` if the env var is set (so the user asked for it).
// We only initialize `rustc` if the env var is set (so the user asked for it).
// If it is not set, we avoid initializing now so that we can initialize later with our custom
// settings, and *not* log anything for what happens before `miri` gets started.
// settings, and *not* log anything for what happens before `miri` starts interpreting.
if env::var_os("RUSTC_LOG").is_some() {
rustc_driver::init_logger(early_dcx, rustc_logger_config());
assert!(!LOGGER_INITED.swap(true, Ordering::AcqRel));
LOGGER_INITED.call_once(|| {
rustc_driver::init_logger(early_dcx, rustc_logger_config());
});
}
}

fn init_late_loggers(early_dcx: &EarlyDiagCtxt, tcx: TyCtxt<'_>) {
// If the logger is not yet initialized, initialize it.
if !LOGGER_INITED.swap(true, Ordering::AcqRel) {
LOGGER_INITED.call_once(|| {
rustc_driver::init_logger(early_dcx, rustc_logger_config());
}
// There's a little race condition here in many-seeds mode, where we don't wait for the thread
// that is doing the initializing. But if you want to debug things with extended logging you
// probably won't use many-seeds mode anyway.
});

// If `MIRI_BACKTRACE` is set and `RUSTC_CTFE_BACKTRACE` is not, set `RUSTC_CTFE_BACKTRACE`.
// Do this late, so we ideally only apply this to Miri's errors.
Expand Down Expand Up @@ -742,8 +740,9 @@ fn main() {
if many_seeds.is_some() && miri_config.seed.is_some() {
show_error!("Only one of `-Zmiri-seed` and `-Zmiri-many-seeds can be set");
}

// Ensure we have parallelism for many-seeds mode.
if many_seeds.is_some() && !rustc_args.iter().any(|arg| arg.starts_with("-Zthreads=")) {
// Ensure we have parallelism for many-seeds mode.
rustc_args.push(format!(
"-Zthreads={}",
std::thread::available_parallelism().map_or(1, |n| n.get())
Expand Down