Skip to content

Commit 6d78620

Browse files
committed
rustbuild: Nicer error for host builds of targets
If a triple is configured only as a target, not a host, then trying to build that triple with host artifacts would cause a panic. Fail a little nicer instead. Closes #36268
1 parent fa9d8cc commit 6d78620

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/bootstrap/lib.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,11 @@ impl Build {
959959
/// Returns the path to the C++ compiler for the target specified, may panic
960960
/// if no C++ compiler was configured for the target.
961961
fn cxx(&self, target: &str) -> &Path {
962-
self.cxx[target].path()
962+
match self.cxx.get(target) {
963+
Some(p) => p.path(),
964+
None => panic!("\n\ntarget `{}` is not configured as a host,
965+
only as a target\n\n", target),
966+
}
963967
}
964968

965969
/// Returns flags to pass to the compiler to generate code for `target`.

0 commit comments

Comments
 (0)