diff options
| author | Sebastian Poeplau <poeplau@adacore.com> | 2025-08-01 12:39:50 +0200 |
|---|---|---|
| committer | Sebastian Poeplau <poeplau@adacore.com> | 2025-08-05 10:55:07 +0200 |
| commit | 868bdde25b030e0b71a29a5dbc04a891036e702e (patch) | |
| tree | 4fdbccbcc0f1760014fba2ae3e771f76bb065c04 /compiler/rustc_codegen_llvm/src/base.rs | |
| parent | 0f353363965ebf05e0757f7679c800b39c51a07e (diff) | |
| download | rust-868bdde25b030e0b71a29a5dbc04a891036e702e.tar.gz rust-868bdde25b030e0b71a29a5dbc04a891036e702e.zip | |
Preserve the .debug_gdb_scripts section
Make sure that compiler and linker don't optimize the section's contents away by adding the global holding the data to "llvm.used". The volatile load in the main shim is retained because "llvm.used", which translates to SHF_GNU_RETAIN on ELF targets, requires a reasonably recent linker; emitting the volatile load ensures compatibility with older linkers, at least when libstd is used. Pretty printers in dylib dependencies are now emitted by the main crate instead of the dylib; apart from matching how rlibs are handled, this approach has the advantage that `omit_gdb_pretty_printer_section` keeps working with dylib dependencies.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/base.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/base.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler/rustc_codegen_llvm/src/base.rs b/compiler/rustc_codegen_llvm/src/base.rs index 5dda836988c..d7da03bf490 100644 --- a/compiler/rustc_codegen_llvm/src/base.rs +++ b/compiler/rustc_codegen_llvm/src/base.rs @@ -109,11 +109,16 @@ pub(crate) fn compile_codegen_unit( } // Finalize code coverage by injecting the coverage map. Note, the coverage map will - // also be added to the `llvm.compiler.used` variable, created next. + // also be added to the `llvm.compiler.used` variable, created below. if cx.sess().instrument_coverage() { cx.coverageinfo_finalize(); } + // Finalize debuginfo. This adds to `llvm.used`, created below. + if cx.sess().opts.debuginfo != DebugInfo::None { + cx.debuginfo_finalize(); + } + // Create the llvm.used and llvm.compiler.used variables. if !cx.used_statics.is_empty() { cx.create_used_variable_impl(c"llvm.used", &cx.used_statics); @@ -130,11 +135,6 @@ pub(crate) fn compile_codegen_unit( llvm::LLVMDeleteGlobal(old_g); } } - - // Finalize debuginfo - if cx.sess().opts.debuginfo != DebugInfo::None { - cx.debuginfo_finalize(); - } } ModuleCodegen::new_regular(cgu_name.to_string(), llvm_module) |
