link
다양한 플래폼 테스트 하는 방법(굳이 다른 환경에서 테스트 안해도 된다)
Github Actions 설정(LinuxOS, macOS, windowsOS 3가지 테스트 설명으로 자동화
우선 타겟으로 테스트하고 실제로 OS들어가서 해보면 대충 99프로 이상 잘 되는듯
Install|🔝|
- Install
# Install(LinuxOS)
rustup target add x86_64-unknown-linux-gnu
rustup target add aarch64-unknown-linux-gnu
rustup target add aarch64-unknown-linux-musl
rustup target add x86_64-unknown-linux-musl
# macOS(Install)
rustup target add aarch64-apple-darwin
rustup target add x86_64-apple-darwin
# WindowsOS (Install)
rustup target add x86_64-pc-windows-gnu
rustup target add aarch64-pc-windows-gnu
rustup target add x86_64-pc-windows-msvc # Intel/AMD Windows
rustup target add aarch64-pc-windows-msvc # ARM64 Windowstarget test
# test linuxOS
cargo build --release --target aarch64-unknown-linux-gnu
cargo build --release --target x86_64-unknown-linux-gnu
cargo build --release --target x86_64-unknown-linux-musl
cargo build --release --target aarch64-unknown-linux-musl
# test(macOS)
cargo build --release --target aarch64-apple-darwin
cargo build --release --target x86_64-apple-darwin
# WindowsOS test
cargo build --release --target x86_64-pc-windows-gnu
cargo build --release --target aarch64-pc-windows-gnu
cargo build --release --target x86_64-pc-windows-msvc # Intel/AMD Windows
cargo build --release --target aarch64-pc-windows-msvc # ARM64 WindowsYes. The important distinction is that your command:|🔝|
cargo check --release --target x86_64-pc-windows-gnudoes not actually run Windows code. It checks whether your Rust project can compile for the Windows GNU target from Linux.
For macOS, the situation is different because Apple targets require Apple’s SDK/toolchain components, and you generally cannot natively cross-compile to macOS from Linux using the normal Rust toolchain.
1. Check the macOS target
The Rust target names are typically:
x86_64-apple-darwin # Intel macOS
aarch64-apple-darwin # Apple Silicon macOSYou can see available targets with:
rustup target listYou might see:
aarch64-apple-darwin
x86_64-apple-darwinYou can add them:
rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwinHowever, on Linux, adding the target alone is not enough to produce a usable macOS binary.
2. Why Windows is easier
Your Windows example:
cargo check --release --target x86_64-pc-windows-gnuworks because the GNU Windows target can use a Linux-hosted cross-compilation toolchain.
Conceptually:
Linux
│
├── Rust compiler
│
└── x86_64-pc-windows-gnu
│
▼
Windows binaryFor macOS:
Linux
│
├── Rust compiler
│
└── aarch64-apple-darwin
│
▼
macOS binaryThe problem is the Apple SDK/linker ecosystem. Apple does not provide the macOS SDK as a normal Linux-native toolchain.
3. If you only want cargo check
If your project doesn’t require linking native libraries, you can sometimes do:
cargo check --release --target aarch64-apple-darwinor:
cargo check --release --target x86_64-apple-darwinBut cargo check is not a complete test of producing a runnable macOS executable.
For a project such as your Rust FFmpeg implementation, native dependencies may make this distinction particularly important.
4. To actually test on macOS|🔝|
The most reliable approach is to run the tests on an actual macOS environment.
For example, with GitHub Actions you can have Linux development plus macOS CI:
jobs:
test:
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo test --releaseThis gives you:
Ubuntu
│
└── cargo test
macOS
│
└── cargo test
Windows
│
└── cargo testThis is much closer to real platform testing than cross-compilation.
5. For your Rust project, I would use|🔝|
For local Linux development:
# Linux
cargo check --release
cargo test --releaseCross-check Windows:
cargo check --release --target x86_64-pc-windows-gnuAnd test macOS through CI:
GitHub Actions
├── Linux
│ └── cargo test --release
├── macOS
│ ├── cargo check --release
│ └── cargo test --release
└── Windows
├── cargo check --release
└── cargo test --releaseIn short|🔝|
| Goal | Linux command |
|---|---|
| Check Linux | cargo check --release |
| Test Linux | cargo test --release |
| Cross-check Windows | cargo check --release --target x86_64-pc-windows-gnu |
| Cross-check macOS | cargo check --release --target aarch64-apple-darwin* |
| Actually test macOS | Run cargo test on macOS |
- The macOS cross-target may require additional linker/SDK setup and isn’t equivalent to having a real macOS environment.
- If your goal is “I’m on Linux, but I want every
cargo testto automatically test Linux + Windows + Intel Mac + Apple Silicon Mac”, GitHub Actions is probably the cleanest setup.