fix(host-config): host.runner should not apply to cargo run#16638
Merged
epage merged 4 commits intorust-lang:masterfrom Feb 13, 2026
Merged
fix(host-config): host.runner should not apply to cargo run#16638epage merged 4 commits intorust-lang:masterfrom
host.runner should not apply to cargo run#16638epage merged 4 commits intorust-lang:masterfrom
Conversation
Collaborator
|
r? @ehuss rustbot has assigned @ehuss. Use Why was this reviewer chosen?The reviewer was selected based on:
|
epage
approved these changes
Feb 13, 2026
Add tests documenting that `host.runner`incorrectly apply to normal target builds. The test will be fixed in the next commit.
8b539f8 to
089725d
Compare
089725d to
5662c3b
Compare
weihanglo
commented
Feb 13, 2026
| .chain(Some(&CompileKind::Host)) | ||
| .map(|kind| Ok((*kind, target_runner(bcx, *kind)?))) | ||
| .collect::<CargoResult<HashMap<_, _>>>()?; | ||
| if !bcx.gctx.target_applies_to_host()? { |
Member
Author
There was a problem hiding this comment.
The previous iteration was a premature fix because requested_kinds contains only CompileKind::Host when in non-cross-compilation mode. We need to insert target config with explicit target key here to ensure they are picked up.
See also the new tests in tool_paths.rs.
b0c8342 to
7e5b21f
Compare
host mode means without any `--target` cross-compilation settings
`host.runner` was incorrectly applied to `cargo run` and other target processes when `-Zhost-config` was enabled but no `--target` flag was specified. The root cause was that `target_runner()` 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 it covers both host and target runners.
7e5b21f to
c3ac327
Compare
github-merge-queue bot
pushed a commit
that referenced
this pull request
Feb 16, 2026
### What does this PR try to resolve? Similar to <#16638>, this prevents `host.linker` from 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`: * doctest continues using `target_linker` as it is more a target builds: https://github.com/rust-lang/cargo/blob/312145c006c53906c7bd6c585e52f2639d37a191/src/cargo/core/compiler/build_runner/mod.rs?plain=1#L281-L289 * `RUSTC_LINKER` set for build scripts is on the same boat. It indicates the linker to use for the associated crate, which is always a target build: https://github.com/rust-lang/cargo/blob/312145c006c53906c7bd6c585e52f2639d37a191/src/cargo/core/compiler/custom_build.rs?plain=1#L389-L391 Other than the two above, the other usages of it (fingerprint, and rustc invocation) should respect host.linker when building build script exectuables.
rust-bors bot
pushed a commit
to rust-lang/rust
that referenced
this pull request
Feb 21, 2026
Update cargo submodule 10 commits in ce69df6f72a3b6a2b5c722ba68ddef255344b31c..8cc0cb136772b8f54eafe0d163fcb7226a06af0c 2026-02-12 12:39:45 +0000 to 2026-02-17 12:16:26 +0000 - docs(layout): Updated layout module docs to document new layout (rust-lang/cargo#16502) - fix(host-config): host.linker should not apply to non host unit (rust-lang/cargo#16641) - init: improve error message and add tests (rust-lang/cargo#16643) - Corrected doc comment for build script root_output path (rust-lang/cargo#16645) - Changed build script run `output` dir to `stdout` in new build-dir layout (rust-lang/cargo#16644) - test: add test case for verify-project with invalid TOML (rust-lang/cargo#16640) - test(script): Show remaining workspace behavors (rust-lang/cargo#16633) - fix(host-config): `host.runner` should not apply to `cargo run` (rust-lang/cargo#16638) - refactor(help): simplify code structure (rust-lang/cargo#16627) - test: Remove unused docker ip_address (rust-lang/cargo#16636)
github-actions bot
pushed a commit
to rust-lang/miri
that referenced
this pull request
Feb 22, 2026
Update cargo submodule 10 commits in ce69df6f72a3b6a2b5c722ba68ddef255344b31c..8cc0cb136772b8f54eafe0d163fcb7226a06af0c 2026-02-12 12:39:45 +0000 to 2026-02-17 12:16:26 +0000 - docs(layout): Updated layout module docs to document new layout (rust-lang/cargo#16502) - fix(host-config): host.linker should not apply to non host unit (rust-lang/cargo#16641) - init: improve error message and add tests (rust-lang/cargo#16643) - Corrected doc comment for build script root_output path (rust-lang/cargo#16645) - Changed build script run `output` dir to `stdout` in new build-dir layout (rust-lang/cargo#16644) - test: add test case for verify-project with invalid TOML (rust-lang/cargo#16640) - test(script): Show remaining workspace behavors (rust-lang/cargo#16633) - fix(host-config): `host.runner` should not apply to `cargo run` (rust-lang/cargo#16638) - refactor(help): simplify code structure (rust-lang/cargo#16627) - test: Remove unused docker ip_address (rust-lang/cargo#16636)
github-actions bot
pushed a commit
to rust-lang/rustc-dev-guide
that referenced
this pull request
Feb 23, 2026
Update cargo submodule 10 commits in ce69df6f72a3b6a2b5c722ba68ddef255344b31c..8cc0cb136772b8f54eafe0d163fcb7226a06af0c 2026-02-12 12:39:45 +0000 to 2026-02-17 12:16:26 +0000 - docs(layout): Updated layout module docs to document new layout (rust-lang/cargo#16502) - fix(host-config): host.linker should not apply to non host unit (rust-lang/cargo#16641) - init: improve error message and add tests (rust-lang/cargo#16643) - Corrected doc comment for build script root_output path (rust-lang/cargo#16645) - Changed build script run `output` dir to `stdout` in new build-dir layout (rust-lang/cargo#16644) - test: add test case for verify-project with invalid TOML (rust-lang/cargo#16640) - test(script): Show remaining workspace behavors (rust-lang/cargo#16633) - fix(host-config): `host.runner` should not apply to `cargo run` (rust-lang/cargo#16638) - refactor(help): simplify code structure (rust-lang/cargo#16627) - test: Remove unused docker ip_address (rust-lang/cargo#16636)
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?
host.runnerwas incorrectly applied tocargo runand other targetprocesses when
-Zhost-configwas enabled but no--targetflag wasspecified.
The root cause was that
target_runner()usedtarget_config(kind)which routes through
host_configforCompileKind::Host. ButCompileKind::Hostis used for both build scripts and normal binarieswhen no
--targetis specified.Fixes #16634
How to test and review this PR?
Commit by commit.
Planned to change
host.linkerbehavior though that "bug" has been there for years.It is wiser to make a separate PR.