]> git.lizzy.rs Git - rust.git/commitdiff
Disable `.debug_aranges` for all wasm targets
authorAlex Crichton <alex@alexcrichton.com>
Wed, 10 Nov 2021 18:47:00 +0000 (10:47 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 10 Nov 2021 18:47:00 +0000 (10:47 -0800)
This follows from discussion on
https://bugs.llvm.org/show_bug.cgi?id=52442 where it looks like this
section doesn't make sense for wasm targets.

compiler/rustc_codegen_llvm/src/llvm_util.rs
compiler/rustc_target/src/spec/mod.rs
compiler/rustc_target/src/spec/wasm_base.rs

index 35a3d21036a14d1aaa7622f6f04ea50f76a97bfb..3393c9baa28e3889804ea05a13d1af1fcfff261b 100644 (file)
@@ -75,14 +75,8 @@ fn llvm_arg_to_arg_name(full_arg: &str) -> &str {
         if sess.print_llvm_passes() {
             add("-debug-pass=Structure", false);
         }
-        if !sess.opts.debugging_opts.no_generate_arange_section
-            // FIXME: An LLVM bug [1] means that if this option is enabled for
-            // wasm64 then LLVM will crash when generating debuginfo. Assuming
-            // that this gets fixed in LLVM 14 this condition here is a
-            // workaround to work with versions of LLVM 13 and prior.
-            //
-            // [1]: https://bugs.llvm.org/show_bug.cgi?id=52376
-            && (sess.target.arch != "wasm64" || llvm_util::get_version() >= (14, 0, 0))
+        if sess.target.generate_arange_section
+            && !sess.opts.debugging_opts.no_generate_arange_section
         {
             add("-generate-arange-section", false);
         }
index 69b90bf10fe6a131d3c96e6da2b27d1db190ffe1..0771f9985350020449f02ec968c3b4fb78f81b1d 100644 (file)
@@ -1357,6 +1357,9 @@ pub struct TargetOptions {
 
     /// Minimum number of bits in #[repr(C)] enum. Defaults to 32.
     pub c_enum_min_bits: u64,
+
+    /// Whether or not the DWARF `.debug_aranges` section should be generated.
+    pub generate_arange_section: bool,
 }
 
 impl Default for TargetOptions {
@@ -1462,6 +1465,7 @@ fn default() -> TargetOptions {
             supported_sanitizers: SanitizerSet::empty(),
             default_adjusted_cabi: None,
             c_enum_min_bits: 32,
+            generate_arange_section: true,
         }
     }
 }
@@ -2047,6 +2051,7 @@ macro_rules! key {
         key!(supported_sanitizers, SanitizerSet)?;
         key!(default_adjusted_cabi, Option<Abi>)?;
         key!(c_enum_min_bits, u64);
+        key!(generate_arange_section, bool);
 
         if base.is_builtin {
             // This can cause unfortunate ICEs later down the line.
@@ -2286,6 +2291,7 @@ macro_rules! target_option_val {
         target_option_val!(split_debuginfo);
         target_option_val!(supported_sanitizers);
         target_option_val!(c_enum_min_bits);
+        target_option_val!(generate_arange_section);
 
         if let Some(abi) = self.default_adjusted_cabi {
             d.insert("default-adjusted-cabi".to_string(), Abi::name(abi).to_json());
index 4c954a1e567ccb236e95b515fb2c8276be192364..24e9c62516999dc612dfb74f25481603c86fb284 100644 (file)
@@ -128,6 +128,12 @@ pub fn options() -> TargetOptions {
         // gdb scripts don't work on wasm blobs
         emit_debug_gdb_scripts: false,
 
+        // There's more discussion of this at
+        // https://bugs.llvm.org/show_bug.cgi?id=52442 but the general result is
+        // that this isn't useful for wasm and has tricky issues with
+        // representation, so this is disabled.
+        generate_arange_section: false,
+
         ..Default::default()
     }
 }