Skip to content

Commit

Permalink
feat: add changes from this pr: rust-lang/rust#128283
Browse files Browse the repository at this point in the history
  • Loading branch information
ratankaliani committed Sep 19, 2024
1 parent 974d720 commit 43b6ef1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
11 changes: 10 additions & 1 deletion src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,11 @@ impl TargetSelection {
pub fn is_windows(&self) -> bool {
self.contains("windows")
}

/// Path to the file defining the custom target, if any.
pub fn filepath(&self) -> Option<&Path> {
self.file.as_ref().map(Path::new)
}
}

impl fmt::Display for TargetSelection {
Expand Down Expand Up @@ -2388,7 +2393,11 @@ impl Config {
.get(&target)
.and_then(|t| t.split_debuginfo)
.or_else(|| {
if self.build == target { self.rust_split_debuginfo_for_build_triple } else { None }
if self.build == target {
self.rust_split_debuginfo_for_build_triple
} else {
None
}
})
.unwrap_or_else(|| SplitDebuginfo::default_for_platform(target))
}
Expand Down
12 changes: 9 additions & 3 deletions src/bootstrap/src/core/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ than building it.

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

if !has_target {
panic!(
"No such target exists in the target list,
specify a correct location of the JSON specification file for custom targets!"
"No such target exists in the target list,\n\
make sure to correctly specify the location \
of the JSON specification file \
for custom targets!\n\
Use BOOTSTRAP_SKIP_TARGET_SANITY=1 to \
bypass this check."
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/check-cfg/well-known-values.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
LL | target_vendor = "_UNEXPECTED_VALUE",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_vendor` are: `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `nintendo`, `nvidia`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs`
= note: expected values for `target_vendor` are: `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `nintendo`, `nvidia`, `pc`, `succinct`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
Expand Down

0 comments on commit 43b6ef1

Please sign in to comment.