Skip to content

Commit b455533

Browse files
committed
fix(ci): align local builds with release target-cpu, drop native flag
The .cargo/config.toml setting target-cpu=native created a dev/release divergence: local binaries used whatever instructions the dev's host CPU supported (AVX-512 on modern hardware), while published binaries are capped at x86-64-v3. CI tests inherited the native flag too, occasionally producing SIGILL on GH Actions runners whose CPUs reported features the container couldn't actually execute. Switch to a per-cfg setting: x86_64 dev builds use target-cpu=x86-64-v3 to match the released Linux/Windows binaries; aarch64 dev builds inherit rustc defaults to match the released macOS binary. Local dev experience now reflects what users actually run.
1 parent 07e560b commit b455533

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

.cargo/config.toml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
# Build for the local CPU architecture (enables AVX2/BMI2/FMA on Ryzen, etc.)
2-
# Note: this produces a non-portable binary optimized for the dev's CPU.
3-
# For distribution, override with --target or build without these flags.
4-
[build]
5-
rustflags = ["-C", "target-cpu=native"]
1+
# Local builds use the same target-cpu the CI release workflow uses, so the
2+
# dev binary has the same instruction set as the binaries users download.
3+
#
4+
# x86_64 (Linux / Windows / Intel Mac): target-cpu=x86-64-v3
5+
# AVX2 / BMI1 / BMI2 / FMA baseline, supported by every Intel/AMD CPU
6+
# from 2013 onward. Matches the published Linux/Windows release.
7+
# aarch64 (Apple Silicon): no override, inherit rustc defaults — matches
8+
# the published macOS release, which also sets no target-cpu.
9+
#
10+
# Pre-2013 x86 hardware: override this `target-cpu` value (e.g. to
11+
# `x86-64-v2` or remove the flag entirely) and build from source.
12+
13+
[target.'cfg(target_arch = "x86_64")']
14+
rustflags = ["-C", "target-cpu=x86-64-v3"]

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cargo build --release
1212
./target/release/focalors gui
1313
```
1414

15-
The repo's `.cargo/config.toml` sets `target-cpu=native` for local builds — handy when iterating but not portable. The GitHub Actions release workflow builds Linux/Windows binaries with `target-cpu=x86-64-v3` (AVX2 baseline, supported by every Intel/AMD x86 CPU from 2013 onward). macOS builds default to Apple Silicon. Pre-2013 x86 hardware can compile from source instead.
15+
The repo's `.cargo/config.toml` matches the GitHub Actions release workflow: x86_64 builds (Linux/Windows/Intel Mac) use `target-cpu=x86-64-v3` (AVX2 baseline, supported by every Intel/AMD CPU from 2013 onward); aarch64 builds (Apple Silicon) use rustc defaults. Your local binary has the same instruction set as the binaries users download — what you test is what they run. Pre-2013 x86 hardware can compile from source by lowering `target-cpu` in `.cargo/config.toml`.
1616

1717
## Engine development
1818

0 commit comments

Comments
 (0)