Skip to content

fix(host-config): host.linker should not apply to non host unit#16641

Merged
epage merged 4 commits intorust-lang:masterfrom
weihanglo:host-linker
Feb 16, 2026
Merged

fix(host-config): host.linker should not apply to non host unit#16641
epage merged 4 commits intorust-lang:masterfrom
weihanglo:host-linker

Conversation

@weihanglo
Copy link
Member

@weihanglo weihanglo commented Feb 13, 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:
    self.compilation.to_doc_test.push(compilation::Doctest {
    unit: unit.clone(),
    args,
    unstable_opts,
    linker: self.compilation.target_linker(unit.kind).clone(),
    script_metas,
    env: artifact::get_env(&self, unit, self.unit_deps(unit))?,
    });
    }
  • 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:
    if let Some(linker) = &build_runner.compilation.target_linker(unit.kind) {
    cmd.env("RUSTC_LINKER", linker);
    }

Other than the two above, the other usages of it (fingerprint, and rustc invocation) should respect host.linker when building build script exectuables.

@rustbot rustbot added A-build-execution Area: anything dealing with executing the compiler A-rebuild-detection Area: rebuild detection and fingerprinting S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 13, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 13, 2026

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ehuss, @epage, @weihanglo
  • @ehuss, @epage, @weihanglo expanded to ehuss, epage, weihanglo
  • Random selection from ehuss, epage

@weihanglo weihanglo added Z-host-config Nightly: host-config A-build-execution Area: anything dealing with executing the compiler A-rebuild-detection Area: rebuild detection and fingerprinting S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed A-build-execution Area: anything dealing with executing the compiler A-rebuild-detection Area: rebuild detection and fingerprinting S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 13, 2026
@weihanglo weihanglo force-pushed the host-linker branch 2 times, most recently from f8598e5 to 464c17b Compare February 13, 2026 23:40
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
"#]])
.run();

// FIXME: without --target, host.linker incorrectly applies to normal binaries.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are we tracking this fixme? Living in a test adds a second, invisible backlog.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It got removed in the next commit

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was specifically looking to see if that happened and still somehow missed it, thanks

@epage epage added this pull request to the merge queue Feb 16, 2026
Merged via the queue into rust-lang:master with commit 2200079 Feb 16, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 16, 2026
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)
@rustbot rustbot added this to the 1.95.0 milestone Feb 21, 2026
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-build-execution Area: anything dealing with executing the compiler A-rebuild-detection Area: rebuild detection and fingerprinting Z-host-config Nightly: host-config

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants