Skip to content

Commit b62d8c7

Browse files
authored
Better error message when failing on unknown targets (#1313)
1 parent 75973f4 commit b62d8c7

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ enum ErrorKind {
351351
ToolFamilyMacroNotFound,
352352
/// Invalid target.
353353
InvalidTarget,
354+
/// Unknown target.
355+
UnknownTarget,
354356
/// Invalid rustc flag.
355357
InvalidFlag,
356358
#[cfg(feature = "parallel")]
@@ -3979,7 +3981,7 @@ impl Default for Build {
39793981
}
39803982

39813983
fn fail(s: &str) -> ! {
3982-
eprintln!("\n\nerror occurred: {}\n\n", s);
3984+
eprintln!("\n\nerror occurred in cc-rs: {}\n\n", s);
39833985
std::process::exit(1);
39843986
}
39853987

src/target.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,20 @@ impl FromStr for TargetInfo<'_> {
5959
Ok(info.clone())
6060
} else {
6161
Err(Error::new(
62-
ErrorKind::InvalidTarget,
63-
format!("unknown target `{target_triple}`"),
62+
ErrorKind::UnknownTarget,
63+
format!(
64+
"unknown target `{target_triple}`.
65+
66+
NOTE: `cc-rs` only supports a fixed set of targets when not in a build script.
67+
- If adding a new target, you will need to fork of `cc-rs` until the target
68+
has landed on nightly and the auto-generated list has been updated. See also
69+
the `rustc` dev guide on adding a new target:
70+
https://rustc-dev-guide.rust-lang.org/building/new-target.html
71+
- If using a custom target, prefer to upstream it to `rustc` if possible,
72+
otherwise open an issue with `cc-rs`:
73+
https://github.com/rust-lang/cc-rs/issues/new
74+
"
75+
),
6476
))
6577
}
6678
}

0 commit comments

Comments
 (0)