diff --git a/.cargo/release.toml b/.cargo/release.toml new file mode 100644 index 00000000..bd3a5760 --- /dev/null +++ b/.cargo/release.toml @@ -0,0 +1,3 @@ +# Remove source locations from release panic metadata to reduce binary size. +[target.'cfg(all())'] +rustflags = ["-Zlocation-detail=none"] diff --git a/.github/workflows/reusable-native-build.yml b/.github/workflows/reusable-native-build.yml index 4a893f2f..d06dbd48 100644 --- a/.github/workflows/reusable-native-build.yml +++ b/.github/workflows/reusable-native-build.yml @@ -109,6 +109,8 @@ jobs: ;; esac + # Omit panic source locations to reduce the release binary size. + args+=(-- --config ../../.cargo/release.toml) pnpm exec napi "${args[@]}" - name: Upload native binding diff --git a/packages/rstack/package.json b/packages/rstack/package.json index a678ae1e..89782fd7 100644 --- a/packages/rstack/package.json +++ b/packages/rstack/package.json @@ -67,7 +67,7 @@ "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", + "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 -- --config ../../.cargo/release.toml", "dev": "rslib -w", "package:native": "napi create-npm-dirs --config-path napi.json", "test": "rs test" diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 99461977..6f8397f5 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,5 @@ [toolchain] -channel = "1.97.1" +# Required by the release-only -Zlocation-detail=none flag. +channel = "nightly-2026-04-16" components = ["clippy", "rustfmt"] profile = "minimal"