Skip to content

Precompute build-script flag metadata - #56

Merged
dzbarsky merged 1 commit into
hermeticbuild:mainfrom
zbarsky-openai:zbarsky/cargo-build-script-flags-20260906
Sep 8, 2026
Merged

dzbarsky merged 1 commit into
hermeticbuild:mainfrom
zbarsky-openai:zbarsky/cargo-build-script-flags-20260906

Conversation

@zbarsky-openai

Copy link
Copy Markdown

Cargo build-script analysis normalizes linker, C, and C++ flags through
_prefix_pwd_to_flag. The helper currently sorts the same flag spellings
and checks their argument form for every toolchain argument. Compute both
once per call while preserving the existing ordered matches and path
rewrites.

In full-graph bazel build --nobuild //... profiles, cumulative sampled
Starlark CPU under _cargo_build_script_impl fell from 114 seconds to
27–30 seconds in two patched runs. Overall elapsed time varied with major
GC, so the profiles do not establish a consistent wall-time improvement.

Sort flag variants and classify their argument forms once in
_prefix_pwd_to_flag, rather than repeating both operations for every
C/C++ toolchain argument. Preserve the existing ordered matching and
path rewrites.
@dzbarsky
dzbarsky merged commit b805595 into hermeticbuild:main Sep 8, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants