perf: declare artifact cdylibs as normal dependencies - #636
Merged
wan9chi merged 1 commit intoAug 11, 2026
Conversation
Move the fspy preload libraries and vt_client_napi from `[build-dependencies]` to (target-scoped) `[dependencies]`. Cargo compiles build-dependency artifact deps with the build-override profile — opt-level 0 in release builds, and only a root-manifest override can fix it, which every downstream workspace had to copy (see rust-lang/cargo#16719). Under `[dependencies]` the normal profile applies everywhere with no overrides, and the cdylibs additionally gain `panic = "abort"` from the release profile. `CARGO_CDYLIB_FILE_*` is now provided while the consuming crate compiles instead of to its build script, so hashing moves from `materialized_artifact_build::register` into a new `materialized_artifact_macros::artifact!` proc macro that reads and hashes the file at expansion time. The macro declares its reads via `proc_macro::tracked` so a future expansion cache cannot serve a stale hash next to fresh bytes, and its expansion re-references the file and env var through `include_bytes!(env!(…))` for dep-info tracking. When the env var is unset the expansion branches on `cfg(rust_analyzer)`: a well-typed stub under rust-analyzer, an actionable `compile_error!` under rustc. The macOS downloaded binaries switch to the same macro (their build script now publishes only a path via `cargo:rustc-env`), which leaves `materialized_artifact_build` without consumers; the crate is removed. Scoping the preload deps to the targets that embed them also stops musl and Windows/Unix cross-builds from producing empty cdylibs — resolver panics on cfg-scoped artifact deps only affect `[build-dependencies]` placement. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
fspy benchmarklinuxmacoswindows |
wan9chi
added a commit
that referenced
this pull request
Aug 11, 2026
## Motivation #597 worked around Cargo compiling `[build-dependencies]` artifact deps with the build-override profile (opt-level 0 in release; rust-lang/cargo#16719) using per-package `[profile.release.package.*]` overrides plus the `artifact_profile` build-script guard. The next PR in this stack (#636) moves the artifact cdylibs to `[dependencies]`, where the normal release profile applies in this workspace and every downstream one — making both the overrides and the guard dead machinery. ## What this does Reverts #597 (5ed7a5a): removes the three profile-override blocks, the `artifact_profile` crate, and its build-script guard calls from the preload and napi crates. Note: artifact cdylibs build unoptimized between this PR and #636; the stack lands together. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Cargo compiles artifact dependencies declared under
[build-dependencies]with the build-override profile — opt-level 0 even in release builds — and only root-manifest profile overrides can fix it, which every downstream workspace has to copy (rust-lang/cargo#16719). The preload libraries run inside every intercepted libc call andvt_client_napibacks the Node.js client, so their optimization should not depend on fragile per-workspace boilerplate. Declaring them under[dependencies]applies the normal profile everywhere automatically.What this does
fspy_preload_unix/fspy_preload_windows/vt_client_napifrom[build-dependencies]to target-scoped[dependencies]. They now build with the full release profile (opt-level=3,lto=fat,codegen-units=1,strip=symbols) and additionally gainpanic = "abort", in this workspace and downstream ones, with no profile overrides.CARGO_CDYLIB_FILE_*is provided while the consuming crate compiles rather than to its build script, so hashing moves into a newmaterialized_artifact_macros::artifact!proc macro that reads and hashes the file at expansion time (same xxh3{:x}format, so materialized filenames are unchanged).proc_macro::trackedso a future proc-macro expansion cache can never serve a stale hash next to fresh bytes, and its expansion re-references the env var and file throughinclude_bytes!(env!(…))for dep-info tracking.cfg(rust_analyzer): a well-typed stub under rust-analyzer, an actionablecompile_error!under rustc. The cfg tokens never appear in successful builds, so nocheck-cfgdeclarations are needed.cargo:rustc-env), leavingmaterialized_artifact_buildwithout consumers; the crate is removed.[build-dependencies]placement.Behavior note:
panic = "abort"now applies tovt_client_napi— a panic in the addon aborts the Node process instead of unwinding into napi-rs'scatch_unwind. This matches the workspace-wide abort policy.🤖 Generated with Claude Code