@@ -36,7 +36,7 @@ pub fn resolve_std<'cfg>(
36
36
requested_target : CompileKind ,
37
37
crates : & [ String ] ,
38
38
) -> CargoResult < ( PackageSet < ' cfg > , Resolve , ResolvedFeatures ) > {
39
- let src_path = detect_sysroot_src_path ( ws ) ?;
39
+ let src_path = detect_sysroot_src_path ( target_data ) ?;
40
40
let to_patch = [
41
41
"rustc-std-workspace-core" ,
42
42
"rustc-std-workspace-alloc" ,
@@ -163,21 +163,19 @@ pub fn generate_std_roots<'a>(
163
163
. collect :: < CargoResult < Vec < _ > > > ( )
164
164
}
165
165
166
- fn detect_sysroot_src_path ( ws : & Workspace < ' _ > ) -> CargoResult < PathBuf > {
166
+ fn detect_sysroot_src_path ( target_data : & RustcTargetData ) -> CargoResult < PathBuf > {
167
167
if let Some ( s) = env:: var_os ( "__CARGO_TESTS_ONLY_SRC_ROOT" ) {
168
168
return Ok ( s. into ( ) ) ;
169
169
}
170
170
171
171
// NOTE: This is temporary until we figure out how to acquire the source.
172
- // If we decide to keep the sysroot probe, then BuildConfig will need to
173
- // be restructured so that the TargetInfo is created earlier and passed
174
- // in, so we don't have this extra call to rustc.
175
- let rustc = ws. config ( ) . load_global_rustc ( Some ( ws) ) ?;
176
- let output = rustc. process ( ) . arg ( "--print=sysroot" ) . exec_with_output ( ) ?;
177
- let s = String :: from_utf8 ( output. stdout )
178
- . map_err ( |e| anyhow:: format_err!( "rustc didn't return utf8 output: {:?}" , e) ) ?;
179
- let sysroot = PathBuf :: from ( s. trim ( ) ) ;
180
- let src_path = sysroot. join ( "lib" ) . join ( "rustlib" ) . join ( "src" ) . join ( "rust" ) ;
172
+ let src_path = target_data
173
+ . info ( CompileKind :: Host )
174
+ . sysroot
175
+ . join ( "lib" )
176
+ . join ( "rustlib" )
177
+ . join ( "src" )
178
+ . join ( "rust" ) ;
181
179
let lock = src_path. join ( "Cargo.lock" ) ;
182
180
if !lock. exists ( ) {
183
181
anyhow:: bail!(
0 commit comments