1
Fork 0

Add -Z location-detail flag

This commit is contained in:
Hudson Ayers 2021-10-13 17:01:31 -07:00
parent 97e3b30285
commit a9a1393cbf
2 changed files with 40 additions and 1 deletions

View file

@ -174,6 +174,20 @@ impl LinkerPluginLto {
}
}
/// The different settings that can be enabled via the `-Z location-detail` flag.
#[derive(Clone, PartialEq, Hash, Debug)]
pub struct LocationDetail {
pub file: bool,
pub line: bool,
pub column: bool,
}
impl LocationDetail {
pub fn all() -> Self {
Self { file: true, line: true, column: true }
}
}
#[derive(Clone, PartialEq, Hash, Debug)]
pub enum SwitchWithOptPath {
Enabled(Option<PathBuf>),
@ -2422,7 +2436,7 @@ crate mod dep_tracking {
use super::LdImpl;
use super::{
CFGuard, CrateType, DebugInfo, ErrorOutputType, InstrumentCoverage, LinkerPluginLto,
LtoCli, OptLevel, OutputType, OutputTypes, Passes, SourceFileHashAlgorithm,
LocationDetail, LtoCli, OptLevel, OutputType, OutputTypes, Passes, SourceFileHashAlgorithm,
SwitchWithOptPath, SymbolManglingVersion, TrimmedDefPaths,
};
use crate::lint;
@ -2513,6 +2527,7 @@ crate mod dep_tracking {
Option<LdImpl>,
OutputType,
RealFileName,
LocationDetail,
);
impl<T1, T2> DepTrackingHash for (T1, T2)

View file

@ -368,6 +368,8 @@ mod desc {
"either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted";
pub const parse_linker_plugin_lto: &str =
"either a boolean (`yes`, `no`, `on`, `off`, etc), or the path to the linker plugin";
pub const parse_location_detail: &str =
"comma seperated list of location details to track: `file`, `line`, or `column`";
pub const parse_switch_with_opt_path: &str =
"an optional path to the profiling data output directory";
pub const parse_merge_functions: &str = "one of: `disabled`, `trampolines`, or `aliases`";
@ -484,6 +486,25 @@ mod parse {
}
}
crate fn parse_location_detail(ld: &mut LocationDetail, v: Option<&str>) -> bool {
if let Some(v) = v {
ld.line = false;
ld.file = false;
ld.column = false;
for s in v.split(',') {
match s {
"file" => ld.file = true,
"line" => ld.line = true,
"column" => ld.column = true,
_ => return false,
}
}
true
} else {
false
}
}
crate fn parse_opt_comma_list(slot: &mut Option<Vec<String>>, v: Option<&str>) -> bool {
match v {
Some(s) => {
@ -1152,6 +1173,9 @@ options! {
"a list LLVM plugins to enable (space separated)"),
llvm_time_trace: bool = (false, parse_bool, [UNTRACKED],
"generate JSON tracing data file from LLVM data (default: no)"),
location_detail: LocationDetail = (LocationDetail::all(), parse_location_detail, [TRACKED],
"comma seperated list of location details to be tracked when using caller_location \
valid options are `file`, `line`, and `column` (default: all)"),
ls: bool = (false, parse_bool, [UNTRACKED],
"list the symbols defined by a library crate (default: no)"),
macro_backtrace: bool = (false, parse_bool, [UNTRACKED],