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

Fix non-MSVC builds on Windows and cross-compilation in general #155

Merged
merged 1 commit into from
Jun 27, 2021

Conversation

ratijas
Copy link
Collaborator

@ratijas ratijas commented Jun 27, 2021

Simple cfg!(target_* = "...") doesn't work in build scripts the way it
does in crate's code, because build scripts are being compiled for the
toolchain's target triple -- not the default-host nor the cargo's
eventual target. Instead, such configuration should be loaded from
provided environment variables at run-time.

While initially trying to fix linkage issues for Windows + MinGW target
(first reported by @stuartZhang in #150), I came to realize in the
process that cfg!(target_os = ...), although being used only for OS X
at this moment, is likely screwed up in the same way (except, who would
ever cross-compile to or from Mac, and why?)

https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts

Fixes #154


My life priorities are seriously questionable, and it almost makes me wonder why did I choose this job in the first place. Now to get some well-deserved rest...

Simple cfg!(target_* = "...") doesn't work in build scripts the way it
does in crate's code, because build scripts are being compiled for the
toolchain's target triple -- not the default-host nor the cargo's
eventual target. Instead, such configuration should be loaded from
provided environment variables at run-time.

While initially trying to fix linkage issues for Windows + MinGW target
(first reported by @stuartZhang in #150), I came to realize in the
process that cfg!(target_os = ...), although being used only for OS X
at this moment, is likely screwed up in the same way (except, who would
ever cross-compile to or from Mac, and why?)

https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts

Fixes #154
@ratijas ratijas requested a review from ogoffart June 27, 2021 02:40
Copy link
Member

@ogoffart ogoffart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks

@ogoffart ogoffart merged commit 3ebdca9 into master Jun 27, 2021
@ratijas ratijas deleted the windows-msvc branch June 27, 2021 17:42
@ratijas ratijas added A-cross Area: Cross compilation O-macos Operating system: macOS O-windows-gnu Toolchain: GNU, Operating system: Windows O-windows-msvc Toolchain: MSVC, Operating system: Windows C-bug Category: This is a bug. I-crash Issue: compiler or runtime crashes labels Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cross Area: Cross compilation C-bug Category: This is a bug. I-crash Issue: compiler or runtime crashes O-macos Operating system: macOS O-windows-gnu Toolchain: GNU, Operating system: Windows O-windows-msvc Toolchain: MSVC, Operating system: Windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

qttypes: Support C++ toolchains on Windows other than MSVC
2 participants