@@ -7,7 +7,7 @@ use gccjit::Version;
77use rustc_codegen_ssa:: target_features;
88use rustc_data_structures:: smallvec:: { SmallVec , smallvec} ;
99use rustc_session:: Session ;
10- use rustc_target:: spec:: { Arch , RelocModel , StackProtector } ;
10+ use rustc_target:: spec:: { Arch , RelocModel , StackProbeType , StackProtector } ;
1111
1212fn gcc_features_by_flags ( sess : & Session , features : & mut Vec < String > ) {
1313 target_features:: retpoline_features_by_flags ( sess, features) ;
@@ -211,6 +211,15 @@ pub fn new_context<'gcc>(sess: &Session) -> Context<'gcc> {
211211 StackProtector :: None => ( ) ,
212212 }
213213
214+ match sess. target . stack_probes {
215+ StackProbeType :: None => ( ) ,
216+ StackProbeType :: Inline | StackProbeType :: InlineOrCall { .. } => {
217+ context. add_command_line_option ( "-fstack-clash-protection" )
218+ }
219+ // FIXME(antoyo): We should define the stack probe symbol to be __rust_probestack, but it seems GCC cannot do that.
220+ StackProbeType :: Call => ( ) ,
221+ } ;
222+
214223 add_pic_option ( & context, sess. relocation_model ( ) ) ;
215224
216225 let target_cpu = target_cpu ( sess) ;
0 commit comments