@@ -10,6 +10,7 @@ use std::ffi::OsString;
10
10
use std:: fmt;
11
11
use std:: fs;
12
12
use std:: path:: { Path , PathBuf } ;
13
+ use std:: str:: FromStr ;
13
14
14
15
use crate :: cache:: { Interned , INTERNER } ;
15
16
use crate :: flags:: Flags ;
@@ -65,7 +66,7 @@ pub struct Config {
65
66
pub rustc_error_format : Option < String > ,
66
67
pub json_output : bool ,
67
68
pub test_compare_mode : bool ,
68
- pub llvm_libunwind : bool ,
69
+ pub llvm_libunwind : Option < LlvmLibunwind > ,
69
70
70
71
pub on_fail : Option < String > ,
71
72
pub stage : u32 ,
@@ -177,6 +178,32 @@ pub struct Config {
177
178
pub out : PathBuf ,
178
179
}
179
180
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
+
180
207
#[ derive( Debug , Copy , Clone , Default , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
181
208
pub struct TargetSelection {
182
209
pub triple : Interned < String > ,
@@ -457,7 +484,7 @@ struct Rust {
457
484
remap_debuginfo : Option < bool > ,
458
485
jemalloc : Option < bool > ,
459
486
test_compare_mode : Option < bool > ,
460
- llvm_libunwind : Option < bool > ,
487
+ llvm_libunwind : Option < String > ,
461
488
control_flow_guard : Option < bool > ,
462
489
new_symbol_mangling : Option < bool > ,
463
490
}
@@ -799,7 +826,9 @@ impl Config {
799
826
set ( & mut config. rust_rpath , rust. rpath ) ;
800
827
set ( & mut config. jemalloc , rust. jemalloc ) ;
801
828
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" ) ) ;
803
832
set ( & mut config. backtrace , rust. backtrace ) ;
804
833
set ( & mut config. channel , rust. channel ) ;
805
834
set ( & mut config. rust_dist_src , rust. dist_src ) ;
0 commit comments