Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse unsupported crate type error more tightly #7364

Merged
merged 2 commits into from
Sep 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/build_context/target_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ fn parse_crate_type(
) -> CargoResult<Option<(String, String)>> {
let not_supported = error.lines().any(|line| {
(line.contains("unsupported crate type") || line.contains("unknown crate type"))
&& line.contains(crate_type)
&& line.contains(&format!("crate type `{}`", crate_type))
});
if not_supported {
return Ok(None);
Expand Down
47 changes: 47 additions & 0 deletions tests/testsuite/custom_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,50 @@ fn custom_target_dependency() {

p.cargo("build --lib --target custom-target.json -v").run();
}

#[cargo_test]
fn custom_bin_target() {
if !is_nightly() {
// Requires features no_core, lang_items
return;
}
let p = project()
.file(
"src/main.rs",
r#"
#![feature(no_core)]
#![feature(lang_items)]
#![no_core]
#![no_main]

#[lang = "sized"]
pub trait Sized {
// Empty.
}
#[lang = "copy"]
pub trait Copy {
// Empty.
}
"#,
)
.file(
"custom-bin-target.json",
r#"
{
"llvm-target": "x86_64-unknown-none-gnu",
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
"arch": "x86_64",
"target-endian": "little",
"target-pointer-width": "64",
"target-c-int-width": "32",
"os": "none",
"linker-flavor": "ld.lld",
"linker": "rust-lld",
"executables": true
}
"#,
)
.build();

p.cargo("build --target custom-bin-target.json -v").run();
}