From 148f9e883df67f6df8fb2a2afc79c3a63e36c923 Mon Sep 17 00:00:00 2001 From: can1357 Date: Tue, 10 Feb 2026 22:06:34 +0100 Subject: [PATCH] ci(workflows): added RUSTFLAGS configuration for x86-64-v3 CPU optimization in CI and native builds - Added RUSTFLAGS environment variable configuration to CI workflow for x86-64-v3 CPU optimization across multiple build jobs. - Added per-matrix rustflags configuration for native builds on x64 platforms (Linux, macOS Intel, Windows). - Updated build-native script to default to native CPU optimization for local builds when not cross-compiling. --- .github/workflows/ci.yml | 8 ++++++++ packages/natives/scripts/build-native.ts | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1c490d16c..92ed1ccf4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,8 @@ concurrency: jobs: rust: runs-on: ubuntu-latest + env: + RUSTFLAGS: -C target-cpu=x86-64-v3 steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly @@ -41,6 +43,7 @@ jobs: - os: ubuntu-latest platform: linux arch: x64 + rustflags: "-C target-cpu=x86-64-v3" - os: ubuntu-latest platform: linux arch: arm64 @@ -48,12 +51,14 @@ jobs: - os: macos-15-intel platform: darwin arch: x64 + rustflags: "-C target-cpu=x86-64-v3" - os: macos-14 platform: darwin arch: arm64 - os: windows-latest platform: win32 arch: x64 + rustflags: "-C target-cpu=x86-64-v3" runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -79,6 +84,7 @@ jobs: TARGET_PLATFORM: ${{ matrix.platform }} TARGET_ARCH: ${{ matrix.arch }} CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc + RUSTFLAGS: ${{ matrix.rustflags }} run: bun --cwd=packages/natives run build:native - name: Upload native addon uses: actions/upload-artifact@v4 @@ -89,6 +95,8 @@ jobs: test: runs-on: ubuntu-latest + env: + RUSTFLAGS: -C target-cpu=x86-64-v3 steps: - uses: actions/checkout@v4 with: diff --git a/packages/natives/scripts/build-native.ts b/packages/natives/scripts/build-native.ts index 6658eccc4..14a6c352b 100644 --- a/packages/natives/scripts/build-native.ts +++ b/packages/natives/scripts/build-native.ts @@ -15,6 +15,11 @@ const isCrossCompile = targetPlatform !== process.platform || targetArch !== process.arch; +// Default to native CPU optimization for local builds; CI overrides via RUSTFLAGS env +if (!isCrossCompile && !Bun.env.RUSTFLAGS) { + Bun.env.RUSTFLAGS = "-C target-cpu=native"; +} + async function cleanupStaleTemps(dir: string): Promise { try { const entries = await fs.readdir(dir);