Fix cross-compilation of Windows surrogate binary on Linux #1045
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
CARGO_CFG_TARGET_OSinstead of#[cfg(target_os)]. This ensures the Windows-specific surrogate build logic runs correctly when cross-compiling from a Linux host.TARGETtriple to the innercargo buildcommand so the surrogate binary is compiled for the correct target architecture.output()tostatus()for the inner build command. This ensures build errors are visible in the terminal and causes the main build to fail correctly if the surrogate build fails.After this pr, commands like
cargo clippy --target x86_64-pc-windows-gnucan be ran from a linux host without erroring out.The reason for doing this is that it is useful to be able to compile for windows on a linux host, for example to spot clippy issues without having to push to CI or try compiling on a different host machine. At least personally I often think I fixed all clippy errors, then CI spots some new ones when compiling for windows, and I'll have to go back and forth between machines