1
Fork 0

Implement support for DWARF version 5.

DWARF version 5 brings a number of improvements over version 4. Quoting from
the announcement [1]:

> Version 5 incorporates improvements in many areas: better data compression,
> separation of debugging data from executable files, improved description of
> macros and source files, faster searching for symbols, improved debugging
> optimized code, as well as numerous improvements in functionality and
> performance.

On platforms where DWARF version 5 is supported (Linux, primarily), this commit
adds support for it behind a new `-Z dwarf-version=5` flag.

[1]: https://dwarfstd.org/Public_Review.php
This commit is contained in:
Patrick Walton 2022-06-20 16:26:51 -07:00
parent 45263fc66d
commit 1e0ad0c1d4
13 changed files with 59 additions and 21 deletions

View file

@ -3,7 +3,7 @@ use crate::spec::TargetOptions;
pub fn opts() -> TargetOptions {
let mut base = super::linux_base::opts();
base.os = "android".into();
base.dwarf_version = Some(2);
base.default_dwarf_version = 2;
base.position_independent_executables = true;
base.has_thread_local = false;
// This is for backward compatibility, see https://github.com/rust-lang/rust/issues/49867

View file

@ -28,7 +28,7 @@ pub fn opts(os: &'static str) -> TargetOptions {
executables: true,
families: cvs!["unix"],
is_like_osx: true,
dwarf_version: Some(2),
default_dwarf_version: 2,
frame_pointer: FramePointer::Always,
has_rpath: true,
dll_suffix: ".dylib".into(),

View file

@ -9,7 +9,7 @@ pub fn opts() -> TargetOptions {
has_rpath: true,
position_independent_executables: true,
relro_level: RelroLevel::Full,
dwarf_version: Some(2),
default_dwarf_version: 2,
..Default::default()
}
}

View file

@ -10,7 +10,7 @@ pub fn opts() -> TargetOptions {
position_independent_executables: true,
relro_level: RelroLevel::Full,
abi_return_struct_as_int: true,
dwarf_version: Some(2),
default_dwarf_version: 2,
..Default::default()
}
}

View file

@ -1275,9 +1275,9 @@ pub struct TargetOptions {
pub is_like_msvc: bool,
/// Whether a target toolchain is like WASM.
pub is_like_wasm: bool,
/// Version of DWARF to use if not using the default.
/// Default supported version of DWARF on this platform.
/// Useful because some platforms (osx, bsd) only want up to DWARF2.
pub dwarf_version: Option<u32>,
pub default_dwarf_version: u32,
/// Whether the linker support GNU-like arguments such as -O. Defaults to true.
pub linker_is_gnu: bool,
/// The MinGW toolchain has a known issue that prevents it from correctly
@ -1539,7 +1539,7 @@ impl Default for TargetOptions {
is_like_windows: false,
is_like_msvc: false,
is_like_wasm: false,
dwarf_version: None,
default_dwarf_version: 4,
linker_is_gnu: true,
allows_weak_linkage: true,
has_rpath: false,
@ -1778,13 +1778,13 @@ impl Target {
base.$key_name = s;
}
} );
($key_name:ident, Option<u32>) => ( {
($key_name:ident, u32) => ( {
let name = (stringify!($key_name)).replace("_", "-");
if let Some(s) = obj.remove(&name).and_then(|b| b.as_u64()) {
if s < 1 || s > 5 {
return Err("Not a valid DWARF version number".into());
}
base.$key_name = Some(s as u32);
base.$key_name = s as u32;
}
} );
($key_name:ident, Option<u64>) => ( {
@ -2143,7 +2143,7 @@ impl Target {
key!(is_like_windows, bool);
key!(is_like_msvc, bool);
key!(is_like_wasm, bool);
key!(dwarf_version, Option<u32>);
key!(default_dwarf_version, u32);
key!(linker_is_gnu, bool);
key!(allows_weak_linkage, bool);
key!(has_rpath, bool);
@ -2387,7 +2387,7 @@ impl ToJson for Target {
target_option_val!(is_like_windows);
target_option_val!(is_like_msvc);
target_option_val!(is_like_wasm);
target_option_val!(dwarf_version);
target_option_val!(default_dwarf_version);
target_option_val!(linker_is_gnu);
target_option_val!(allows_weak_linkage);
target_option_val!(has_rpath);

View file

@ -11,7 +11,7 @@ pub fn opts() -> TargetOptions {
position_independent_executables: true,
relro_level: RelroLevel::Full,
use_ctors_section: true,
dwarf_version: Some(2),
default_dwarf_version: 2,
..Default::default()
}
}

View file

@ -11,7 +11,7 @@ pub fn opts() -> TargetOptions {
position_independent_executables: true,
frame_pointer: FramePointer::Always, // FIXME 43575: should be MayOmit...
relro_level: RelroLevel::Full,
dwarf_version: Some(2),
default_dwarf_version: 2,
..Default::default()
}
}