@@ -279,6 +279,15 @@ pub struct Config {
279
279
/// [`Self::rustc_path`].
280
280
pub stage0_rustc_path : Option < Utf8PathBuf > ,
281
281
282
+ /// Path to the stage 1 or higher `rustc` used to obtain target information via
283
+ /// `--print=all-target-specs-json` and similar queries.
284
+ ///
285
+ /// Normally this is unset, because [`Self::rustc_path`] can be used instead.
286
+ /// But when running "stage 1" ui-fulldeps tests, `rustc_path` is a stage 0
287
+ /// compiler, whereas target specs must be obtained from a stage 1+ compiler
288
+ /// (in case the JSON format has changed since the last bootstrap bump).
289
+ pub query_rustc_path : Option < Utf8PathBuf > ,
290
+
282
291
/// Path to the `rustdoc`-under-test. Like [`Self::rustc_path`], this `rustdoc` is *staged*.
283
292
pub rustdoc_path : Option < Utf8PathBuf > ,
284
293
@@ -712,6 +721,7 @@ impl Config {
712
721
rustc_path : Utf8PathBuf :: default ( ) ,
713
722
cargo_path : Default :: default ( ) ,
714
723
stage0_rustc_path : Default :: default ( ) ,
724
+ query_rustc_path : Default :: default ( ) ,
715
725
rustdoc_path : Default :: default ( ) ,
716
726
coverage_dump_path : Default :: default ( ) ,
717
727
python : Default :: default ( ) ,
@@ -917,7 +927,7 @@ pub struct TargetCfgs {
917
927
918
928
impl TargetCfgs {
919
929
fn new ( config : & Config ) -> TargetCfgs {
920
- let mut targets: HashMap < String , TargetCfg > = serde_json:: from_str ( & rustc_output (
930
+ let mut targets: HashMap < String , TargetCfg > = serde_json:: from_str ( & query_rustc_output (
921
931
config,
922
932
& [ "--print=all-target-specs-json" , "-Zunstable-options" ] ,
923
933
Default :: default ( ) ,
@@ -950,7 +960,7 @@ impl TargetCfgs {
950
960
if config. target . ends_with ( ".json" ) || !envs. is_empty ( ) {
951
961
targets. insert (
952
962
config. target . clone ( ) ,
953
- serde_json:: from_str ( & rustc_output (
963
+ serde_json:: from_str ( & query_rustc_output (
954
964
config,
955
965
& [
956
966
"--print=target-spec-json" ,
@@ -1009,10 +1019,13 @@ impl TargetCfgs {
1009
1019
// which are respected for `--print=cfg` but not for `--print=all-target-specs-json`. The
1010
1020
// code below extracts them from `--print=cfg`: make sure to only override fields that can
1011
1021
// actually be changed with `-C` flags.
1012
- for config in
1013
- rustc_output ( config, & [ "--print=cfg" , "--target" , & config. target ] , Default :: default ( ) )
1014
- . trim ( )
1015
- . lines ( )
1022
+ for config in query_rustc_output (
1023
+ config,
1024
+ & [ "--print=cfg" , "--target" , & config. target ] ,
1025
+ Default :: default ( ) ,
1026
+ )
1027
+ . trim ( )
1028
+ . lines ( )
1016
1029
{
1017
1030
let ( name, value) = config
1018
1031
. split_once ( "=\" " )
@@ -1113,7 +1126,7 @@ pub enum Endian {
1113
1126
}
1114
1127
1115
1128
fn builtin_cfg_names ( config : & Config ) -> HashSet < String > {
1116
- rustc_output (
1129
+ query_rustc_output (
1117
1130
config,
1118
1131
& [ "--print=check-cfg" , "-Zunstable-options" , "--check-cfg=cfg()" ] ,
1119
1132
Default :: default ( ) ,
@@ -1128,7 +1141,7 @@ pub const KNOWN_CRATE_TYPES: &[&str] =
1128
1141
& [ "bin" , "cdylib" , "dylib" , "lib" , "proc-macro" , "rlib" , "staticlib" ] ;
1129
1142
1130
1143
fn supported_crate_types ( config : & Config ) -> HashSet < String > {
1131
- let crate_types: HashSet < _ > = rustc_output (
1144
+ let crate_types: HashSet < _ > = query_rustc_output (
1132
1145
config,
1133
1146
& [ "--target" , & config. target , "--print=supported-crate-types" , "-Zunstable-options" ] ,
1134
1147
Default :: default ( ) ,
@@ -1149,8 +1162,10 @@ fn supported_crate_types(config: &Config) -> HashSet<String> {
1149
1162
crate_types
1150
1163
}
1151
1164
1152
- fn rustc_output ( config : & Config , args : & [ & str ] , envs : HashMap < String , String > ) -> String {
1153
- let mut command = Command :: new ( & config. rustc_path ) ;
1165
+ fn query_rustc_output ( config : & Config , args : & [ & str ] , envs : HashMap < String , String > ) -> String {
1166
+ let query_rustc_path = config. query_rustc_path . as_deref ( ) . unwrap_or ( & config. rustc_path ) ;
1167
+
1168
+ let mut command = Command :: new ( query_rustc_path) ;
1154
1169
add_dylib_path ( & mut command, iter:: once ( & config. compile_lib_path ) ) ;
1155
1170
command. args ( & config. target_rustcflags ) . args ( args) ;
1156
1171
command. env ( "RUSTC_BOOTSTRAP" , "1" ) ;
0 commit comments