@@ -10,6 +10,7 @@ use std::ffi::OsString;
1010use std:: fmt;
1111use std:: fs;
1212use std:: path:: { Path , PathBuf } ;
13+ use std:: str:: FromStr ;
1314
1415use crate :: cache:: { Interned , INTERNER } ;
1516use crate :: flags:: Flags ;
@@ -65,7 +66,7 @@ pub struct Config {
6566 pub rustc_error_format : Option < String > ,
6667 pub json_output : bool ,
6768 pub test_compare_mode : bool ,
68- pub llvm_libunwind : bool ,
69+ pub llvm_libunwind : Option < LlvmLibunwind > ,
6970
7071 pub on_fail : Option < String > ,
7172 pub stage : u32 ,
@@ -177,6 +178,32 @@ pub struct Config {
177178 pub out : PathBuf ,
178179}
179180
181+ #[ derive( Debug , Clone , Copy , PartialEq ) ]
182+ pub enum LlvmLibunwind {
183+ No ,
184+ InTree ,
185+ System ,
186+ }
187+
188+ impl Default for LlvmLibunwind {
189+ fn default ( ) -> Self {
190+ Self :: No
191+ }
192+ }
193+
194+ impl FromStr for LlvmLibunwind {
195+ type Err = String ;
196+
197+ fn from_str ( value : & str ) -> Result < Self , Self :: Err > {
198+ match value {
199+ "no" => Ok ( Self :: No ) ,
200+ "in-tree" => Ok ( Self :: InTree ) ,
201+ "system" => Ok ( Self :: System ) ,
202+ invalid => Err ( format ! ( "Invalid value '{}' for rust.llvm-libunwind config." , invalid) ) ,
203+ }
204+ }
205+ }
206+
180207#[ derive( Debug , Copy , Clone , Default , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
181208pub struct TargetSelection {
182209 pub triple : Interned < String > ,
@@ -457,7 +484,7 @@ struct Rust {
457484 remap_debuginfo : Option < bool > ,
458485 jemalloc : Option < bool > ,
459486 test_compare_mode : Option < bool > ,
460- llvm_libunwind : Option < bool > ,
487+ llvm_libunwind : Option < String > ,
461488 control_flow_guard : Option < bool > ,
462489 new_symbol_mangling : Option < bool > ,
463490}
@@ -799,7 +826,9 @@ impl Config {
799826 set ( & mut config. rust_rpath , rust. rpath ) ;
800827 set ( & mut config. jemalloc , rust. jemalloc ) ;
801828 set ( & mut config. test_compare_mode , rust. test_compare_mode ) ;
802- set ( & mut config. llvm_libunwind , rust. llvm_libunwind ) ;
829+ config. llvm_libunwind = rust
830+ . llvm_libunwind
831+ . map ( |v| v. parse ( ) . expect ( "failed to parse rust.llvm-libunwind" ) ) ;
803832 set ( & mut config. backtrace , rust. backtrace ) ;
804833 set ( & mut config. channel , rust. channel ) ;
805834 set ( & mut config. rust_dist_src , rust. dist_src ) ;
0 commit comments