Auto merge of #109808 - jyn514:debuginfo-options, r=michaelwoerister
Extend -Cdebuginfo with new options and named aliases This is a rebase of https://github.com/rust-lang/rust/pull/83947, along with my best guess at what the new options mean. I tried to follow the LLVM source code to get a better idea but ran into quite a lot of trouble (https://rust-lang.zulipchat.com/#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/go-to-definition.20in.20src.2Fllvm-project.3F). The description for the original PR follows below. Note that the changes in this PR have already been through FCP: https://github.com/rust-lang/rust/pull/83947#issuecomment-878384979 Closes https://github.com/rust-lang/rust/pull/109311. Helps with https://github.com/rust-lang/rust/pull/104968. r? `@michaelwoerister` cc `@cuviper` --- The -Cdebuginfo=1 option was never line tables only and can't be due to backwards compatibility issues. This was clarified and an option for emitting line tables only was added. Additionally an option for emitting line info directives only was added, which is needed for some targets, i.e. nvptx. The debug info options should now behave similarly to clang's debug info options. Fix https://github.com/rust-lang/rust/issues/60020 Fix https://github.com/rust-lang/rust/issues/64405
This commit is contained in:
commit
700938c078
13 changed files with 133 additions and 54 deletions
|
@ -260,6 +260,8 @@ pub enum SymbolManglingVersion {
|
|||
#[derive(Clone, Copy, Debug, PartialEq, Hash)]
|
||||
pub enum DebugInfo {
|
||||
None,
|
||||
LineDirectivesOnly,
|
||||
LineTablesOnly,
|
||||
Limited,
|
||||
Full,
|
||||
}
|
||||
|
@ -1979,11 +1981,7 @@ fn parse_opt_level(
|
|||
}
|
||||
}
|
||||
|
||||
fn select_debuginfo(
|
||||
matches: &getopts::Matches,
|
||||
cg: &CodegenOptions,
|
||||
error_format: ErrorOutputType,
|
||||
) -> DebugInfo {
|
||||
fn select_debuginfo(matches: &getopts::Matches, cg: &CodegenOptions) -> DebugInfo {
|
||||
let max_g = matches.opt_positions("g").into_iter().max();
|
||||
let max_c = matches
|
||||
.opt_strs_pos("C")
|
||||
|
@ -1993,24 +1991,7 @@ fn select_debuginfo(
|
|||
if let Some("debuginfo") = s.split('=').next() { Some(i) } else { None }
|
||||
})
|
||||
.max();
|
||||
if max_g > max_c {
|
||||
DebugInfo::Full
|
||||
} else {
|
||||
match cg.debuginfo {
|
||||
0 => DebugInfo::None,
|
||||
1 => DebugInfo::Limited,
|
||||
2 => DebugInfo::Full,
|
||||
arg => {
|
||||
early_error(
|
||||
error_format,
|
||||
&format!(
|
||||
"debug info level needs to be between \
|
||||
0-2 (instead was `{arg}`)"
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if max_g > max_c { DebugInfo::Full } else { cg.debuginfo }
|
||||
}
|
||||
|
||||
pub(crate) fn parse_assert_incr_state(
|
||||
|
@ -2498,7 +2479,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
|||
// to use them interchangeably. See the note above (regarding `-O` and `-C opt-level`)
|
||||
// for more details.
|
||||
let debug_assertions = cg.debug_assertions.unwrap_or(opt_level == OptLevel::No);
|
||||
let debuginfo = select_debuginfo(matches, &cg, error_format);
|
||||
let debuginfo = select_debuginfo(matches, &cg);
|
||||
|
||||
let mut search_paths = vec![];
|
||||
for s in &matches.opt_strs("L") {
|
||||
|
|
|
@ -377,6 +377,7 @@ mod desc {
|
|||
pub const parse_cfguard: &str =
|
||||
"either a boolean (`yes`, `no`, `on`, `off`, etc), `checks`, or `nochecks`";
|
||||
pub const parse_cfprotection: &str = "`none`|`no`|`n` (default), `branch`, `return`, or `full`|`yes`|`y` (equivalent to `branch` and `return`)";
|
||||
pub const parse_debuginfo: &str = "either an integer (0, 1, 2), `none`, `line-directives-only`, `line-tables-only`, `limited`, or `full`";
|
||||
pub const parse_strip: &str = "either `none`, `debuginfo`, or `symbols`";
|
||||
pub const parse_linker_flavor: &str = ::rustc_target::spec::LinkerFlavorCli::one_of();
|
||||
pub const parse_optimization_fuel: &str = "crate=integer";
|
||||
|
@ -767,6 +768,18 @@ mod parse {
|
|||
true
|
||||
}
|
||||
|
||||
pub(crate) fn parse_debuginfo(slot: &mut DebugInfo, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some("0") | Some("none") => *slot = DebugInfo::None,
|
||||
Some("line-directives-only") => *slot = DebugInfo::LineDirectivesOnly,
|
||||
Some("line-tables-only") => *slot = DebugInfo::LineTablesOnly,
|
||||
Some("1") | Some("limited") => *slot = DebugInfo::Limited,
|
||||
Some("2") | Some("full") => *slot = DebugInfo::Full,
|
||||
_ => return false,
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
pub(crate) fn parse_linker_flavor(slot: &mut Option<LinkerFlavorCli>, v: Option<&str>) -> bool {
|
||||
match v.and_then(LinkerFlavorCli::from_str) {
|
||||
Some(lf) => *slot = Some(lf),
|
||||
|
@ -1217,9 +1230,9 @@ options! {
|
|||
"use Windows Control Flow Guard (default: no)"),
|
||||
debug_assertions: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
||||
"explicitly enable the `cfg(debug_assertions)` directive"),
|
||||
debuginfo: usize = (0, parse_number, [TRACKED],
|
||||
"debug info emission level (0 = no debug info, 1 = line tables only, \
|
||||
2 = full debug info with variable and type information; default: 0)"),
|
||||
debuginfo: DebugInfo = (DebugInfo::None, parse_debuginfo, [TRACKED],
|
||||
"debug info emission level (0-2, none, line-directives-only, \
|
||||
line-tables-only, limited, or full; default: 0)"),
|
||||
default_linker_libraries: bool = (false, parse_bool, [UNTRACKED],
|
||||
"allow the linker to link its default libraries (default: no)"),
|
||||
embed_bitcode: bool = (true, parse_bool, [TRACKED],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue