Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

taiki-e
Copy link

@taiki-e taiki-e commented Mar 2, 2024

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.

Copy link
Member

@fitzgen fitzgen left a 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?

Comment on lines +11 to +18
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())
Copy link
Member

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:?}");
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Distributed release files can only compile for musl
2 participants