Skip to content

Commit

Permalink
Rollup merge of rust-lang#49728 - japaric:no-debug_gdb_scripts, r=ale…
Browse files Browse the repository at this point in the history
…xcrichton

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
  • Loading branch information
kennytm authored Apr 7, 2018
2 parents 496f026 + 1eed662 commit c3eb990
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/librustc_back/target/apple_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub fn opts() -> TargetOptions {
exe_allocation_crate: super::maybe_jemalloc(),
has_elf_tls: version >= (10, 7),
abi_return_struct_as_int: true,
emit_debug_gdb_scripts: false,
.. Default::default()
}
}
6 changes: 6 additions & 0 deletions src/librustc_back/target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,9 @@ pub struct TargetOptions {

/// Whether or not bitcode is embedded in object files
pub embed_bitcode: bool,

/// Whether a .debug_gdb_scripts section will be added to the output object file
pub emit_debug_gdb_scripts: bool,
}

impl Default for TargetOptions {
Expand Down Expand Up @@ -550,6 +553,7 @@ impl Default for TargetOptions {
codegen_backend: "llvm".to_string(),
default_hidden_visibility: false,
embed_bitcode: false,
emit_debug_gdb_scripts: true,
}
}
}
Expand Down Expand Up @@ -799,6 +803,7 @@ impl Target {
key!(codegen_backend);
key!(default_hidden_visibility, bool);
key!(embed_bitcode, bool);
key!(emit_debug_gdb_scripts, bool);

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

if default.abi_blacklist != self.options.abi_blacklist {
d.insert("abi-blacklist".to_string(), self.options.abi_blacklist.iter()
Expand Down
3 changes: 3 additions & 0 deletions src/librustc_back/target/msp430_none_elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ pub fn target() -> TargetResult {
// too much overhead for such small target.
trap_unreachable: false,

// See the thumb_base.rs file for an explanation of this value
emit_debug_gdb_scripts: false,

.. Default::default( )
}
})
Expand Down
7 changes: 7 additions & 0 deletions src/librustc_back/target/thumb_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ pub fn opts() -> TargetOptions {
// costs it involves.
relocation_model: "static".to_string(),
abi_blacklist: super::arm_base::abi_blacklist(),
// When this section is added a volatile load to its start address is also generated. This
// volatile load is a footgun as it can end up loading an invalid memory address, depending
// on how the user set up their linker scripts. This section adds pretty printer for stuff
// like std::Vec, which is not that used in no-std context, so it's best to left it out
// until we figure a way to add the pretty printers without requiring a volatile load cf.
// rust-lang/rust#44993.
emit_debug_gdb_scripts: false,
.. Default::default()
}
}
1 change: 1 addition & 0 deletions src/librustc_back/target/windows_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ pub fn opts() -> TargetOptions {
],
custom_unwind_resume: true,
abi_return_struct_as_int: true,
emit_debug_gdb_scripts: false,

.. Default::default()
}
Expand Down
1 change: 1 addition & 0 deletions src/librustc_back/target/windows_msvc_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub fn opts() -> TargetOptions {
crt_static_allows_dylibs: true,
crt_static_respected: true,
abi_return_struct_as_int: true,
emit_debug_gdb_scripts: false,

.. Default::default()
}
Expand Down
5 changes: 2 additions & 3 deletions src/librustc_trans/debuginfo/gdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ pub fn needs_gdb_debug_scripts_section(cx: &CodegenCx) -> bool {
"omit_gdb_pretty_printer_section");

!omit_gdb_pretty_printer_section &&
!cx.sess().target.target.options.is_like_osx &&
!cx.sess().target.target.options.is_like_windows &&
cx.sess().opts.debuginfo != NoDebugInfo
cx.sess().opts.debuginfo != NoDebugInfo &&
cx.sess().target.target.options.emit_debug_gdb_scripts
}

0 comments on commit c3eb990

Please sign in to comment.