Skip to content

Commit a1a163f

Browse files
committed
Add test showing that linker is ignored with target_applies_to_host=false and no target flags
1 parent 61424d6 commit a1a163f

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,7 +1,9 @@
11
//! Tests for configuration values that point to programs.
22
33
use cargo_test_support::prelude::*;
4-
use cargo_test_support::{basic_lib_manifest, project, rustc_host, rustc_host_env, str};
4+
use cargo_test_support::{
5+
basic_bin_manifest, basic_lib_manifest, project, rustc_host, rustc_host_env, str,
6+
};
57

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

0 commit comments

Comments
 (0)