Fix rust_doc_test linking with native libraries#4080
Merged
UebelAndre merged 2 commits intoJun 11, 2026
Conversation
d4d3435 to
f96b19d
Compare
Make sure linker inputs are included in runfiles by adding a flag to collect_inputs. Add roots for native libraries.
f96b19d to
2a51335
Compare
UebelAndre
requested changes
Jun 11, 2026
UebelAndre
left a comment
Collaborator
There was a problem hiding this comment.
Thanks! Just one question!
| use_direct_link_driver (bool): Whether the linker is a direct driver (e.g. `ld`, `wasm-ld`) vs a wrapper (e.g. `clang`, `gcc`). | ||
| include_link_flags (bool, optional): Whether to include flags like `-l` that instruct the linker to search for a library. | ||
| """ | ||
| if crate_type in ["lib", "rlib"]: |
Collaborator
There was a problem hiding this comment.
This seems somewhat risky, can you expand on why this is removed?
Contributor
Author
There was a problem hiding this comment.
_add_native_link_flags is called by construct_arguments and is already guarded by
if ("link" in emit and crate_info.type not in ["rlib", "lib"]) or add_flags_for_binary
In the rustdoc test, add_flags_for_binary was already true, but then _add_native_link_flags bails early. I thought it was redundant to check again for ["rlib", "lib"] and seemed like the right thing to do if add_flags_for_binary is true.
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.
rust_doc_test does not propagate native libraries into the final test command. This appears to only affect native libraries built by bazel rather than ones linked into crates by build.rs. This change only works with static libraries - dynamic libraries are much more complex.
For example, using the jemalloc bazel module in tikv-jemalloc-sys.