Skip to content

Commit 7dc3836

Browse files
committed
Disable .debug_aranges for all wasm targets
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.
1 parent 9a44235 commit 7dc3836

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,8 @@ unsafe fn configure_llvm(sess: &Session) {
7575
if sess.print_llvm_passes() {
7676
add("-debug-pass=Structure", false);
7777
}
78-
if !sess.opts.debugging_opts.no_generate_arange_section
79-
// FIXME: An LLVM bug [1] means that if this option is enabled for
80-
// wasm64 then LLVM will crash when generating debuginfo. Assuming
81-
// that this gets fixed in LLVM 14 this condition here is a
82-
// workaround to work with versions of LLVM 13 and prior.
83-
//
84-
// [1]: https://bugs.llvm.org/show_bug.cgi?id=52376
85-
&& (sess.target.arch != "wasm64" || llvm_util::get_version() >= (14, 0, 0))
78+
if sess.target.generate_arange_section
79+
&& !sess.opts.debugging_opts.no_generate_arange_section
8680
{
8781
add("-generate-arange-section", false);
8882
}

compiler/rustc_target/src/spec/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,9 @@ pub struct TargetOptions {
13571357

13581358
/// Minimum number of bits in #[repr(C)] enum. Defaults to 32.
13591359
pub c_enum_min_bits: u64,
1360+
1361+
/// Whether or not the DWARF `.debug_aranges` section should be generated.
1362+
pub generate_arange_section: bool,
13601363
}
13611364

13621365
impl Default for TargetOptions {
@@ -1462,6 +1465,7 @@ impl Default for TargetOptions {
14621465
supported_sanitizers: SanitizerSet::empty(),
14631466
default_adjusted_cabi: None,
14641467
c_enum_min_bits: 32,
1468+
generate_arange_section: true,
14651469
}
14661470
}
14671471
}
@@ -2047,6 +2051,7 @@ impl Target {
20472051
key!(supported_sanitizers, SanitizerSet)?;
20482052
key!(default_adjusted_cabi, Option<Abi>)?;
20492053
key!(c_enum_min_bits, u64);
2054+
key!(generate_arange_section, bool);
20502055

20512056
if base.is_builtin {
20522057
// This can cause unfortunate ICEs later down the line.
@@ -2286,6 +2291,7 @@ impl ToJson for Target {
22862291
target_option_val!(split_debuginfo);
22872292
target_option_val!(supported_sanitizers);
22882293
target_option_val!(c_enum_min_bits);
2294+
target_option_val!(generate_arange_section);
22892295

22902296
if let Some(abi) = self.default_adjusted_cabi {
22912297
d.insert("default-adjusted-cabi".to_string(), Abi::name(abi).to_json());

compiler/rustc_target/src/spec/wasm_base.rs

+6
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ pub fn options() -> TargetOptions {
128128
// gdb scripts don't work on wasm blobs
129129
emit_debug_gdb_scripts: false,
130130

131+
// There's more discussion of this at
132+
// https://bugs.llvm.org/show_bug.cgi?id=52442 but the general result is
133+
// that this isn't useful for wasm and has tricky issues with
134+
// representation, so this is disabled.
135+
generate_arange_section: false,
136+
131137
..Default::default()
132138
}
133139
}

0 commit comments

Comments
 (0)