diff --git a/src/cargo/core/compiler/compile_kind.rs b/src/cargo/core/compiler/compile_kind.rs index 4c123601f8e..f099db8ec8f 100644 --- a/src/cargo/core/compiler/compile_kind.rs +++ b/src/cargo/core/compiler/compile_kind.rs @@ -72,7 +72,11 @@ impl CompileKind { } else { val.raw_value().to_string() }; - CompileKind::Target(CompileTarget::new(&value)?) + if value == "" { + CompileKind::Host + } else { + CompileKind::Target(CompileTarget::new(&value)?) + } } None => CompileKind::Host, }; diff --git a/tests/testsuite/cross_compile.rs b/tests/testsuite/cross_compile.rs index fe573a88270..a854cec91fa 100644 --- a/tests/testsuite/cross_compile.rs +++ b/tests/testsuite/cross_compile.rs @@ -117,6 +117,37 @@ fn simple_cross_config() { } } +#[cargo_test] +fn unset_default_target() { + let p = project() + .file( + ".cargo/config", + r#" + [build] + target = "" + "#, + ) + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.0" + authors = [] + "#, + ) + .file( + "src/main.rs", + r#" + fn main() {{}} + "#, + ) + .build(); + + p.cargo("build -v").run(); + assert!(p.bin("foo").is_file()); +} + #[cargo_test] fn simple_deps() { if cross_compile::disabled() {