File tree 1 file changed +14
-5
lines changed
1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -1088,10 +1088,16 @@ impl Build {
1088
1088
self
1089
1089
}
1090
1090
1091
- /// Configures the target this configuration will be compiling for.
1091
+ /// Configures the `rustc` target this configuration will be compiling
1092
+ /// for.
1092
1093
///
1093
- /// This option is automatically scraped from the `TARGET` environment
1094
- /// variable by build scripts, so it's not required to call this function.
1094
+ /// This will fail if using a target not in a pre-compiled list taken from
1095
+ /// `rustc +nightly --print target-list`. The list will be updated
1096
+ /// periodically.
1097
+ ///
1098
+ /// You should avoid setting this in build scripts, target information
1099
+ /// will instead be retrieved from the environment variables `TARGET` and
1100
+ /// `CARGO_CFG_TARGET_*` that Cargo sets.
1095
1101
///
1096
1102
/// # Example
1097
1103
///
@@ -3411,8 +3417,11 @@ impl Build {
3411
3417
3412
3418
fn get_target ( & self ) -> Result < TargetInfo < ' _ > , Error > {
3413
3419
match & self . target {
3414
- Some ( t) => t. parse ( ) ,
3415
- None => self
3420
+ Some ( t) if Some ( & * * t) != self . getenv_unwrap_str ( "TARGET" ) . ok ( ) . as_deref ( ) => t. parse ( ) ,
3421
+ // Fetch target information from environment if not set, or if the
3422
+ // target was the same as the TARGET environment variable, in
3423
+ // case the user did `build.target(&env::var("TARGET").unwrap())`.
3424
+ _ => self
3416
3425
. build_cache
3417
3426
. target_info_parser
3418
3427
. parse_from_cargo_environment_variables ( ) ,
You can’t perform that action at this time.
0 commit comments