cross-rs / cross

“Zero setup” cross compilation and “cross testing” of Rust crates
Apache License 2.0
6.27k stars 357 forks source link

Improve error message on CI when target = MSVC or Darwin and target = host #1447

Open Emilgardis opened 4 months ago

Emilgardis commented 4 months ago

With https://github.com/cross-rs/cross/pull/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 commented 4 months ago

The way to solve this would probably be to add a check in the error path here: https://github.com/cross-rs/cross/blob/f272b470f999c7e588fbcf5c0a159d14b5485ff4/src/lib.rs#L775-L787

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

yamafaktory commented 4 months ago

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

fujiapple852 commented 3 months ago

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 commented 3 months ago

@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