Skip to content

Stable build script out dir tokens - #4258

Closed
lukasoyen wants to merge 2 commits into
bazelbuild:mainfrom
lukasoyen:stable-build-script-out-dir-tokens
Closed

lukasoyen wants to merge 2 commits into
bazelbuild:mainfrom
lukasoyen:stable-build-script-out-dir-tokens

Conversation

@lukasoyen

Copy link
Copy Markdown
Contributor

Motivation

Cargo build scripts can emit linker flags and search paths containing
bazel-out/<configuration> paths. Since these values are written to generated
flag files, Bazel cannot rewrite them later. The current substitution keys also
use full analysis-time out_dir paths, making the flag files configuration
dependent.

Proposed change

Use stable, producer-specific substitution keys derived from
out_dir.short_path, normalize embedded output paths to bazel-out/cfg, and
keep the corresponding --subst values File-backed for runtime path mapping.

This preserves uniqueness between build scripts while allowing equivalent
configurations to share generated flag files.

Related work

rules_rust#4253
addresses C++ linker and sysroot paths passed as strings. This change covers
Cargo build-script-generated linker flags and search paths.

Testing

Updated runner tests for stable substitution keys, mapped bazel-out paths, and
existing regular-path behavior.

Pass producer-specific output directory tokens to the build script
runner and normalize configuration-specific bazel-out paths in generated
link flags. Keep substitution values File-backed so Bazel path mapping can
share Rust actions across configurations.
Verify nested output paths and identical flags across output
configurations. Strengthen transitive substitution coverage to reject
configuration-specific keys.
@lukasoyen lukasoyen closed this Sep 16, 2026
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.

1 participant