Clean up uses of the unstable dwarf_version
option
- Consolidate calculation of the effective value. - Check the target `DebuginfoKind` instead of using `is_like_msvc`.
This commit is contained in:
parent
4a5f1cc52b
commit
51eaa0d56a
4 changed files with 34 additions and 27 deletions
|
@ -1803,6 +1803,7 @@ options! {
|
|||
"output statistics about monomorphization collection"),
|
||||
dump_mono_stats_format: DumpMonoStatsFormat = (DumpMonoStatsFormat::Markdown, parse_dump_mono_stats, [UNTRACKED],
|
||||
"the format to use for -Z dump-mono-stats (`markdown` (default) or `json`)"),
|
||||
#[rustc_lint_opt_deny_field_access("use `Session::dwarf_version` instead of this field")]
|
||||
dwarf_version: Option<u32> = (None, parse_opt_number, [TRACKED],
|
||||
"version of DWARF debug information to emit (default: 2 or 4, depending on platform)"),
|
||||
dylib_lto: bool = (false, parse_bool, [UNTRACKED],
|
||||
|
|
|
@ -732,6 +732,11 @@ impl Session {
|
|||
self.opts.cg.split_debuginfo.unwrap_or(self.target.split_debuginfo)
|
||||
}
|
||||
|
||||
/// Returns the DWARF version passed on the CLI or the default for the target.
|
||||
pub fn dwarf_version(&self) -> u32 {
|
||||
self.opts.unstable_opts.dwarf_version.unwrap_or(self.target.default_dwarf_version)
|
||||
}
|
||||
|
||||
pub fn stack_protector(&self) -> StackProtector {
|
||||
if self.target.options.supports_stack_protector {
|
||||
self.opts.unstable_opts.stack_protector
|
||||
|
@ -1263,8 +1268,7 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
|
|||
}
|
||||
|
||||
if sess.opts.unstable_opts.embed_source {
|
||||
let dwarf_version =
|
||||
sess.opts.unstable_opts.dwarf_version.unwrap_or(sess.target.default_dwarf_version);
|
||||
let dwarf_version = sess.dwarf_version();
|
||||
|
||||
if dwarf_version < 5 {
|
||||
sess.dcx().emit_warn(errors::EmbedSourceInsufficientDwarfVersion { dwarf_version });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue