Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ rustflags = [

"-Aclippy::default_constructed_unit_structs",
"-Zshare-generics=y", # make the current crate share its generic instantiations
"-Zthreads=8" # parallel frontend https://blog.rust-lang.org/2023/11/09/parallel-rustc.html

"-Zthreads=8", # parallel frontend https://blog.rust-lang.org/2023/11/09/parallel-rustc.html
]

# Fix napi breaking in test environment <https://github.com/napi-rs/napi-rs/issues/1005#issuecomment-1011034770>
Expand All @@ -55,7 +54,6 @@ rustflags = [
"-C", "link-args=/DEFAULTLIB:ucrt.lib"
]


[target.wasm32-wasip1-threads]
rustflags = ["--cfg", "tokio_unstable"]

Expand Down
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ url = { version = "2.5.4" }
urlencoding = { version = "2.1.3" }
ustr = { package = "ustr-fxhash", version = "1.0.1" }
xxhash-rust = { version = "0.8.14" }
sftrace-setup = { version = "0.1.0" }

# Pinned
napi = { version = "3.0.0-beta.5" }
Expand Down
3 changes: 1 addition & 2 deletions crates/node_binding/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,8 @@ ustr = { workspace = true }

[target.'cfg(not(target_family = "wasm"))'.dependencies]
tokio = { workspace = true, features = ["parking_lot"] }

rspack_tracing = { workspace = true }

sftrace-setup = { workspace = true, optional = true }

[build-dependencies]
napi-build = { workspace = true }
15 changes: 13 additions & 2 deletions crates/node_binding/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ async function build() {
"--pipe",
`"node ./scripts/dts-header.js"`
];
let features = [];
let envs = { ...process.env };

if (values.profile) {
args.push("--profile", values.profile);
}
Expand All @@ -52,15 +55,23 @@ async function build() {
}
if (!process.env.DISABLE_PLUGIN) {
args.push("--no-default-features");
args.push("--features plugin");
features.push("plugin");
}
args.push("--no-dts-cache");
if (values.profile === "release-debug") {
features.push("sftrace-setup");
envs.RUSTFLAGS = "-Zinstrument-xray=always";
}
if (features.length) {
args.push("--features " + features.join(","));
}

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

let cp = spawn("napi", args, {
stdio: "inherit",
shell: true
shell: true,
env: envs,
});

cp.on("error", reject);
Expand Down
7 changes: 7 additions & 0 deletions crates/node_binding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,13 @@ fn init() {
thread,
};

#[cfg(feature = "sftrace-setup")]
if std::env::var_os("SFTRACE_OUTPUT_FILE").is_some() {
unsafe {
sftrace_setup::setup();
}
}

panic::install_panic_handler();
// control the number of blocking threads, similar as https://github.com/tokio-rs/tokio/blob/946401c345d672d357693740bc51f77bc678c5c4/tokio/src/loom/std/mod.rs#L93
const ENV_BLOCKING_THREADS: &str = "RSPACK_BLOCKING_THREADS";
Expand Down
Loading