diff --git a/src/lib.rs b/src/lib.rs index 2d0daa6d..3488e1f3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -351,6 +351,8 @@ enum ErrorKind { ToolFamilyMacroNotFound, /// Invalid target. InvalidTarget, + /// Unknown target. + UnknownTarget, /// Invalid rustc flag. InvalidFlag, #[cfg(feature = "parallel")] @@ -3979,7 +3981,7 @@ impl Default for Build { } fn fail(s: &str) -> ! { - eprintln!("\n\nerror occurred: {}\n\n", s); + eprintln!("\n\nerror occurred in cc-rs: {}\n\n", s); std::process::exit(1); } diff --git a/src/target.rs b/src/target.rs index 20fce321..b00a9da4 100644 --- a/src/target.rs +++ b/src/target.rs @@ -59,8 +59,20 @@ impl FromStr for TargetInfo<'_> { Ok(info.clone()) } else { Err(Error::new( - ErrorKind::InvalidTarget, - format!("unknown target `{target_triple}`"), + ErrorKind::UnknownTarget, + format!( + "unknown target `{target_triple}`. + +NOTE: `cc-rs` only supports a fixed set of targets when not in a build script. +- If adding a new target, you will need to fork of `cc-rs` until the target + has landed on nightly and the auto-generated list has been updated. See also + the `rustc` dev guide on adding a new target: + https://rustc-dev-guide.rust-lang.org/building/new-target.html +- If using a custom target, prefer to upstream it to `rustc` if possible, + otherwise open an issue with `cc-rs`: + https://github.com/rust-lang/cc-rs/issues/new +" + ), )) } }