Rust Cross Compile - 1 Machine → 6 Targets (Linux/Mac/Windows Arm & x86)
Автор: Jeremy Chone
Загружено: 19 апр. 2025 г.
Просмотров: 2 895 просмотров
Here, I'll show you how to cross-compile a Rust Programming binary to six platforms—Linux, Mac, and Windows, all on x86 and ARM—with just ONE machine.
Correction - Big thanks to @doudeman's comment below, the Windows target should be x86_64-pc-windows-msvc and NOT the *i686...*, which is the old 32bit version (see below for the corrected Windows x86 instructions).
Here is the gist with all commands (with the windows x86_64 correction): https://gist.github.com/jeremychone/5...
The machine is an Apple Silicon, MacBook Pro Mx or Studio.
00:00 - Intro
00:12 - Mac Arm (simplest)
01:51 - Mac x86
02:31 - Linux Arm
04:57 - Linux x86
06:04 - Windowx Arm
10:33 - Windows x86
This is using:
Mac/Rust host for both Arm and x86
Docker with Arm and x86 for the Linux binaries
And Parallels with Windows 11 Arm for both Arm and Windows x86 .exe
== Correction for the Windows x86 target
As noted above, use the x86_64-pc-windows-msvc for the x86 64 bit target. The i686... is for old 32 bits target (rarely what we need)
FROM WINDOWS
rustup target add x86_64-pc-windows-msvc
cargo build --release --target x86_64-pc-windows-msvc
FROM MAC HOST
COPYFILE_DISABLE=1 tar -czpf dist/x86_64-pc-windows-msvc/aip.tar.gz -C dist/x86_64-pc-windows-msvc aip.exe
rm dist/x86_64-pc-windows-msvc/aip.exe
I fixed my CI, all work nicely, big thanks @doudeman for the correction.
== Jeremy Chone:
Join this channel - / @jeremychone
Member Only Videos - • Members-only videos
AIPACK: https://aipack.ai (Built with Rust)
AI Pack News: https://news.aipack.ai/archive
pro coder AI Pack: • AI Production Coding - Pro/Coder AI P...
Twitter - / jeremychone
Discord general-rust - / discord
Discord genai & aipack - / discord
AIPACK - https://aipack.ai (and then 'aip install jc@coder')
Rust10x - https://rust10x.com - Rust resources for production coding.

Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: