@@ -3,12 +3,11 @@ use std::sync::Arc;
33use std:: time:: { Duration , Instant } ;
44
55use rustc_feature:: UnstableFeatures ;
6+ use rustc_interface:: { Linker , create_and_enter_global_ctxt, passes, run_compiler} ;
67use rustc_interface:: interface:: Result as CompilerResult ;
7- use rustc_interface:: run_compiler;
88use rustc_lint_defs:: Level as LintLevel ;
99use rustc_session:: EarlyDiagCtxt ;
1010use rustc_session:: config:: { ExternEntry , ExternLocation , Externs , Input , OutputFilenames } ;
11- use rustc_session:: filesearch;
1211use rustc_session:: search_paths:: SearchPath ;
1312use rustc_session:: utils:: CanonicalizedPath ;
1413
@@ -37,10 +36,10 @@ pub fn run(config: &Config, analysis_pass: &AnalysisPassResult) -> CompilerResul
3736
3837 // The generated crate code relies on the `mutest_runtime` crate (and its dependencies), which must be loaded.
3938 let early_dcx = EarlyDiagCtxt :: new ( compiler_config. opts . error_format ) ;
40- let sysroot = filesearch :: materialize_sysroot ( compiler_config. opts . maybe_sysroot . clone ( ) ) ;
39+ let sysroot = & compiler_config. opts . sysroot ;
4140 let triple = & compiler_config. opts . target_triple ;
42- compiler_config. opts . search_paths . push ( SearchPath :: from_cli_opt ( & sysroot, & triple, & early_dcx, & format ! ( "crate={}" , config. mutest_search_path. display( ) ) , true ) ) ;
43- compiler_config. opts . search_paths . push ( SearchPath :: from_cli_opt ( & sysroot, & triple, & early_dcx, & format ! ( "dependency={}" , config. mutest_search_path. join( "deps" ) . display( ) ) , true ) ) ;
41+ compiler_config. opts . search_paths . push ( SearchPath :: from_cli_opt ( sysroot, & triple, & early_dcx, & format ! ( "crate={}" , config. mutest_search_path. display( ) ) , true ) ) ;
42+ compiler_config. opts . search_paths . push ( SearchPath :: from_cli_opt ( sysroot, & triple, & early_dcx, & format ! ( "dependency={}" , config. mutest_search_path. join( "deps" ) . display( ) ) , true ) ) ;
4443 // The externs (paths to dependencies) of the `mutest_runtime` crate are baked into it at compile time.
4544 // These must be propagated to any crate which depends on it.
4645 let mut externs = BTreeMap :: < String , ExternEntry > :: new ( ) ;
@@ -71,7 +70,7 @@ pub fn run(config: &Config, analysis_pass: &AnalysisPassResult) -> CompilerResul
7170 let existing_extern = externs. insert ( name. to_owned ( ) , ExternEntry {
7271 location : match path {
7372 Some ( path) => ExternLocation :: ExactPaths ( BTreeSet :: from ( [
74- CanonicalizedPath :: new ( & config. mutest_search_path . join ( path) ) ,
73+ CanonicalizedPath :: new ( config. mutest_search_path . join ( path) ) ,
7574 ] ) ) ,
7675 None => ExternLocation :: FoundInLibrarySearchDirectories ,
7776 } ,
@@ -96,24 +95,24 @@ pub fn run(config: &Config, analysis_pass: &AnalysisPassResult) -> CompilerResul
9695 let sess = & compiler. sess ;
9796 let codegen_backend = & * compiler. codegen_backend ;
9897
99- let ( linker, outputs) = compiler. enter ( |queries| {
100- queries. parse ( ) ?;
98+ let krate = passes:: parse ( sess) ;
10199
102- let outputs = queries . global_ctxt ( ) ? . enter ( |tcx| {
103- let _ = tcx. resolver_for_lowering ( ) ;
100+ let ( linker , outputs) = create_and_enter_global_ctxt ( compiler , krate , |tcx| {
101+ let _ = tcx. resolver_for_lowering ( ) ;
104102
105- let outputs = tcx . output_filenames ( ( ) ) ;
103+ passes :: write_dep_info ( tcx ) ;
106104
107- tcx . analysis ( ( ) ) ? ;
105+ passes :: write_interface ( tcx ) ;
108106
109- Ok ( outputs. clone ( ) )
110- } ) ?;
107+ tcx. ensure_ok ( ) . analysis ( ( ) ) ;
111108
112- let linker = queries. codegen_and_build_linker ( ) ?;
113- Ok ( ( linker, outputs) )
114- } ) ?;
109+ let outputs = tcx. output_filenames ( ( ) ) . clone ( ) ;
110+ let linker = Linker :: codegen_and_build_linker ( tcx, & * compiler. codegen_backend ) ;
115111
116- linker. link ( sess, codegen_backend) ?;
112+ ( linker, outputs)
113+ } ) ;
114+
115+ linker. link ( sess, codegen_backend) ;
117116
118117 Ok ( CompilationPassResult {
119118 duration : t_start. elapsed ( ) ,
0 commit comments