@@ -278,10 +278,6 @@ pub struct Config {
278278 /// override this setting.
279279 pub optimize_tests : bool ,
280280
281- /// What panic strategy the target is built with. Unwind supports Abort, but
282- /// not vice versa.
283- pub target_panic : PanicStrategy ,
284-
285281 /// Target system to be tested
286282 pub target : String ,
287283
@@ -426,6 +422,10 @@ impl Config {
426422 * & self . target_cfg ( ) . pointer_width
427423 }
428424
425+ pub fn can_unwind ( & self ) -> bool {
426+ self . target_cfg ( ) . panic == PanicStrategy :: Unwind
427+ }
428+
429429 pub fn has_asm_support ( & self ) -> bool {
430430 static ASM_SUPPORTED_ARCHS : & [ & str ] = & [
431431 "x86" , "x86_64" , "arm" , "aarch64" , "riscv32" ,
@@ -446,6 +446,7 @@ pub struct TargetCfg {
446446 families : Vec < String > ,
447447 pointer_width : u32 ,
448448 endian : Endian ,
449+ panic : PanicStrategy ,
449450}
450451
451452#[ derive( Eq , PartialEq , Clone , Debug ) ]
@@ -481,6 +482,7 @@ impl TargetCfg {
481482 let mut families = Vec :: new ( ) ;
482483 let mut pointer_width = None ;
483484 let mut endian = None ;
485+ let mut panic = None ;
484486 for line in print_cfg. lines ( ) {
485487 if let Some ( ( name, value) ) = line. split_once ( '=' ) {
486488 let value = value. trim_matches ( '"' ) ;
@@ -498,6 +500,13 @@ impl TargetCfg {
498500 s => panic ! ( "unexpected {s}" ) ,
499501 } )
500502 }
503+ "panic" => {
504+ panic = match value {
505+ "abort" => Some ( PanicStrategy :: Abort ) ,
506+ "unwind" => Some ( PanicStrategy :: Unwind ) ,
507+ s => panic ! ( "unexpected {s}" ) ,
508+ }
509+ }
501510 _ => { }
502511 }
503512 }
@@ -510,6 +519,7 @@ impl TargetCfg {
510519 families,
511520 pointer_width : pointer_width. unwrap ( ) ,
512521 endian : endian. unwrap ( ) ,
522+ panic : panic. unwrap ( ) ,
513523 }
514524 }
515525}
0 commit comments