-
Notifications
You must be signed in to change notification settings - Fork 110
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
Improve default_target to respect current toolchain and config #365
base: main
Are you sure you want to change the base?
Conversation
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.
Can you report the timings for cargo clean && time cargo build
on main
and on this feature
branch?
if targets.len() > 1 { | ||
// Config can contain multiple targets, but we don't support it: https://doc.rust-lang.org/cargo/reference/config.html#buildtarget | ||
panic!("multi-target build is not supported: {targets:?}"); | ||
} | ||
targets | ||
.pop() | ||
// Get the host triple if the target is not specified in config. | ||
.unwrap_or_else(|| config.host_triple().unwrap().to_owned()) |
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 think this would be cleaner as match targets.len() { ... }
.
let mut targets = config.build_target_for_cli(None::<&str>).unwrap(); | ||
if targets.len() > 1 { | ||
// Config can contain multiple targets, but we don't support it: https://doc.rust-lang.org/cargo/reference/config.html#buildtarget | ||
panic!("multi-target build is not supported: {targets:?}"); |
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.
Let's return a result from this function and properly propagate errors rather than panicking here.
Rough test of build time:
|
Fixes #355
See #355 (comment) and #355 (comment) for details.
This PR uses the latter approach, which is more accurate. However, I have also implemented the former approach in another branch and can update the PR to use it if needed.