@@ -3,7 +3,6 @@ use std::env;
33use std:: time:: Instant ;
44
55use gccjit:: {
6- Context ,
76 FunctionType ,
87 GlobalKind ,
98} ;
@@ -18,8 +17,9 @@ use rustc_codegen_ssa::mono_item::MonoItemExt;
1817use rustc_codegen_ssa:: traits:: DebugInfoMethods ;
1918use rustc_session:: config:: DebugInfo ;
2019use rustc_span:: Symbol ;
20+ use rustc_target:: spec:: PanicStrategy ;
2121
22- use crate :: { LockedTargetInfo , gcc_util} ;
22+ use crate :: { LockedTargetInfo , gcc_util, new_context } ;
2323use crate :: GccContext ;
2424use crate :: builder:: Builder ;
2525use crate :: context:: CodegenCx ;
@@ -88,20 +88,18 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol, target_info: Lock
8888 fn module_codegen ( tcx : TyCtxt < ' _ > , ( cgu_name, target_info) : ( Symbol , LockedTargetInfo ) ) -> ModuleCodegen < GccContext > {
8989 let cgu = tcx. codegen_unit ( cgu_name) ;
9090 // Instantiate monomorphizations without filling out definitions yet...
91- let context = Context :: default ( ) ;
91+ let context = new_context ( & tcx ) ;
9292
93- context. add_command_line_option ( "-fexceptions" ) ;
94- context. add_driver_option ( "-fexceptions" ) ;
93+ if tcx. sess . panic_strategy ( ) == PanicStrategy :: Unwind {
94+ context. add_command_line_option ( "-fexceptions" ) ;
95+ context. add_driver_option ( "-fexceptions" ) ;
96+ }
9597
9698 let disabled_features: HashSet < _ > = tcx. sess . opts . cg . target_feature . split ( ',' )
9799 . filter ( |feature| feature. starts_with ( '-' ) )
98100 . map ( |string| & string[ 1 ..] )
99101 . collect ( ) ;
100102
101- if tcx. sess . target . arch == "x86" || tcx. sess . target . arch == "x86_64" {
102- context. add_command_line_option ( "-masm=intel" ) ;
103- }
104-
105103 if !disabled_features. contains ( "avx" ) && tcx. sess . target . arch == "x86_64" {
106104 // NOTE: we always enable AVX because the equivalent of llvm.x86.sse2.cmp.pd in GCC for
107105 // SSE2 is multiple builtins, so we use the AVX __builtin_ia32_cmppd instead.
0 commit comments