Skip to content

Commit a217db0

Browse files
committed
Add test showing that linker is ignored with target_applies_to_host=false and no target flags
1 parent 6d68563 commit a217db0

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

tests/testsuite/tool_paths.rs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//! Tests for configuration values that point to programs.
22
3-
use cargo_test_support::{basic_lib_manifest, project, rustc_host, rustc_host_env, str};
3+
use cargo_test_support::{
4+
basic_bin_manifest, basic_lib_manifest, project, rustc_host, rustc_host_env, str,
5+
};
46

57
#[cargo_test]
68
fn pathless_tools() {
@@ -484,3 +486,39 @@ fn cfg_ignored_fields() {
484486
"#]])
485487
.run();
486488
}
489+
490+
#[cargo_test]
491+
fn custom_linker_target_applies_to_host() {
492+
let target = rustc_host();
493+
494+
let foo = project()
495+
.file("Cargo.toml", &basic_bin_manifest("foo"))
496+
.file("src/main.rs", "fn main() {}")
497+
.file(
498+
".cargo/config.toml",
499+
&format!(
500+
r#"
501+
[target.{}]
502+
linker = "nonexistent-linker"
503+
"#,
504+
target
505+
),
506+
)
507+
.build();
508+
509+
// Since we're building a binary this would error if
510+
// linker was being passed to cargo.
511+
foo.cargo("build --verbose")
512+
.masquerade_as_nightly_cargo(&["target-applies-to-host"])
513+
.arg("-Ztarget-applies-to-host")
514+
.env("CARGO_TARGET_APPLIES_TO_HOST", "false")
515+
.with_status(0)
516+
.with_stderr_data(
517+
"\
518+
[COMPILING] foo v0.5.0 ([ROOT]/foo)
519+
[RUNNING] `rustc [..]`
520+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
521+
",
522+
)
523+
.run();
524+
}

0 commit comments

Comments
 (0)