@@ -450,9 +450,12 @@ impl Build {
450
450
// FIXME: the guard against msvc shouldn't need to be here
451
451
if !target. contains ( "msvc" ) {
452
452
cargo. env ( format ! ( "CC_{}" , target) , self . cc ( target) )
453
- . env ( format ! ( "CXX_{}" , target) , self . cxx ( target) )
454
453
. env ( format ! ( "AR_{}" , target) , self . ar ( target) . unwrap ( ) ) // only msvc is None
455
454
. env ( format ! ( "CFLAGS_{}" , target) , self . cflags ( target) . join ( " " ) ) ;
455
+
456
+ if let Ok ( cxx) = self . cxx ( target) {
457
+ cargo. env ( format ! ( "CXX_{}" , target) , cxx) ;
458
+ }
456
459
}
457
460
458
461
if self . config . extended && compiler. is_final_stage ( self ) {
@@ -839,13 +842,13 @@ impl Build {
839
842
self . cc [ target] . 1 . as_ref ( ) . map ( |p| & * * p)
840
843
}
841
844
842
- /// Returns the path to the C++ compiler for the target specified, may panic
843
- /// if no C++ compiler was configured for the target.
844
- fn cxx ( & self , target : & str ) -> & Path {
845
+ /// Returns the path to the C++ compiler for the target specified.
846
+ fn cxx ( & self , target : & str ) -> Result < & Path , String > {
845
847
match self . cxx . get ( target) {
846
- Some ( p) => p. path ( ) ,
847
- None => panic ! ( "\n \n target `{}` is not configured as a host,
848
- only as a target\n \n " , target) ,
848
+ Some ( p) => Ok ( p. path ( ) ) ,
849
+ None => Err ( format ! (
850
+ "target `{}` is not configured as a host, only as a target" ,
851
+ target) )
849
852
}
850
853
}
851
854
0 commit comments