Skip to content

Commit

Permalink
Emit detailed message when failing on unknown targets
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Dec 4, 2024
1 parent faef3fa commit b3597e8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ enum ErrorKind {
ToolFamilyMacroNotFound,
/// Invalid target.
InvalidTarget,
/// Unknown target.
UnknownTarget,
/// Invalid rustc flag.
InvalidFlag,
#[cfg(feature = "parallel")]
Expand Down
16 changes: 14 additions & 2 deletions src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
"
),
))
}
}
Expand Down

0 comments on commit b3597e8

Please sign in to comment.