@@ -17,6 +17,7 @@ pub(crate) fn build_sysroot(
1717 bootstrap_host_compiler : & Compiler ,
1818 rustup_toolchain_name : Option < & str > ,
1919 target_triple : String ,
20+ panic_unwind_support : bool ,
2021) -> Compiler {
2122 let _guard = LogGroup :: guard ( "Build sysroot" ) ;
2223
@@ -52,6 +53,9 @@ pub(crate) fn build_sysroot(
5253 . arg ( "-o" )
5354 . arg ( & wrapper_path)
5455 . arg ( "-Cstrip=debuginfo" ) ;
56+ if panic_unwind_support {
57+ build_cargo_wrapper_cmd. arg ( "--cfg" ) . arg ( "support_panic_unwind" ) ;
58+ }
5559 if let Some ( rustup_toolchain_name) = & rustup_toolchain_name {
5660 build_cargo_wrapper_cmd
5761 . env ( "TOOLCHAIN_NAME" , rustup_toolchain_name)
@@ -77,6 +81,7 @@ pub(crate) fn build_sysroot(
7781 bootstrap_host_compiler. clone ( ) ,
7882 & cg_clif_dylib_path,
7983 sysroot_kind,
84+ panic_unwind_support,
8085 ) ;
8186 host. install_into_sysroot ( dist_dir) ;
8287
@@ -91,6 +96,7 @@ pub(crate) fn build_sysroot(
9196 } ,
9297 & cg_clif_dylib_path,
9398 sysroot_kind,
99+ panic_unwind_support,
94100 )
95101 . install_into_sysroot ( dist_dir) ;
96102 }
@@ -141,12 +147,15 @@ fn build_sysroot_for_triple(
141147 compiler : Compiler ,
142148 cg_clif_dylib_path : & CodegenBackend ,
143149 sysroot_kind : SysrootKind ,
150+ panic_unwind_support : bool ,
144151) -> SysrootTarget {
145152 match sysroot_kind {
146153 SysrootKind :: None => build_rtstartup ( dirs, & compiler)
147154 . unwrap_or ( SysrootTarget { triple : compiler. triple , libs : vec ! [ ] } ) ,
148155 SysrootKind :: Llvm => build_llvm_sysroot_for_triple ( compiler) ,
149- SysrootKind :: Clif => build_clif_sysroot_for_triple ( dirs, compiler, cg_clif_dylib_path) ,
156+ SysrootKind :: Clif => {
157+ build_clif_sysroot_for_triple ( dirs, compiler, cg_clif_dylib_path, panic_unwind_support)
158+ }
150159 }
151160}
152161
@@ -188,6 +197,7 @@ fn build_clif_sysroot_for_triple(
188197 dirs : & Dirs ,
189198 mut compiler : Compiler ,
190199 cg_clif_dylib_path : & CodegenBackend ,
200+ panic_unwind_support : bool ,
191201) -> SysrootTarget {
192202 let mut target_libs = SysrootTarget { triple : compiler. triple . clone ( ) , libs : vec ! [ ] } ;
193203
@@ -206,7 +216,10 @@ fn build_clif_sysroot_for_triple(
206216 }
207217
208218 // Build sysroot
209- let mut rustflags = vec ! [ "-Zforce-unstable-if-unmarked" . to_owned( ) , "-Cpanic=abort" . to_owned( ) ] ;
219+ let mut rustflags = vec ! [ "-Zforce-unstable-if-unmarked" . to_owned( ) ] ;
220+ if !panic_unwind_support {
221+ rustflags. push ( "-Cpanic=abort" . to_owned ( ) ) ;
222+ }
210223 match cg_clif_dylib_path {
211224 CodegenBackend :: Local ( path) => {
212225 rustflags. push ( format ! ( "-Zcodegen-backend={}" , path. to_str( ) . unwrap( ) ) ) ;
0 commit comments