@@ -130,7 +130,7 @@ pub struct Config {
130130 pub rust_debuginfo_level_std : u32 ,
131131 pub rust_debuginfo_level_tools : u32 ,
132132 pub rust_debuginfo_level_tests : u32 ,
133- pub rust_run_dsymutil : bool ,
133+ pub rust_split_debuginfo : SplitDebuginfo ,
134134 pub rust_rpath : bool ,
135135 pub rustc_parallel : bool ,
136136 pub rustc_default_linker : Option < String > ,
@@ -221,6 +221,46 @@ impl FromStr for LlvmLibunwind {
221221 }
222222}
223223
224+ #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
225+ pub enum SplitDebuginfo {
226+ Packed ,
227+ Unpacked ,
228+ Off ,
229+ }
230+
231+ impl Default for SplitDebuginfo {
232+ fn default ( ) -> Self {
233+ SplitDebuginfo :: Off
234+ }
235+ }
236+
237+ impl std:: str:: FromStr for SplitDebuginfo {
238+ type Err = ( ) ;
239+
240+ fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
241+ match s {
242+ "packed" => Ok ( SplitDebuginfo :: Packed ) ,
243+ "unpacked" => Ok ( SplitDebuginfo :: Unpacked ) ,
244+ "off" => Ok ( SplitDebuginfo :: Off ) ,
245+ _ => Err ( ( ) ) ,
246+ }
247+ }
248+ }
249+
250+ impl SplitDebuginfo {
251+ /// Returns the default `-Csplit-debuginfo` value for the current target. See the comment for
252+ /// `rust.split-debuginfo` in `config.toml.example`.
253+ fn default_for_platform ( target : & str ) -> Self {
254+ if target. contains ( "apple" ) {
255+ SplitDebuginfo :: Unpacked
256+ } else if target. contains ( "windows" ) {
257+ SplitDebuginfo :: Packed
258+ } else {
259+ SplitDebuginfo :: Unpacked
260+ }
261+ }
262+ }
263+
224264#[ derive( Copy , Clone , Default , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
225265pub struct TargetSelection {
226266 pub triple : Interned < String > ,
@@ -586,6 +626,7 @@ define_config! {
586626 debuginfo_level_std: Option <u32 > = "debuginfo-level-std" ,
587627 debuginfo_level_tools: Option <u32 > = "debuginfo-level-tools" ,
588628 debuginfo_level_tests: Option <u32 > = "debuginfo-level-tests" ,
629+ split_debuginfo: Option <String > = "split-debuginfo" ,
589630 run_dsymutil: Option <bool > = "run-dsymutil" ,
590631 backtrace: Option <bool > = "backtrace" ,
591632 incremental: Option <bool > = "incremental" ,
@@ -992,7 +1033,12 @@ impl Config {
9921033 debuginfo_level_std = rust. debuginfo_level_std ;
9931034 debuginfo_level_tools = rust. debuginfo_level_tools ;
9941035 debuginfo_level_tests = rust. debuginfo_level_tests ;
995- config. rust_run_dsymutil = rust. run_dsymutil . unwrap_or ( false ) ;
1036+ config. rust_split_debuginfo = rust
1037+ . split_debuginfo
1038+ . as_deref ( )
1039+ . map ( SplitDebuginfo :: from_str)
1040+ . map ( |v| v. expect ( "invalid value for rust.split_debuginfo" ) )
1041+ . unwrap_or ( SplitDebuginfo :: default_for_platform ( & config. build . triple ) ) ;
9961042 optimize = rust. optimize ;
9971043 ignore_git = rust. ignore_git ;
9981044 config. rust_new_symbol_mangling = rust. new_symbol_mangling ;
0 commit comments