From 3c0907ce51f51bbedeb63b482041e4a8e1239364 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 13 Sep 2018 19:43:15 +0200 Subject: [PATCH] add -Z emit-stack-sizes --- src/librustc/session/config.rs | 2 ++ src/librustc_codegen_llvm/back/write.rs | 2 ++ src/librustc_codegen_llvm/llvm/ffi.rs | 3 ++- src/rustllvm/PassWrapper.cpp | 5 ++++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 8fa15d48a5d..eb779e6382f 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1385,6 +1385,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "run the self profiler"), profile_json: bool = (false, parse_bool, [UNTRACKED], "output a json file with profiler results"), + emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED], + "emits a section containing stack size metadata"), } pub fn default_lib_output() -> CrateType { diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs index 447b505e79c..02ef690b942 100644 --- a/src/librustc_codegen_llvm/back/write.rs +++ b/src/librustc_codegen_llvm/back/write.rs @@ -196,6 +196,7 @@ pub fn target_machine_factory(sess: &Session, find_features: bool) let features = CString::new(features).unwrap(); let is_pie_binary = !find_features && is_pie_binary(sess); let trap_unreachable = sess.target.target.options.trap_unreachable; + let emit_stack_size_section = sess.opts.debugging_opts.emit_stack_sizes; let asm_comments = sess.asm_comments(); @@ -213,6 +214,7 @@ pub fn target_machine_factory(sess: &Session, find_features: bool) trap_unreachable, singlethread, asm_comments, + emit_stack_size_section, ) }; diff --git a/src/librustc_codegen_llvm/llvm/ffi.rs b/src/librustc_codegen_llvm/llvm/ffi.rs index a5f4137c62b..845f2fa9f45 100644 --- a/src/librustc_codegen_llvm/llvm/ffi.rs +++ b/src/librustc_codegen_llvm/llvm/ffi.rs @@ -1460,7 +1460,8 @@ extern "C" { DataSections: bool, TrapUnreachable: bool, Singlethread: bool, - AsmComments: bool) + AsmComments: bool, + EmitStackSizeSection: bool) -> Option<&'static mut TargetMachine>; pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine); pub fn LLVMRustAddAnalysisPasses(T: &'a TargetMachine, PM: &PassManager<'a>, M: &'a Module); diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp index 5c4bb61781e..06f75d981e3 100644 --- a/src/rustllvm/PassWrapper.cpp +++ b/src/rustllvm/PassWrapper.cpp @@ -373,7 +373,8 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine( bool DataSections, bool TrapUnreachable, bool Singlethread, - bool AsmComments) { + bool AsmComments, + bool EmitStackSizeSection) { auto OptLevel = fromRust(RustOptLevel); auto RM = fromRust(RustReloc); @@ -411,6 +412,8 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine( } #if LLVM_VERSION_GE(6, 0) + Options.EmitStackSizeSection = EmitStackSizeSection; + Optional CM; #else CodeModel::Model CM = CodeModel::Model::Default;