From a5d624d32c9cc04fa8424918c55d7a7bbe520ba1 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 18 Nov 2019 15:05:01 -0800 Subject: [PATCH 1/2] Generate DWARF address ranges for faster lookups This adds a new option `-Zgenerate-arange-section`, enabled by default, corresponding to LLVM's `-generate-arange-section`. This creates a `.debug_aranges` section with DWARF address ranges, which some tools depend on to optimize address lookups (elfutils [22288], [25173]). This only has effect when debuginfo is enabled, and the additional data is small compared to the other debug sections. For example, libstd.so with full debuginfo is about 11MB, with just 61kB in aranges. [22288]: https://sourceware.org/bugzilla/show_bug.cgi?id=22288 [25173]: https://sourceware.org/bugzilla/show_bug.cgi?id=25173 Closes #45246. --- src/librustc/session/config.rs | 2 ++ src/librustc_codegen_llvm/llvm_util.rs | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 4474b008c79..f2e07850aa4 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1331,6 +1331,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "for every macro invocation, print its name and arguments"), debug_macros: bool = (false, parse_bool, [TRACKED], "emit line numbers debug info inside macros"), + generate_arange_section: bool = (true, parse_bool, [UNTRACKED], + "generate DWARF address ranges for faster lookups"), keep_hygiene_data: bool = (false, parse_bool, [UNTRACKED], "don't clear the hygiene data after analysis"), keep_ast: bool = (false, parse_bool, [UNTRACKED], diff --git a/src/librustc_codegen_llvm/llvm_util.rs b/src/librustc_codegen_llvm/llvm_util.rs index 85e0b6d465a..290ca409261 100644 --- a/src/librustc_codegen_llvm/llvm_util.rs +++ b/src/librustc_codegen_llvm/llvm_util.rs @@ -62,6 +62,9 @@ unsafe fn configure_llvm(sess: &Session) { if sess.opts.debugging_opts.disable_instrumentation_preinliner { add("-disable-preinline"); } + if sess.opts.debugging_opts.generate_arange_section { + add("-generate-arange-section"); + } if get_major_version() >= 8 { match sess.opts.debugging_opts.merge_functions .unwrap_or(sess.target.target.options.merge_functions) { From 4c2f1c802c4d582891a8e079949889d2462bbfd2 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 19 Nov 2019 09:13:10 -0800 Subject: [PATCH 2/2] Mark -Zgenerate-arange-section as TRACKED --- src/librustc/session/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index f2e07850aa4..b9b6a5f2342 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1331,7 +1331,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "for every macro invocation, print its name and arguments"), debug_macros: bool = (false, parse_bool, [TRACKED], "emit line numbers debug info inside macros"), - generate_arange_section: bool = (true, parse_bool, [UNTRACKED], + generate_arange_section: bool = (true, parse_bool, [TRACKED], "generate DWARF address ranges for faster lookups"), keep_hygiene_data: bool = (false, parse_bool, [UNTRACKED], "don't clear the hygiene data after analysis"),