@@ -29,11 +29,12 @@ use std::num::NonZero;
29
29
use std:: ops:: Range ;
30
30
use std:: path:: PathBuf ;
31
31
use std:: str:: FromStr ;
32
- use std:: sync:: atomic :: { AtomicI32 , Ordering } ;
33
- use std:: sync:: { Arc , Once } ;
32
+ use std:: sync:: Once ;
33
+ use std:: sync:: atomic :: { AtomicI32 , AtomicU32 , Ordering } ;
34
34
35
35
use miri:: {
36
- BacktraceStyle , BorrowTrackerMethod , MiriConfig , ProvenanceMode , RetagFields , ValidationMode ,
36
+ BacktraceStyle , BorrowTrackerMethod , MiriConfig , MiriEntryFnType , ProvenanceMode , RetagFields ,
37
+ ValidationMode ,
37
38
} ;
38
39
use rustc_abi:: ExternAbi ;
39
40
use rustc_data_structures:: sync;
@@ -51,7 +52,7 @@ use rustc_middle::query::LocalCrate;
51
52
use rustc_middle:: traits:: { ObligationCause , ObligationCauseCode } ;
52
53
use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
53
54
use rustc_middle:: util:: Providers ;
54
- use rustc_session:: config:: { CrateType , EntryFnType , ErrorOutputType , OptLevel } ;
55
+ use rustc_session:: config:: { CrateType , ErrorOutputType , OptLevel } ;
55
56
use rustc_session:: search_paths:: PathKind ;
56
57
use rustc_session:: { CtfeBacktrace , EarlyDiagCtxt } ;
57
58
use rustc_span:: def_id:: DefId ;
@@ -73,9 +74,9 @@ impl MiriCompilerCalls {
73
74
}
74
75
}
75
76
76
- fn entry_fn ( tcx : TyCtxt < ' _ > ) -> ( DefId , EntryFnType ) {
77
- if let Some ( entry_def ) = tcx. entry_fn ( ( ) ) {
78
- return entry_def ;
77
+ fn entry_fn ( tcx : TyCtxt < ' _ > ) -> ( DefId , MiriEntryFnType ) {
78
+ if let Some ( ( def_id , entry_type ) ) = tcx. entry_fn ( ( ) ) {
79
+ return ( def_id , MiriEntryFnType :: Rustc ( entry_type ) ) ;
79
80
}
80
81
// Look for a symbol in the local crate named `miri_start`, and treat that as the entry point.
81
82
let sym = tcx. exported_symbols ( LOCAL_CRATE ) . iter ( ) . find_map ( |( sym, _) | {
@@ -102,7 +103,7 @@ fn entry_fn(tcx: TyCtxt<'_>) -> (DefId, EntryFnType) {
102
103
. is_ok ( ) ;
103
104
104
105
if correct_func_sig {
105
- ( * id, EntryFnType :: Start )
106
+ ( * id, MiriEntryFnType :: MiriStart )
106
107
} else {
107
108
tcx. dcx ( ) . fatal (
108
109
"`miri_start` must have the following signature:\n \
@@ -182,7 +183,8 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
182
183
if let Some ( many_seeds) = self . many_seeds . take ( ) {
183
184
assert ! ( config. seed. is_none( ) ) ;
184
185
let exit_code = sync:: IntoDynSyncSend ( AtomicI32 :: new ( rustc_driver:: EXIT_SUCCESS ) ) ;
185
- sync:: par_for_each_in ( many_seeds. seeds , |seed| {
186
+ let num_failed = sync:: IntoDynSyncSend ( AtomicU32 :: new ( 0 ) ) ;
187
+ sync:: par_for_each_in ( many_seeds. seeds . clone ( ) , |seed| {
186
188
let mut config = config. clone ( ) ;
187
189
config. seed = Some ( seed. into ( ) ) ;
188
190
eprintln ! ( "Trying seed: {seed}" ) ;
@@ -196,8 +198,13 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
196
198
std:: process:: exit ( return_code) ;
197
199
}
198
200
exit_code. store ( return_code, Ordering :: Relaxed ) ;
201
+ num_failed. fetch_add ( 1 , Ordering :: Relaxed ) ;
199
202
}
200
203
} ) ;
204
+ let num_failed = num_failed. 0 . into_inner ( ) ;
205
+ if num_failed > 0 {
206
+ eprintln ! ( "{num_failed}/{total} SEEDS FAILED" , total = many_seeds. seeds. count( ) ) ;
207
+ }
201
208
std:: process:: exit ( exit_code. 0 . into_inner ( ) ) ;
202
209
} else {
203
210
let return_code = miri:: eval_entry ( tcx, entry_def_id, entry_type, config)
@@ -370,13 +377,10 @@ fn init_late_loggers(early_dcx: &EarlyDiagCtxt, tcx: TyCtxt<'_>) {
370
377
fn run_compiler_and_exit (
371
378
args : & [ String ] ,
372
379
callbacks : & mut ( dyn rustc_driver:: Callbacks + Send ) ,
373
- using_internal_features : Arc < std:: sync:: atomic:: AtomicBool > ,
374
380
) -> ! {
375
381
// Invoke compiler, and handle return code.
376
382
let exit_code = rustc_driver:: catch_with_exit_code ( move || {
377
- rustc_driver:: RunCompiler :: new ( args, callbacks)
378
- . set_using_internal_features ( using_internal_features)
379
- . run ( ) ;
383
+ rustc_driver:: run_compiler ( args, callbacks) ;
380
384
Ok ( ( ) )
381
385
} ) ;
382
386
std:: process:: exit ( exit_code)
@@ -467,8 +471,7 @@ fn main() {
467
471
// If the environment asks us to actually be rustc, then do that.
468
472
if let Some ( crate_kind) = env:: var_os ( "MIRI_BE_RUSTC" ) {
469
473
// Earliest rustc setup.
470
- let using_internal_features =
471
- rustc_driver:: install_ice_hook ( rustc_driver:: DEFAULT_BUG_REPORT_URL , |_| ( ) ) ;
474
+ rustc_driver:: install_ice_hook ( rustc_driver:: DEFAULT_BUG_REPORT_URL , |_| ( ) ) ;
472
475
rustc_driver:: init_rustc_env_logger ( & early_dcx) ;
473
476
474
477
let target_crate = if crate_kind == "target" {
@@ -492,16 +495,11 @@ fn main() {
492
495
}
493
496
494
497
// We cannot use `rustc_driver::main` as we want it to use `args` as the CLI arguments.
495
- run_compiler_and_exit (
496
- & args,
497
- & mut MiriBeRustCompilerCalls { target_crate } ,
498
- using_internal_features,
499
- )
498
+ run_compiler_and_exit ( & args, & mut MiriBeRustCompilerCalls { target_crate } )
500
499
}
501
500
502
501
// Add an ICE bug report hook.
503
- let using_internal_features =
504
- rustc_driver:: install_ice_hook ( "https://github.com/rust-lang/miri/issues/new" , |_| ( ) ) ;
502
+ rustc_driver:: install_ice_hook ( "https://github.com/rust-lang/miri/issues/new" , |_| ( ) ) ;
505
503
506
504
// Init loggers the Miri way.
507
505
init_early_loggers ( & early_dcx) ;
@@ -725,19 +723,14 @@ fn main() {
725
723
726
724
// Ensure we have parallelism for many-seeds mode.
727
725
if many_seeds. is_some ( ) && !rustc_args. iter ( ) . any ( |arg| arg. starts_with ( "-Zthreads=" ) ) {
728
- rustc_args. push ( format ! (
729
- "-Zthreads={}" ,
730
- std:: thread:: available_parallelism( ) . map_or( 1 , |n| n. get( ) )
731
- ) ) ;
726
+ // Clamp to 8 threads; things get a lot less efficient beyond that due to lock contention.
727
+ let threads = std:: thread:: available_parallelism ( ) . map_or ( 1 , |n| n. get ( ) ) . min ( 8 ) ;
728
+ rustc_args. push ( format ! ( "-Zthreads={threads}" ) ) ;
732
729
}
733
730
let many_seeds =
734
731
many_seeds. map ( |seeds| ManySeedsConfig { seeds, keep_going : many_seeds_keep_going } ) ;
735
732
736
733
debug ! ( "rustc arguments: {:?}" , rustc_args) ;
737
734
debug ! ( "crate arguments: {:?}" , miri_config. args) ;
738
- run_compiler_and_exit (
739
- & rustc_args,
740
- & mut MiriCompilerCalls :: new ( miri_config, many_seeds) ,
741
- using_internal_features,
742
- )
735
+ run_compiler_and_exit ( & rustc_args, & mut MiriCompilerCalls :: new ( miri_config, many_seeds) )
743
736
}
0 commit comments