@@ -29,11 +29,12 @@ use std::num::NonZero;
2929use std:: ops:: Range ;
3030use std:: path:: PathBuf ;
3131use 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 } ;
3434
3535use miri:: {
36- BacktraceStyle , BorrowTrackerMethod , MiriConfig , ProvenanceMode , RetagFields , ValidationMode ,
36+ BacktraceStyle , BorrowTrackerMethod , MiriConfig , MiriEntryFnType , ProvenanceMode , RetagFields ,
37+ ValidationMode ,
3738} ;
3839use rustc_abi:: ExternAbi ;
3940use rustc_data_structures:: sync;
@@ -51,7 +52,7 @@ use rustc_middle::query::LocalCrate;
5152use rustc_middle:: traits:: { ObligationCause , ObligationCauseCode } ;
5253use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
5354use rustc_middle:: util:: Providers ;
54- use rustc_session:: config:: { CrateType , EntryFnType , ErrorOutputType , OptLevel } ;
55+ use rustc_session:: config:: { CrateType , ErrorOutputType , OptLevel } ;
5556use rustc_session:: search_paths:: PathKind ;
5657use rustc_session:: { CtfeBacktrace , EarlyDiagCtxt } ;
5758use rustc_span:: def_id:: DefId ;
@@ -73,9 +74,9 @@ impl MiriCompilerCalls {
7374 }
7475}
7576
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 ) ) ;
7980 }
8081 // Look for a symbol in the local crate named `miri_start`, and treat that as the entry point.
8182 let sym = tcx. exported_symbols ( LOCAL_CRATE ) . iter ( ) . find_map ( |( sym, _) | {
@@ -102,7 +103,7 @@ fn entry_fn(tcx: TyCtxt<'_>) -> (DefId, EntryFnType) {
102103 . is_ok ( ) ;
103104
104105 if correct_func_sig {
105- ( * id, EntryFnType :: Start )
106+ ( * id, MiriEntryFnType :: MiriStart )
106107 } else {
107108 tcx. dcx ( ) . fatal (
108109 "`miri_start` must have the following signature:\n \
@@ -182,7 +183,8 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
182183 if let Some ( many_seeds) = self . many_seeds . take ( ) {
183184 assert ! ( config. seed. is_none( ) ) ;
184185 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| {
186188 let mut config = config. clone ( ) ;
187189 config. seed = Some ( seed. into ( ) ) ;
188190 eprintln ! ( "Trying seed: {seed}" ) ;
@@ -196,8 +198,13 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
196198 std:: process:: exit ( return_code) ;
197199 }
198200 exit_code. store ( return_code, Ordering :: Relaxed ) ;
201+ num_failed. fetch_add ( 1 , Ordering :: Relaxed ) ;
199202 }
200203 } ) ;
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+ }
201208 std:: process:: exit ( exit_code. 0 . into_inner ( ) ) ;
202209 } else {
203210 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<'_>) {
370377fn run_compiler_and_exit (
371378 args : & [ String ] ,
372379 callbacks : & mut ( dyn rustc_driver:: Callbacks + Send ) ,
373- using_internal_features : Arc < std:: sync:: atomic:: AtomicBool > ,
374380) -> ! {
375381 // Invoke compiler, and handle return code.
376382 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) ;
380384 Ok ( ( ) )
381385 } ) ;
382386 std:: process:: exit ( exit_code)
@@ -467,8 +471,7 @@ fn main() {
467471 // If the environment asks us to actually be rustc, then do that.
468472 if let Some ( crate_kind) = env:: var_os ( "MIRI_BE_RUSTC" ) {
469473 // 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 , |_| ( ) ) ;
472475 rustc_driver:: init_rustc_env_logger ( & early_dcx) ;
473476
474477 let target_crate = if crate_kind == "target" {
@@ -492,16 +495,11 @@ fn main() {
492495 }
493496
494497 // 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 } )
500499 }
501500
502501 // 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" , |_| ( ) ) ;
505503
506504 // Init loggers the Miri way.
507505 init_early_loggers ( & early_dcx) ;
@@ -725,19 +723,14 @@ fn main() {
725723
726724 // Ensure we have parallelism for many-seeds mode.
727725 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}" ) ) ;
732729 }
733730 let many_seeds =
734731 many_seeds. map ( |seeds| ManySeedsConfig { seeds, keep_going : many_seeds_keep_going } ) ;
735732
736733 debug ! ( "rustc arguments: {:?}" , rustc_args) ;
737734 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) )
743736}
0 commit comments