Include transitive out_dirs in linking action#3579
Merged
illicitonion merged 3 commits intobazelbuild:mainfrom Sep 2, 2025
Merged
Include transitive out_dirs in linking action#3579illicitonion merged 3 commits intobazelbuild:mainfrom
illicitonion merged 3 commits intobazelbuild:mainfrom
Conversation
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.
Merged
UebelAndre
approved these changes
Sep 2, 2025
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.
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.