Skip to content

Commit ebe0b39

Browse files
committed
Implement stack probes
1 parent 10ceee0 commit ebe0b39

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/gcc_util.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use gccjit::Version;
77
use rustc_codegen_ssa::target_features;
88
use rustc_data_structures::smallvec::{SmallVec, smallvec};
99
use rustc_session::Session;
10-
use rustc_target::spec::{Arch, RelocModel, StackProtector};
10+
use rustc_target::spec::{Arch, RelocModel, StackProbeType, StackProtector};
1111

1212
fn 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

Comments
 (0)