Skip to content

Commit e216915

Browse files
committed
Stabilize -Zdwarf-version as -Cdwarf-version
1 parent 2da29db commit e216915

File tree

13 files changed

+42
-32
lines changed

13 files changed

+42
-32
lines changed

Diff for: compiler/rustc_interface/src/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ fn test_codegen_options_tracking_hash() {
614614
tracked!(control_flow_guard, CFGuard::Checks);
615615
tracked!(debug_assertions, Some(true));
616616
tracked!(debuginfo, DebugInfo::Limited);
617+
tracked!(dwarf_version, Some(5));
617618
tracked!(embed_bitcode, false);
618619
tracked!(force_frame_pointers, FramePointer::Always);
619620
tracked!(force_unwind_tables, Some(true));

Diff for: compiler/rustc_session/src/options.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1956,6 +1956,9 @@ options! {
19561956
"allow the linker to link its default libraries (default: no)"),
19571957
dlltool: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
19581958
"import library generation tool (ignored except when targeting windows-gnu)"),
1959+
#[rustc_lint_opt_deny_field_access("use `Session::dwarf_version` instead of this field")]
1960+
dwarf_version: Option<u32> = (None, parse_opt_number, [TRACKED],
1961+
"version of DWARF debug information to emit (default: 2 or 4, depending on platform)"),
19591962
embed_bitcode: bool = (true, parse_bool, [TRACKED],
19601963
"emit bitcode in rlibs (default: yes)"),
19611964
extra_filename: String = (String::new(), parse_string, [UNTRACKED],

Diff for: compiler/rustc_session/src/session.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,11 @@ impl Session {
764764

765765
/// Returns the DWARF version passed on the CLI or the default for the target.
766766
pub fn dwarf_version(&self) -> u32 {
767-
self.opts.unstable_opts.dwarf_version.unwrap_or(self.target.default_dwarf_version)
767+
self.opts
768+
.cg
769+
.dwarf_version
770+
.or(self.opts.unstable_opts.dwarf_version)
771+
.unwrap_or(self.target.default_dwarf_version)
768772
}
769773

770774
pub fn stack_protector(&self) -> StackProtector {
@@ -1327,7 +1331,9 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
13271331
sess.dcx().emit_err(errors::BranchProtectionRequiresAArch64);
13281332
}
13291333

1330-
if let Some(dwarf_version) = sess.opts.unstable_opts.dwarf_version {
1334+
if let Some(dwarf_version) =
1335+
sess.opts.cg.dwarf_version.or(sess.opts.unstable_opts.dwarf_version)
1336+
{
13311337
// DWARF 1 is not supported by LLVM and DWARF 6 is not yet finalized.
13321338
if dwarf_version < 2 || dwarf_version > 5 {
13331339
sess.dcx().emit_err(errors::UnsupportedDwarfVersion { dwarf_version });

Diff for: src/doc/rustc/src/codegen-options/index.md

+13
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,19 @@ It takes a path to [the dlltool executable](https://sourceware.org/binutils/docs
110110
If this flag is not specified, a dlltool executable will be inferred based on
111111
the host environment and target.
112112

113+
## dwarf-version
114+
115+
This option controls the version of DWARF that the compiler emits, on platforms
116+
that use DWARF to encode debug information. It takes one of the following
117+
values:
118+
119+
* `2`: DWARF version 2 (the default on certain platforms, like Android).
120+
* `3`: DWARF version 3 (the default on certain platforms, like AIX).
121+
* `4`: DWARF version 4 (the default on most platforms, like Linux & macOS).
122+
* `5`: DWARF version 5.
123+
124+
DWARF version 1 is not supported.
125+
113126
## embed-bitcode
114127

115128
This flag controls whether or not the compiler embeds LLVM bitcode into object

Diff for: src/doc/unstable-book/src/compiler-flags/dwarf-version.md

-13
This file was deleted.

Diff for: tests/assembly/auxiliary/dwarf-mixed-versions-lto-aux.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ compile-flags: -g --crate-type=rlib -Zdwarf-version=4
1+
//@ compile-flags: -g --crate-type=rlib -Cdwarf-version=4
22

33
pub fn check_is_even(number: &u64) -> bool {
44
number % 2 == 0

Diff for: tests/assembly/dwarf-mixed-versions-lto.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
//@ only-linux
66
//@ aux-build:dwarf-mixed-versions-lto-aux.rs
7-
//@ compile-flags: -C lto -g -Zdwarf-version=5
7+
//@ compile-flags: -C lto -g -Cdwarf-version=5
88
//@ assembly-output: emit-asm
99
//@ no-prefer-dynamic
1010

Diff for: tests/assembly/dwarf4.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// Makes sure that `-Z dwarf-version=4` causes `rustc` to emit DWARF version 4.
1+
// Makes sure that `-C dwarf-version=4` causes `rustc` to emit DWARF version 4.
22
//@ assembly-output: emit-asm
33
//@ add-core-stubs
4-
//@ compile-flags: -g --target x86_64-unknown-linux-gnu -Z dwarf-version=4 -Copt-level=0
4+
//@ compile-flags: -g --target x86_64-unknown-linux-gnu -C dwarf-version=4 -Copt-level=0
55
//@ needs-llvm-components: x86
66

77
#![feature(no_core, lang_items)]

Diff for: tests/assembly/dwarf5.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// Makes sure that `-Z dwarf-version=5` causes `rustc` to emit DWARF version 5.
1+
// Makes sure that `-C dwarf-version=5` causes `rustc` to emit DWARF version 5.
22
//@ add-core-stubs
33
//@ assembly-output: emit-asm
4-
//@ compile-flags: -g --target x86_64-unknown-linux-gnu -Z dwarf-version=5 -Copt-level=0
4+
//@ compile-flags: -g --target x86_64-unknown-linux-gnu -C dwarf-version=5 -Copt-level=0
55
//@ needs-llvm-components: x86
66

77
#![feature(no_core, lang_items)]

Diff for: tests/run-make/embed-source-dwarf/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn main() {
2121
.output(&output)
2222
.arg("-g")
2323
.arg("-Zembed-source=yes")
24-
.arg("-Zdwarf-version=5")
24+
.arg("-Cdwarf-version=5")
2525
.run();
2626
let output = rfs::read(output);
2727
let obj = object::File::parse(output.as_slice()).unwrap();

Diff for: tests/ui/debuginfo/dwarf-versions.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
// This test verifies the expected behavior of various options passed to
2-
// `-Zdwarf-version`: 2 - 5 (valid) with all other options being invalid.
2+
// `-Cdwarf-version`: 2 - 5 (valid) with all other options being invalid.
33

44
//@ revisions: zero one two three four five six
55

6-
//@[zero] compile-flags: -Zdwarf-version=0
6+
//@[zero] compile-flags: -Cdwarf-version=0
77

8-
//@[one] compile-flags: -Zdwarf-version=1
8+
//@[one] compile-flags: -Cdwarf-version=1
99

10-
//@[two] compile-flags: -Zdwarf-version=2
10+
//@[two] compile-flags: -Cdwarf-version=2
1111
//@[two] check-pass
1212

13-
//@[three] compile-flags: -Zdwarf-version=3
13+
//@[three] compile-flags: -Cdwarf-version=3
1414
//@[three] check-pass
1515

16-
//@[four] compile-flags: -Zdwarf-version=4
16+
//@[four] compile-flags: -Cdwarf-version=4
1717
//@[four] check-pass
1818

19-
//@[five] compile-flags: -Zdwarf-version=5
19+
//@[five] compile-flags: -Cdwarf-version=5
2020
//@[five] check-pass
2121

22-
//@[six] compile-flags: -Zdwarf-version=6
22+
//@[six] compile-flags: -Cdwarf-version=6
2323

2424
//@ compile-flags: -g --target x86_64-unknown-linux-gnu --crate-type cdylib
2525
//@ needs-llvm-components: x86

Diff for: tests/ui/lto/auxiliary/dwarf-mixed-versions-lto-aux.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ compile-flags: -g --crate-type=rlib -Zdwarf-version=4
1+
//@ compile-flags: -g --crate-type=rlib -Cdwarf-version=4
22

33
pub fn say_hi() {
44
println!("hello there")

Diff for: tests/ui/lto/dwarf-mixed-versions-lto.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
//@ ignore-msvc Platform must use DWARF
66
//@ aux-build:dwarf-mixed-versions-lto-aux.rs
7-
//@ compile-flags: -C lto -g -Zdwarf-version=5
7+
//@ compile-flags: -C lto -g -Cdwarf-version=5
88
//@ no-prefer-dynamic
99
//@ build-pass
1010

0 commit comments

Comments
 (0)