Skip to content

Commit 3703457

Browse files
committed
build(native): configure Cargo profiles
1 parent b39de82 commit 3703457

5 files changed

Lines changed: 36 additions & 6 deletions

File tree

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ jobs:
4141
run: cargo fmt --all -- --check
4242

4343
- name: Lint Rust
44-
run: cargo clippy --workspace --all-targets --locked -- -D warnings
44+
run: cargo clippy --profile ci --workspace --all-targets --locked -- -D warnings
4545

4646
- name: Build Native Binding
47-
run: pnpm --filter rstack build:native
47+
run: pnpm --filter rstack build:native:ci
4848

4949
- name: Check
5050
run: node --run check

.github/workflows/reusable-native-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ jobs:
9696
export MACOSX_DEPLOYMENT_TARGET=11.0
9797
;;
9898
i686-pc-windows-msvc)
99+
# Reduce peak link time and memory usage for the constrained 32-bit target.
99100
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=32
100101
export CARGO_PROFILE_RELEASE_LTO=false
101102
;;

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ jobs:
4141
run: node --run build
4242

4343
- name: Run Rust Tests
44-
run: cargo test --workspace --locked
44+
run: cargo test --profile ci --workspace --locked
4545

4646
- name: Build Native Binding
47-
run: pnpm --filter rstack build:native:release
47+
run: pnpm --filter rstack build:native:ci
4848

4949
- name: Check Generated Native Files
5050
run: git diff --exit-code -- packages/rstack/binding.cjs packages/rstack/binding.d.cts

Cargo.toml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,34 @@ napi-derive = "3.6.2"
1616
pathdiff = "0.2.3"
1717
rstack-ignore = { path = "crates/rstack-ignore" }
1818

19+
# Local development: 16 codegen units are sufficient for this small workspace while preserving
20+
# parallel compilation and full debugging support.
21+
[profile.dev]
22+
codegen-units = 16
23+
debug = 2
24+
incremental = true
25+
panic = "unwind"
26+
split-debuginfo = "unpacked"
27+
28+
# CI: 256 codegen units favor clean-build parallelism, while disabling cross-crate LTO avoids the
29+
# release-only linking cost.
30+
[profile.ci]
31+
codegen-units = 256
32+
debug = false
33+
incremental = false
34+
inherits = "release"
35+
lto = false
36+
opt-level = 2
37+
# Cargo tests require unwinding, so keep the CI native build consistent.
38+
panic = "unwind"
39+
strip = false
40+
41+
# Release: one codegen unit and fat LTO maximize optimization; abort prevents unwinding across the
42+
# NAPI FFI boundary.
1943
[profile.release]
20-
lto = true
21-
strip = "symbols"
44+
codegen-units = 1
45+
debug = false
46+
lto = "fat"
47+
opt-level = 3
48+
panic = "abort"
49+
strip = true

packages/rstack/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"scripts": {
6767
"build": "rslib",
6868
"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",
69+
"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",
6970
"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",
7071
"dev": "rslib -w",
7172
"package:native": "napi create-npm-dirs --config-path napi.json",

0 commit comments

Comments
 (0)