Skip to content

Fix incorrect exec transition for cargo_build_script#4040

Merged
UebelAndre merged 2 commits into
bazelbuild:mainfrom
UebelAndre:cargo_build_script
May 28, 2026
Merged

Fix incorrect exec transition for cargo_build_script#4040
UebelAndre merged 2 commits into
bazelbuild:mainfrom
UebelAndre:cargo_build_script

Conversation

@UebelAndre
Copy link
Copy Markdown
Collaborator

@UebelAndre UebelAndre commented May 14, 2026

Relying on an exec configuration through targets consumed in target leads to the potential for cfg = "exec" to be evaluated differently in the transitive target (in this case, cargo_build_script_runfiles.script) and the consumer (cargo_build_script.data_runfiles). This change moves the script directly back to cargo_build_script in cfg = "exec" and separately uses a cfg = "target" intermediate rule to implement runfiles (solving for bazelbuild/bazel#15486).

closes #3201 #3893

Comment thread cargo/private/cargo_build_script_runner/cargo_manifest_dir.rs Outdated
@UebelAndre UebelAndre enabled auto-merge May 28, 2026 17:13
@UebelAndre UebelAndre added this pull request to the merge queue May 28, 2026
Merged via the queue into bazelbuild:main with commit e0ddf88 May 28, 2026
3 checks passed
@slackito
Copy link
Copy Markdown
Collaborator

slackito commented Jun 2, 2026

We've found a regression while testing this change internally. To reproduce, patch repro.patch into a clean working copy and run bazel build //test/unit/cargo_build_script_data_runfiles:reproduce_bin.

If I understand correctly, the main problem is that the runfiles library needs the RUNFILES_DIR env variable to point to the runfiles directory created by cargo_build_script. Apart from that, I believe we also need to copy the _repo_mapping file from the original runfiles dir to the new one. As far as I can tell, doing both of these things makes the example build correctly, but I don't know the right way to get the data to the right place. Could you please take a look?

@UebelAndre
Copy link
Copy Markdown
Collaborator Author

@slackito can you open a pull-request with the repro so I can see the failure?

@slackito
Copy link
Copy Markdown
Collaborator

slackito commented Jun 2, 2026

@slackito can you open a pull-request with the repro so I can see the failure?

#4064

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.

"No such file or directory" crash for build scripts of 3rd party crates

2 participants