diff --git a/src/librustc/driver/config.rs b/src/librustc/driver/config.rs index 345877d9ab6c4..3a59c2bbcc350 100644 --- a/src/librustc/driver/config.rs +++ b/src/librustc/driver/config.rs @@ -332,6 +332,8 @@ cgoptions!( "prefer dynamic linking to static linking"), no_integrated_as: bool = (false, parse_bool, "use an external assembler rather than LLVM's integrated one"), + no_redzone: bool = (false, parse_bool, + "disable the use of the redzone"), relocation_model: String = ("pic".to_string(), parse_string, "choose the relocation model to use (llc -relocation-model for details)"), metadata: Vec = (Vec::new(), parse_list, diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 6bcc9b9b745b7..3ca188cf2813a 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -193,6 +193,14 @@ fn decl_fn(ccx: &CrateContext, name: &str, cc: llvm::CallConv, _ => {} } + if ccx.tcx.sess.opts.cg.no_redzone { + unsafe { + llvm::LLVMAddFunctionAttribute(llfn, + llvm::FunctionIndex as c_uint, + llvm::NoRedZoneAttribute as uint64_t) + } + } + llvm::SetFunctionCallConv(llfn, cc); // Function addresses in Rust are never significant, allowing functions to be merged. llvm::SetUnnamedAddr(llfn, true);