Skip to content

Commit c3eb990

Browse files
authored
Rollup merge of rust-lang#49728 - japaric:no-debug_gdb_scripts, r=alexcrichton
add emit_debug_gdb_scripts target option and .. set it to false for no-std targets like ARM Cortex-M and MSP430. For the rationale of this change see the comment in thumb_base.rs this is a temporary workaround until rust-lang#44993 is implemented r? @alexcrichton or @michaelwoerister
2 parents 496f026 + 1eed662 commit c3eb990

File tree

7 files changed

+21
-3
lines changed

7 files changed

+21
-3
lines changed

src/librustc_back/target/apple_base.rs

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pub fn opts() -> TargetOptions {
4747
exe_allocation_crate: super::maybe_jemalloc(),
4848
has_elf_tls: version >= (10, 7),
4949
abi_return_struct_as_int: true,
50+
emit_debug_gdb_scripts: false,
5051
.. Default::default()
5152
}
5253
}

src/librustc_back/target/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,9 @@ pub struct TargetOptions {
478478

479479
/// Whether or not bitcode is embedded in object files
480480
pub embed_bitcode: bool,
481+
482+
/// Whether a .debug_gdb_scripts section will be added to the output object file
483+
pub emit_debug_gdb_scripts: bool,
481484
}
482485

483486
impl Default for TargetOptions {
@@ -550,6 +553,7 @@ impl Default for TargetOptions {
550553
codegen_backend: "llvm".to_string(),
551554
default_hidden_visibility: false,
552555
embed_bitcode: false,
556+
emit_debug_gdb_scripts: true,
553557
}
554558
}
555559
}
@@ -799,6 +803,7 @@ impl Target {
799803
key!(codegen_backend);
800804
key!(default_hidden_visibility, bool);
801805
key!(embed_bitcode, bool);
806+
key!(emit_debug_gdb_scripts, bool);
802807

803808
if let Some(array) = obj.find("abi-blacklist").and_then(Json::as_array) {
804809
for name in array.iter().filter_map(|abi| abi.as_string()) {
@@ -1002,6 +1007,7 @@ impl ToJson for Target {
10021007
target_option_val!(codegen_backend);
10031008
target_option_val!(default_hidden_visibility);
10041009
target_option_val!(embed_bitcode);
1010+
target_option_val!(emit_debug_gdb_scripts);
10051011

10061012
if default.abi_blacklist != self.options.abi_blacklist {
10071013
d.insert("abi-blacklist".to_string(), self.options.abi_blacklist.iter()

src/librustc_back/target/msp430_none_elf.rs

+3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ pub fn target() -> TargetResult {
5959
// too much overhead for such small target.
6060
trap_unreachable: false,
6161

62+
// See the thumb_base.rs file for an explanation of this value
63+
emit_debug_gdb_scripts: false,
64+
6265
.. Default::default( )
6366
}
6467
})

src/librustc_back/target/thumb_base.rs

+7
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ pub fn opts() -> TargetOptions {
5353
// costs it involves.
5454
relocation_model: "static".to_string(),
5555
abi_blacklist: super::arm_base::abi_blacklist(),
56+
// When this section is added a volatile load to its start address is also generated. This
57+
// volatile load is a footgun as it can end up loading an invalid memory address, depending
58+
// on how the user set up their linker scripts. This section adds pretty printer for stuff
59+
// like std::Vec, which is not that used in no-std context, so it's best to left it out
60+
// until we figure a way to add the pretty printers without requiring a volatile load cf.
61+
// rust-lang/rust#44993.
62+
emit_debug_gdb_scripts: false,
5663
.. Default::default()
5764
}
5865
}

src/librustc_back/target/windows_base.rs

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ pub fn opts() -> TargetOptions {
102102
],
103103
custom_unwind_resume: true,
104104
abi_return_struct_as_int: true,
105+
emit_debug_gdb_scripts: false,
105106

106107
.. Default::default()
107108
}

src/librustc_back/target/windows_msvc_base.rs

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub fn opts() -> TargetOptions {
3434
crt_static_allows_dylibs: true,
3535
crt_static_respected: true,
3636
abi_return_struct_as_int: true,
37+
emit_debug_gdb_scripts: false,
3738

3839
.. Default::default()
3940
}

src/librustc_trans/debuginfo/gdb.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ pub fn needs_gdb_debug_scripts_section(cx: &CodegenCx) -> bool {
8383
"omit_gdb_pretty_printer_section");
8484

8585
!omit_gdb_pretty_printer_section &&
86-
!cx.sess().target.target.options.is_like_osx &&
87-
!cx.sess().target.target.options.is_like_windows &&
88-
cx.sess().opts.debuginfo != NoDebugInfo
86+
cx.sess().opts.debuginfo != NoDebugInfo &&
87+
cx.sess().target.target.options.emit_debug_gdb_scripts
8988
}

0 commit comments

Comments
 (0)