Videos
Can someone explain to me like I'm an idiot what exactly does
cross build
do beneath the hood?
Let's say I'm using 2 docker images:
-
builder:rust1.66 -
builder:rust1.67
each with the correspoding Rust toolchain installed
Locally I've got rust 1.68
Cross.toml at the root of my project contains the following
[target.x86_64-unknown-linux-gnu] image = "builder:rust1.66"
When I run
cross build --target=x86_64-unknown-linux-gnu
I would expect that the project gets built with Rust 1.66
However, it gets built with local toolchain
cross -v + cargo metadata --format-version 1 + rustc --print sysroot + rustup toolchain list + rustup target list --toolchain 1.68.0-x86_64-unknown-linux-gnu + rustup component list --toolchain 1.68.0-x86_64-unknown-linux-gnu [cross] note: Falling back to `cargo` on the host.
Even if I change Cross.toml to contain
[target.x86_64-unknown-linux-gnu] image = "builder:rust1.67"
the same thing happens.
-
Why does
crossuse my local toolchain? -
Why does it not reflect changes in the builder image?
It is fairly typical for me to cross-compile from my MacOS development machine to my embedded targets of STM32, RP2040, and the Raspberry Pi platforms. To support this I have in the past struggled to install (although not toooo hard to do) to install all of the necessary tools to cross-compile directly on those targets. Last night, for the first time, I tried the rust native "Cross" tool. Oh My Gosh! I am never going back sans some currently unforeseen limitation on this. The ease of using this tool and it simply working should not be ignored.
Get back to building and innovating instead of fighting the tool chain!
Ok, for some, that may be too much to read, so...
TLDR; Use the rust Cross tool to perform cross-compiling for different targets! ;)
Hello, Rustaceans!
Like many of you, I've faced challenges in cross-compiling Rust from macOS to MSVC. The more popular crates such as "cross" have proven ineffective in my pursuit, leaving me to explore other avenues.
Today, I am excited to introduce a real game-changer - the [cargo-xwin](https://github.com/rust-cross/cargo-xwin) crate! After countless trials and errors, cargo-xwin was the only one that truly met my needs.
Why is this crate a standout? It works smoothly and effortlessly, proving itself as a true diamond in the rough. I've been running it on a Macbook M1 with macOS v13, and the performance has been seamless, making it a breeze to cross compile my Rust code to MSVC.
What sets cargo-xwin apart is its solid performance and effectiveness. While this might just be my personal experience, I strongly encourage anyone grappling with the same cross-compiling issues to give this crate a try. Your experience may vary, but it just might save you the same headache it saved me.
For anyone interested in testing out the crate, you can find it here: [cargo-xwin](https://github.com/rust-cross/cargo-xwin)
In conclusion, if you've been wrestling with the cross-compiling conundrum like I was, I truly believe cargo-xwin could be the solution you're searching for. Give it a try, and let's open a dialogue about our experiences with it!
Happy coding, everyone!
(Note: I am not affiliated with the creators of cargo-xwin - just a satisfied user sharing a valuable find.)