Skip to content

Improve cross compiling support #158

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 3 commits into from
Oct 28, 2022
Merged

Improve cross compiling support #158

merged 3 commits into from
Oct 28, 2022

Conversation

messense
Copy link
Contributor

@messense messense commented Jul 26, 2022

This PR changes cmake-rs to fill out CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_PROCESSOR based CARGO_CFG_TARGET_OS and CARGO_CFG_TARGET_ARCH when cross compiling while CMAKE_TOOLCHAIN_FILE and CMAKE_SYSTEM_NAME isn't set by user.

It's tested on CI using cross.

Closes #75
Closes #80
Closes #151

@messense messense marked this pull request as ready for review July 26, 2022 12:10
src/lib.rs Outdated
}
} else if target.contains("solaris") {
if !self.defined("CMAKE_SYSTEM_NAME") {
self.define("CMAKE_SYSTEM_NAME", "SunOS");
Copy link
Contributor Author

@messense messense Jul 26, 2022

Choose a reason for hiding this comment

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

We can also address #151 by removing this if it's desirable.

cc @gco

Copy link

Choose a reason for hiding this comment

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

Yes, please!

Copy link
Member

@thomcc thomcc left a comment

Choose a reason for hiding this comment

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

This looks great. Thanks for improving the CI too.

@thomcc thomcc merged commit cfe11fc into rust-lang:master Oct 28, 2022
luser added a commit to luser/cmake-rs that referenced this pull request Jan 27, 2023
…Fixes rust-lang#173

In rust-lang#158, better support for using CMake's cross-compilation facilities was
added. This made the workaround added in rust-lang#110 for iOS not only unnecessary,
but actively harmful, in that it runs afoul of SDK validation checks in the
CMake iOS codepath.
thomcc added a commit that referenced this pull request Mar 23, 2023
* add an iOS cross-compile test to CI

* Fix zlib-ng compilation for iOS

* Revert #110 to fix iOS cross-compilation after #158. Fixes #173

In #158, better support for using CMake's cross-compilation facilities was
added. This made the workaround added in #110 for iOS not only unnecessary,
but actively harmful, in that it runs afoul of SDK validation checks in the
CMake iOS codepath.

* Use checkout@v3

Co-authored-by: Yuki Okushi <[email protected]>

---------

Co-authored-by: Thom Chiovoloni <[email protected]>
Co-authored-by: Yuki Okushi <[email protected]>
@jrose-signal
Copy link

jrose-signal commented May 11, 2023

I'm afraid this broke no-toolchain cross-compilation using Visual Studio, from an x86_64 Windows host to aarch64-pc-windows-msvc. Things are a bit clunky there in general (the existing support goes through platforms and does not set CMAKE_SYSTEM_PROCESSOR), but it was working in 1.48.0 (and I'm afraid we hadn't been testing with new crate versions, so we didn't discover this sooner).

(Specifically, the auto-search for CMAKE_C_COMPILER and CMAKE_CXX_COMPILER doesn't kick in, even though it works fine for a non-cross-compile MSVS generator build.)

@jrose-signal
Copy link

Workaround: set CMAKE_SYSTEM_NAME to an empty string, which counts as defined for this crate, but unset for CMake itself.

@jrose-signal
Copy link

jrose-signal commented May 31, 2023

Turns out this also broke cross-compiling to Mac Catalyst targets (*-apple-ios-macabi), because CMake doesn't like having CMAKE_SYSTEM_NAME set to "iOS" while compiling against a macOS sysroot. That should probably eventually be fixed in CMake itself, but for now setting CMAKE_SYSTEM_NAME back to "Darwin" does work, at least for simple libraries. I don't know if you want to put that in this crate, though.

EDIT (months later): here's CMake not deciding what to do about Catalyst, which isn't cmake-rs's fault.

madsmtm added a commit to madsmtm/rust that referenced this pull request Mar 22, 2025
To avoid a panic in cmake-rs that was introduced in:
rust-lang/cmake-rs#158
madsmtm added a commit to madsmtm/rust that referenced this pull request Mar 22, 2025
To avoid a panic in cmake-rs that was introduced in:
rust-lang/cmake-rs#158
madsmtm added a commit to madsmtm/rust that referenced this pull request Mar 22, 2025
To avoid a panic in cmake-rs that was introduced in:
rust-lang/cmake-rs#158
madsmtm added a commit to madsmtm/rust that referenced this pull request Mar 24, 2025
To avoid a panic in cmake-rs that was introduced in:
rust-lang/cmake-rs#158
kraj added a commit to YoeDistro/poky that referenced this pull request Apr 3, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

Signed-off-by: Khem Raj <[email protected]>
kraj added a commit to YoeDistro/poky that referenced this pull request Apr 3, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

Signed-off-by: Khem Raj <[email protected]>
brainhoard-github pushed a commit to distro-core-curated-mirrors/poky-contrib that referenced this pull request Apr 4, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

(From OE-Core rev: 9ea58340da8e1236ebc1011c2e9495bdc7669583)

Signed-off-by: Khem Raj <[email protected]>
Signed-off-by: Mathieu Dubois-Briand <[email protected]>
kraj added a commit to YoeDistro/poky that referenced this pull request Apr 4, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

Signed-off-by: Khem Raj <[email protected]>
kraj added a commit to YoeDistro/poky that referenced this pull request Apr 4, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

Signed-off-by: Khem Raj <[email protected]>
kraj added a commit to YoeDistro/poky that referenced this pull request Apr 4, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

Signed-off-by: Khem Raj <[email protected]>
brainhoard-github pushed a commit to distro-core-curated-mirrors/poky-contrib that referenced this pull request Apr 4, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

(From OE-Core rev: 9ea58340da8e1236ebc1011c2e9495bdc7669583)

Signed-off-by: Khem Raj <[email protected]>
Signed-off-by: Mathieu Dubois-Briand <[email protected]>
brainhoard-github pushed a commit to distro-core-curated-mirrors/poky-contrib that referenced this pull request Apr 5, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

(From OE-Core rev: 9ea58340da8e1236ebc1011c2e9495bdc7669583)

Signed-off-by: Khem Raj <[email protected]>
Signed-off-by: Mathieu Dubois-Briand <[email protected]>
kraj added a commit to YoeDistro/poky that referenced this pull request Apr 5, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

Signed-off-by: Khem Raj <[email protected]>
kraj added a commit to YoeDistro/poky that referenced this pull request Apr 5, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

Signed-off-by: Khem Raj <[email protected]>
brainhoard-github pushed a commit to distro-core-curated-mirrors/poky-contrib that referenced this pull request Apr 5, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

(From OE-Core rev: 9ea58340da8e1236ebc1011c2e9495bdc7669583)

Signed-off-by: Khem Raj <[email protected]>
Signed-off-by: Mathieu Dubois-Briand <[email protected]>
brainhoard-github pushed a commit to distro-core-curated-mirrors/poky-contrib that referenced this pull request Apr 6, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

(From OE-Core rev: d1e7af5bc3d9349f5266e8bca68aedd19cc83e4b)

Signed-off-by: Khem Raj <[email protected]>
Signed-off-by: Mathieu Dubois-Briand <[email protected]>
brainhoard-github pushed a commit to distro-core-curated-mirrors/poky-contrib that referenced this pull request Apr 6, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

(From OE-Core rev: d1e7af5bc3d9349f5266e8bca68aedd19cc83e4b)

Signed-off-by: Khem Raj <[email protected]>
Signed-off-by: Mathieu Dubois-Briand <[email protected]>
brainhoard-github pushed a commit to distro-core-curated-mirrors/poky-contrib that referenced this pull request Apr 7, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

(From OE-Core rev: d1e7af5bc3d9349f5266e8bca68aedd19cc83e4b)

Signed-off-by: Khem Raj <[email protected]>
Signed-off-by: Mathieu Dubois-Briand <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Apr 7, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

(From OE-Core rev: 48b012e0aeb5d92b934bb16465ba29c9cc6a667b)

Signed-off-by: Khem Raj <[email protected]>
Signed-off-by: Mathieu Dubois-Briand <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to openembedded/openembedded-core that referenced this pull request Apr 7, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

Signed-off-by: Khem Raj <[email protected]>
Signed-off-by: Mathieu Dubois-Briand <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
brainhoard-github pushed a commit to distro-core-curated-mirrors/poky-contrib that referenced this pull request Apr 7, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

(From OE-Core rev: 8f4c2346fe91d5c34cb10ba582a5735e0611fada)

Signed-off-by: Khem Raj <[email protected]>
Signed-off-by: Mathieu Dubois-Briand <[email protected]>
brainhoard-github pushed a commit to distro-core-curated-mirrors/poky-contrib that referenced this pull request Apr 8, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

(From OE-Core rev: 8f4c2346fe91d5c34cb10ba582a5735e0611fada)

Signed-off-by: Khem Raj <[email protected]>
Signed-off-by: Mathieu Dubois-Briand <[email protected]>
brainhoard-github pushed a commit to distro-core-curated-mirrors/poky-contrib that referenced this pull request Apr 8, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

(From OE-Core rev: 51e9f95fe847b19abba2fd62e7c632865592a5be)

Signed-off-by: Khem Raj <[email protected]>
Signed-off-by: Mathieu Dubois-Briand <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Apr 8, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

(From OE-Core rev: 60b4b0808a3b961917ed8abe16b9f7df2a311952)

Signed-off-by: Khem Raj <[email protected]>
Signed-off-by: Mathieu Dubois-Briand <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to openembedded/openembedded-core that referenced this pull request Apr 8, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

Signed-off-by: Khem Raj <[email protected]>
Signed-off-by: Mathieu Dubois-Briand <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Apr 8, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

(From OE-Core rev: 60b4b0808a3b961917ed8abe16b9f7df2a311952)

Signed-off-by: Khem Raj <[email protected]>
Signed-off-by: Mathieu Dubois-Briand <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
daregit pushed a commit to QuantumYocto/quantumyocto that referenced this pull request Apr 8, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

(From OE-Core rev: 60b4b0808a3b961917ed8abe16b9f7df2a311952)

Signed-off-by: Khem Raj <raj.khemgmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briandbootlin.com>
Signed-off-by: Richard Purdie <richard.purdielinuxfoundation.org>
daregit pushed a commit to daregit/yocto-combined that referenced this pull request Apr 8, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

(From OE-Core rev: 60b4b0808a3b961917ed8abe16b9f7df2a311952)

Signed-off-by: Khem Raj <raj.khemgmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briandbootlin.com>
Signed-off-by: Richard Purdie <richard.purdielinuxfoundation.org>
daregit pushed a commit to daregit/yocto-combined that referenced this pull request Apr 8, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

(From OE-Core rev: 60b4b0808a3b961917ed8abe16b9f7df2a311952)

Signed-off-by: Khem Raj <raj.khemgmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briandbootlin.com>
Signed-off-by: Richard Purdie <richard.purdielinuxfoundation.org>
brainhoard-github pushed a commit to distro-core-curated-mirrors/poky-contrib that referenced this pull request Apr 8, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

(From OE-Core rev: 60b4b0808a3b961917ed8abe16b9f7df2a311952)

Signed-off-by: Khem Raj <[email protected]>
Signed-off-by: Mathieu Dubois-Briand <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
Signed-off-by: Mathieu Dubois-Briand <[email protected]>
daregit pushed a commit to daregit/yocto-combined that referenced this pull request Apr 9, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

(From OE-Core rev: 60b4b0808a3b961917ed8abe16b9f7df2a311952)

Signed-off-by: Khem Raj <raj.khemgmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briandbootlin.com>
Signed-off-by: Richard Purdie <richard.purdielinuxfoundation.org>
daregit pushed a commit to daregit/yocto-combined that referenced this pull request Apr 9, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

(From OE-Core rev: 60b4b0808a3b961917ed8abe16b9f7df2a311952)

Signed-off-by: Khem Raj <raj.khemgmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briandbootlin.com>
Signed-off-by: Richard Purdie <richard.purdielinuxfoundation.org>
brainhoard-github pushed a commit to distro-core-curated-mirrors/meta-lts-mixins that referenced this pull request May 3, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

Signed-off-by: Khem Raj <[email protected]>
Signed-off-by: Mathieu Dubois-Briand <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
(adapted from oe-core commit 60b4b0808a3b961917ed8abe16b9f7df2a311952)
Signed-off-by: Scott Murray <[email protected]>
doanac pushed a commit to lmp-mirrors/meta-lts-mixins that referenced this pull request May 5, 2025
Drop patch to exclusively disable it in code
It seems to be fixed upstream [1]

[1] rust-lang/cmake-rs#158

Signed-off-by: Khem Raj <[email protected]>
Signed-off-by: Mathieu Dubois-Briand <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
(adapted from oe-core commit 60b4b0808a3b961917ed8abe16b9f7df2a311952)
Signed-off-by: Scott Murray <[email protected]>
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.

Don't set CMAKE_SYSTEM_NAME=SunOS (and probably others) Improve cross-compiling support Suggestion: Windows CI
4 participants