-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Fallback to unknown vendor with vendored target triples #55368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -247,11 +247,19 @@ macro_rules! supported_targets { | |
// run-time that the parser works correctly | ||
t = Target::from_json(t.to_json())?; | ||
debug!("Got builtin target: {:?}", t); | ||
Ok(t) | ||
return Ok(t) | ||
}, | ||
)+ | ||
_ => Err(format!("Unable to find target: {}", target)) | ||
_ => {}, | ||
} | ||
let mut triple: Vec<&str> = target.splitn(3, '-').collect(); | ||
if triple.len() >= 3 { | ||
if triple[1] != "unknown" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would write this as: if triple.len() >= 3 && triple[1] != "unknown" { |
||
triple[1] = "unknown"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add an explanation of what |
||
return load_specific(&triple.join("-")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a test. Possibly as simple as: #[test]
fn test_load_specific() {
let cros_target = load_specific("x86_64-cros-linux-gnu").unwrap();
assert_eq!(cros_target.llvm_target, "x86_64-unknown-linux-gnu");
} |
||
} | ||
} | ||
Err(format!("Unable to find target: {}", target)) | ||
} | ||
|
||
pub fn get_targets() -> Box<dyn Iterator<Item=String>> { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this would break anyone currently successfully using a non-
unknown
vendor with their own JSON target file. The code before would use their JSON file. The new code would prefer the corresponding builtin target withunknown
vendor while ignoring their JSON file.rust/src/librustc_target/spec/mod.rs
Lines 1101 to 1122 in cc4999e
I think the fallback to
unknown
would be more appropriate if applies only after an exact match JSON file has not been found.