Skip to content

Commit ea84bf2

Browse files
authored
Unrolled build for rust-lang#128283
Rollup merge of rust-lang#128283 - lolbinarycat:bootstrap-custom-target, r=albertlarsan68 bootstrap: fix bug preventing the use of custom targets the bug was caused by two factors: 1. only checking the RUST_TARGET_PATH form, not the full filepath form 2. indirectly trying to use the Debug presentation to get the file path
2 parents bbf60c8 + 6264d2e commit ea84bf2

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Diff for: src/bootstrap/src/core/config/config.rs

+5
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,11 @@ impl TargetSelection {
512512
pub fn is_windows(&self) -> bool {
513513
self.contains("windows")
514514
}
515+
516+
/// Path to the file defining the custom target, if any.
517+
pub fn filepath(&self) -> Option<&Path> {
518+
self.file.as_ref().map(Path::new)
519+
}
515520
}
516521

517522
impl fmt::Display for TargetSelection {

Diff for: src/bootstrap/src/core/sanity.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,9 @@ than building it.
260260

261261
if !has_target {
262262
// This might also be a custom target, so check the target file that could have been specified by the user.
263-
if let Some(custom_target_path) = env::var_os("RUST_TARGET_PATH") {
263+
if target.filepath().is_some_and(|p| p.exists()) {
264+
has_target = true;
265+
} else if let Some(custom_target_path) = env::var_os("RUST_TARGET_PATH") {
264266
let mut target_filename = OsString::from(&target_str);
265267
// Target filename ends with `.json`.
266268
target_filename.push(".json");
@@ -275,8 +277,12 @@ than building it.
275277

276278
if !has_target {
277279
panic!(
278-
"No such target exists in the target list,
279-
specify a correct location of the JSON specification file for custom targets!"
280+
"No such target exists in the target list,\n\
281+
make sure to correctly specify the location \
282+
of the JSON specification file \
283+
for custom targets!\n\
284+
Use BOOTSTRAP_SKIP_TARGET_SANITY=1 to \
285+
bypass this check."
280286
);
281287
}
282288
}

0 commit comments

Comments
 (0)