Skip to content

Commit ea08bdf

Browse files
committed
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
1 parent db4235c commit ea08bdf

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

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_trans/debuginfo/gdb.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,6 @@ pub fn needs_gdb_debug_scripts_section(cx: &CodegenCx) -> bool {
8585
!omit_gdb_pretty_printer_section &&
8686
!cx.sess().target.target.options.is_like_osx &&
8787
!cx.sess().target.target.options.is_like_windows &&
88-
cx.sess().opts.debuginfo != NoDebugInfo
88+
cx.sess().opts.debuginfo != NoDebugInfo &&
89+
cx.sess().target.target.options.emit_debug_gdb_scripts
8990
}

0 commit comments

Comments
 (0)