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 error message on CI when target = MSVC or Darwin and target = host #1447

Open
Emilgardis opened this issue Feb 16, 2024 · 4 comments

Comments

@Emilgardis
Copy link
Member

Emilgardis commented Feb 16, 2024

With #661, we now error on warnings in CI.

[cross] warning: `cross` does not provide a Docker image for target x86_64-apple-darwin, specify a custom image in `Cross.toml`.
[cross] error: Errors encountered before cross compilation, aborting.
[cross] note: Disable this with `CROSS_NO_WARNINGS=0`

To clear up confusion, we could suggest a fix that just running cargo could work, we can also point to https://github.com/cross-rs/cross-toolchains.

See discussion

@Emilgardis
Copy link
Member Author

Emilgardis commented Feb 16, 2024

The way to solve this would probably be to add a check in the error path here:

cross/src/lib.rs

Lines 775 to 787 in f272b47

let image = match docker::get_image(&config, &target, uses_zig) {
Ok(i) => i,
Err(docker::GetImageError::NoCompatibleImages(..))
if config.dockerfile(&target)?.is_some() =>
{
"scratch".into()
}
Err(err) => {
msg_info.warn(err)?;
return Ok(None);
}
};

where we check if the target is x86_64-pc-windows-msvc, x86_64-apple-darwin or aarch64-apple-darwin (probably some more targets we could add here), and if it is, emit a info message suggesting if the host is similar to the target, just running cargo ... could work. Lastly suggest cross-toolchains

@Emilgardis Emilgardis transferred this issue from cross-rs/cross-toolchains Feb 16, 2024
@yamafaktory
Copy link

I hit that issue today and got confused indeed :). Many thanks @Emilgardis for the swift help in the matrix channel!

@fujiapple852
Copy link

I hit the same thing. Setting CROSS_NO_WARNINGS=0 worked as a quick fix but of course not ideal to ignore warnings in general.

Rather than simply improving the error message, perhaps it would be useful to have an explicit option to allow failing back automatically in such cases? The rationale here is that it is convenient when doing matrix builds which include a variety of targets, some of which require cross and some which do not. Of course it is possible to enumerate which is which in the matrix and avoid the issue, so this is simply for convenience.

@Emilgardis
Copy link
Member Author

Emilgardis commented Mar 31, 2024

@fujiapple852 an automatic fallback would be the opposite of the intended behaviour. Perhaps a way to say "i dont care about cross not supporting this target, but I do care about other warnings in ci" is needed.

I dont like this approach though, the reason for doing this was that cross shouldnt be used in those cases, and some people were/are under the false impression that cross does work for these targets, when it actually doesnt

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

No branches or pull requests

3 participants