Skip to content

Commit 81adb7f

Browse files
authored
perf: Use build-std for release (#11077)
1 parent 8675099 commit 81adb7f

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

crates/node_binding/scripts/build.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,33 @@ async function build() {
6969
features.push("sftrace-setup");
7070
envs.RUSTFLAGS = "-Zinstrument-xray=always";
7171
}
72-
if(values.profile === "release"){
72+
if (values.profile === "release") {
7373
features.push("info-level");
7474
}
7575
if (features.length) {
7676
args.push("--features " + features.join(","));
7777
}
7878

79-
if (positionals.length > 0) {
79+
if (positionals.length > 0
80+
|| values.profile === "release"
81+
|| values.profile === "release-debug"
82+
|| values.profile === "profiling"
83+
) {
8084
// napi need `--` to separate options and positional arguments.
8185
args.push("--");
82-
args.push(...positionals);
86+
87+
if (values.profile === "release"
88+
|| values.profile === "release-debug"
89+
|| values.profile === "profiling"
90+
) {
91+
// allows to optimize std with current compile arguments
92+
// and avoids std code generate unwind table to save size.
93+
args.push("-Zbuild-std=panic_abort,std");
94+
}
95+
96+
if (positionals.length > 0) {
97+
args.push(...positionals);
98+
}
8399
}
84100

85101
console.log(`Run command: napi ${args.join(" ")}`);

rust-toolchain.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[toolchain]
22
profile = "default"
3+
components = ["rust-src"]
34
# Use nightly for better access to the latest Rust features.
45
channel = "nightly-2025-05-30"

0 commit comments

Comments
 (0)