skerkour / kerkour.com

(Ab)using technology for fun & profit. Programming, Hacking & Entrepreneurship @ https://kerkour.com
https://kerkour.com
Apache License 2.0
463 stars 63 forks source link

`cross` for cross-compiling Rust #2

Closed linuskmr closed 2 years ago

linuskmr commented 2 years ago

I came across your blog post "Reproducible cross-compilation for Rust (with Docker)" via This Week in Rust #410 and want to say that your Dockerfiles are really cool.

However, there is already a way to cross-compile Rust via Docker. The tool is called cross and is maintained by the Rust Embedded devices Working Group.

So after installing cross via cargo install cross, you can compile to:

Windows:

cargo build --target x86_64-pc-windows-gnu

aarch64 / ARMv8:

cargo build --target aarch64-unknown-linux-gnu

ARMv7:

cargo build --target armv7-unknown-linux-gnueabihf

As said, your Dockerfiles are really awesome and doing something by yourself is always a worthwhile experience, however I just want to point out to you that there is already a way to cross-compile.

sylvain101010 commented 2 years ago

Thank you very much!

I knew cross but I missed the support for windows, which was, in my case, the most important (with aarch64).

I've updated the post to redirect people to it :)