fix(host-config): host.linker should not apply to non host unit#16641
Merged
epage merged 4 commits intorust-lang:masterfrom Feb 16, 2026
Merged
fix(host-config): host.linker should not apply to non host unit#16641epage merged 4 commits intorust-lang:masterfrom
epage merged 4 commits intorust-lang:masterfrom
Conversation
Collaborator
|
r? @epage rustbot has assigned @epage. Use Why was this reviewer chosen?The reviewer was selected based on:
|
f8598e5 to
464c17b
Compare
Add tests documenting that `host.linker`incorrectly apply to normal target builds. The test will be fixed in the next commit.
`host.runner` was incorrectly applied to non host units like proc macros and build scripts when `-Zhost-config` was enabled but no `--target` flag was specified. The root cause was that `target_linker()` used `target_config(kind)` which routes through `host_config` for `CompileKind::Host`. But `CompileKind::Host` is used for both build scripts and normal binaries when no `--target` is specified.
as this collects both host and target build targets
464c17b to
13525b7
Compare
epage
reviewed
Feb 14, 2026
epage
reviewed
Feb 16, 2026
tests/testsuite/cross_compile.rs
Outdated
| "#]]) | ||
| .run(); | ||
|
|
||
| // FIXME: without --target, host.linker incorrectly applies to normal binaries. |
Contributor
There was a problem hiding this comment.
How are we tracking this fixme? Living in a test adds a second, invisible backlog.
Member
Author
There was a problem hiding this comment.
It got removed in the next commit
Contributor
There was a problem hiding this comment.
Was specifically looking to see if that happened and still somehow missed it, thanks
epage
approved these changes
Feb 16, 2026
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.
What does this PR try to resolve?
Similar to #16638,
this prevents
host.linkerfrom applying to non-host build targets.How to test and review this PR?
This behavior has been there since the integration of host-config, so it might break somebody's assumption.
I've checked the use of
target_linker:target_linkeras it is more a target builds:cargo/src/cargo/core/compiler/build_runner/mod.rs
Lines 281 to 289 in 312145c
RUSTC_LINKERset for build scripts is on the same boat. It indicates the linker to use for the associated crate, which is always a target build:cargo/src/cargo/core/compiler/custom_build.rs
Lines 389 to 391 in 312145c
Other than the two above, the other usages of it (fingerprint, and rustc invocation) should respect host.linker when building build script exectuables.