File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -1088,10 +1088,16 @@ impl Build {
10881088 self
10891089 }
10901090
1091- /// Configures the target this configuration will be compiling for.
1091+ /// Configures the `rustc` target this configuration will be compiling
1092+ /// for.
10921093 ///
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.
10951101 ///
10961102 /// # Example
10971103 ///
@@ -3411,8 +3417,11 @@ impl Build {
34113417
34123418 fn get_target ( & self ) -> Result < TargetInfo < ' _ > , Error > {
34133419 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
34163425 . build_cache
34173426 . target_info_parser
34183427 . parse_from_cargo_environment_variables ( ) ,
You can’t perform that action at this time.
0 commit comments