Skip to content

Fix cross-compilation from unix to windows #923

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

Merged
merged 1 commit into from
Aug 29, 2020

Conversation

davidhewitt
Copy link
Member

I think build.rs functions slightly incorrectly for cross-compilation.

If I understand correctly, the build script is always compiled for the host platform, so we can't actually use #[cfg(target_os = "macos")] to set link args, for example. Instead we need to check the CARGO_CFG_TARGET_OS env var which is set during build script execution.

This might fix #666. I want to work with feedback from users before we merge this PR.

@Progdrasil
Copy link
Contributor

I did notice this issue when trying to implement the cross-compile feature in #1095. It does in fact seem to be the behavior, which would make sense since the build script would be unable to run on the host if it was compiled for a different target.

@davidhewitt
Copy link
Member Author

👍 agreed, I've decided I'm certain that this fix is correct. I'll rebase and finish this PR (and also add hard-coded windows cross-compile settings) after #1095 lands.

@davidhewitt davidhewitt marked this pull request as ready for review August 29, 2020 15:47
@davidhewitt
Copy link
Member Author

As discussed, I've rebased this PR and it should now be ready to merge.

@davidhewitt davidhewitt merged commit f816786 into PyO3:master Aug 29, 2020
@davidhewitt davidhewitt deleted the fix-cross-compile branch December 24, 2021 02:06
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.

Can't cross-compile rust lib from linux to windows
3 participants