Skip to content

Include transitive out_dirs in linking action#3579

Merged
illicitonion merged 3 commits intobazelbuild:mainfrom
illicitonion:transitive-out-dirs
Sep 2, 2025
Merged

Include transitive out_dirs in linking action#3579
illicitonion merged 3 commits intobazelbuild:mainfrom
illicitonion:transitive-out-dirs

Conversation

@illicitonion
Copy link
Copy Markdown
Collaborator

If a build script compiles a file which is needed at linking time, and adds a linker flag to add it to the search path, we need the out_dir to be present in the link action in order for the search path flag to actually take effect.

This was the original behaviour way back in
3a569b8 but got removed in 9426a38 which was intending to only restrict where flags were propagated but also stopped propagating out_dir files.

This is required because cargo uses the path to the out_dir as a well-known-path that doesn't move between builds, so link flags from a build script which get transitively propagated up to a link action happen to point at the right location on disk. We need to propagate this out_dir because the known location on disk is probably in a sandbox, so we need to explicitly materialise the files into the sandbox.

If a build script compiles a file which is needed at linking time, and
adds a linker flag to add it to the search path, we need the out_dir to
be present in the link action in order for the search path flag to
actually take effect.

This was the original behaviour way back in
3a569b8 but got removed in
9426a38 which was intending to only
restrict where flags were propagated but also stopped propagating
out_dir files.

This is required because cargo uses the path to the out_dir as a
well-known-path that doesn't move between builds, so link flags from a
build script which get transitively propagated up to a link action
happen to point at the right location on disk. We need to propagate this
out_dir because the known location on disk is probably in a sandbox, so
we need to explicitly materialise the files into the sandbox.
@illicitonion illicitonion mentioned this pull request Sep 1, 2025
@illicitonion illicitonion added this pull request to the merge queue Sep 2, 2025
Merged via the queue into bazelbuild:main with commit 46550dc Sep 2, 2025
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