diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index dcd7591d..795132ce 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -41,10 +41,10 @@ jobs: run: cargo fmt --all -- --check - name: Lint Rust - run: cargo clippy --workspace --all-targets --locked -- -D warnings + run: cargo clippy --profile ci --workspace --all-targets --locked -- -D warnings - name: Build Native Binding - run: pnpm --filter rstack build:native + run: pnpm --filter rstack build:native:ci - name: Check run: node --run check diff --git a/.github/workflows/reusable-native-build.yml b/.github/workflows/reusable-native-build.yml index 0b9793ea..4a893f2f 100644 --- a/.github/workflows/reusable-native-build.yml +++ b/.github/workflows/reusable-native-build.yml @@ -96,6 +96,7 @@ jobs: export MACOSX_DEPLOYMENT_TARGET=11.0 ;; i686-pc-windows-msvc) + # Reduce peak link time and memory usage for the constrained 32-bit target. export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=32 export CARGO_PROFILE_RELEASE_LTO=false ;; diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9241443e..3062f9f7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,10 +41,10 @@ jobs: run: node --run build - name: Run Rust Tests - run: cargo test --workspace --locked + run: cargo test --profile ci --workspace --locked - name: Build Native Binding - run: pnpm --filter rstack build:native:release + run: pnpm --filter rstack build:native:ci - name: Check Generated Native Files run: git diff --exit-code -- packages/rstack/binding.cjs packages/rstack/binding.d.cts diff --git a/Cargo.toml b/Cargo.toml index 54a2d625..4ce85357 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,34 @@ napi-derive = "3.6.2" pathdiff = "0.2.3" rstack-ignore = { path = "crates/rstack-ignore" } +# Local development: 16 codegen units are sufficient for this small workspace while preserving +# parallel compilation and full debugging support. +[profile.dev] +codegen-units = 16 +debug = 2 +incremental = true +panic = "unwind" +split-debuginfo = "unpacked" + +# CI: 256 codegen units favor clean-build parallelism, while disabling cross-crate LTO avoids the +# release-only linking cost. +[profile.ci] +codegen-units = 256 +debug = false +incremental = false +inherits = "release" +lto = false +opt-level = 2 +# Cargo tests require unwinding, so keep the CI native build consistent. +panic = "unwind" +strip = false + +# Release: one codegen unit and fat LTO maximize optimization; abort prevents unwinding across the +# NAPI FFI boundary. [profile.release] -lto = true -strip = "symbols" +codegen-units = 1 +debug = false +lto = "fat" +opt-level = 3 +panic = "abort" +strip = true diff --git a/packages/rstack/package.json b/packages/rstack/package.json index 6504e57a..a678ae1e 100644 --- a/packages/rstack/package.json +++ b/packages/rstack/package.json @@ -66,6 +66,7 @@ "scripts": { "build": "rslib", "build:native": "napi build --config-path napi.json --platform --manifest-path ../../Cargo.toml --package rstack-binding --package-json-path package.json --output-dir . --js binding.cjs --dts binding.d.cts", + "build:native:ci": "napi build --config-path napi.json --platform --profile ci --manifest-path ../../Cargo.toml --package rstack-binding --package-json-path package.json --output-dir . --js binding.cjs --dts binding.d.cts", "build:native:release": "napi build --config-path napi.json --platform --release --manifest-path ../../Cargo.toml --package rstack-binding --package-json-path package.json --output-dir . --js binding.cjs --dts binding.d.cts", "dev": "rslib -w", "package:native": "napi create-npm-dirs --config-path napi.json",