summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_session/src/options.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_session/src/options.rs')
-rw-r--r--compiler/rustc_session/src/options.rs124
1 files changed, 108 insertions, 16 deletions
diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs
index 7b5fd6cc2..b466a3fcd 100644
--- a/compiler/rustc_session/src/options.rs
+++ b/compiler/rustc_session/src/options.rs
@@ -4,7 +4,7 @@ use crate::early_error;
use crate::lint;
use crate::search_paths::SearchPath;
use crate::utils::NativeLib;
-use rustc_errors::LanguageIdentifier;
+use rustc_errors::{LanguageIdentifier, TerminalUrl};
use rustc_target::spec::{CodeModel, LinkerFlavorCli, MergeFunctions, PanicStrategy, SanitizerSet};
use rustc_target::spec::{
RelocModel, RelroLevel, SplitDebuginfo, StackProtector, TargetTriple, TlsModel,
@@ -169,6 +169,8 @@ top_level_options!(
/// is currently just a hack and will be removed eventually, so please
/// try to not rely on this too much.
actually_rustdoc: bool [TRACKED],
+ /// Whether name resolver should resolve documentation links.
+ resolve_doc_links: ResolveDocLinks [TRACKED],
/// Control path trimming.
trimmed_def_paths: TrimmedDefPaths [TRACKED],
@@ -349,7 +351,7 @@ fn build_options<O: Default>(
#[allow(non_upper_case_globals)]
mod desc {
pub const parse_no_flag: &str = "no value";
- pub const parse_bool: &str = "one of: `y`, `yes`, `on`, `n`, `no`, or `off`";
+ pub const parse_bool: &str = "one of: `y`, `yes`, `on`, `true`, `n`, `no`, `off` or `false`";
pub const parse_opt_bool: &str = parse_bool;
pub const parse_string: &str = "a string";
pub const parse_opt_string: &str = parse_string;
@@ -368,7 +370,7 @@ mod desc {
pub const parse_opt_panic_strategy: &str = parse_panic_strategy;
pub const parse_oom_strategy: &str = "either `panic` or `abort`";
pub const parse_relro_level: &str = "one of: `full`, `partial`, or `off`";
- pub const parse_sanitizers: &str = "comma separated list of sanitizers: `address`, `cfi`, `hwaddress`, `kcfi`, `leak`, `memory`, `memtag`, `shadow-call-stack`, or `thread`";
+ pub const parse_sanitizers: &str = "comma separated list of sanitizers: `address`, `cfi`, `hwaddress`, `kcfi`, `kernel-address`, `leak`, `memory`, `memtag`, `shadow-call-stack`, or `thread`";
pub const parse_sanitizer_memory_track_origins: &str = "0, 1, or 2";
pub const parse_cfguard: &str =
"either a boolean (`yes`, `no`, `on`, `off`, etc), `checks`, or `nochecks`";
@@ -380,6 +382,7 @@ mod desc {
pub const parse_dump_mono_stats: &str = "`markdown` (default) or `json`";
pub const parse_instrument_coverage: &str =
"`all` (default), `except-unused-generics`, `except-unused-functions`, or `off`";
+ pub const parse_instrument_xray: &str = "either a boolean (`yes`, `no`, `on`, `off`, etc), or a comma separated list of settings: `always` or `never` (mutually exclusive), `ignore-loops`, `instruction-threshold=N`, `skip-entry`, `skip-exit`";
pub const parse_unpretty: &str = "`string` or `string=string`";
pub const parse_treat_err_as_bug: &str = "either no value or a number bigger than 0";
pub const parse_trait_solver: &str =
@@ -399,6 +402,8 @@ mod desc {
pub const parse_code_model: &str = "one of supported code models (`rustc --print code-models`)";
pub const parse_tls_model: &str = "one of supported TLS models (`rustc --print tls-models`)";
pub const parse_target_feature: &str = parse_string;
+ pub const parse_terminal_url: &str =
+ "either a boolean (`yes`, `no`, `on`, `off`, etc), or `auto`";
pub const parse_wasi_exec_model: &str = "either `command` or `reactor`";
pub const parse_split_debuginfo: &str =
"one of supported split-debuginfo modes (`off`, `packed`, or `unpacked`)";
@@ -432,11 +437,11 @@ mod parse {
/// Use this for any boolean option that has a static default.
pub(crate) fn parse_bool(slot: &mut bool, v: Option<&str>) -> bool {
match v {
- Some("y") | Some("yes") | Some("on") | None => {
+ Some("y") | Some("yes") | Some("on") | Some("true") | None => {
*slot = true;
true
}
- Some("n") | Some("no") | Some("off") => {
+ Some("n") | Some("no") | Some("off") | Some("false") => {
*slot = false;
true
}
@@ -449,11 +454,11 @@ mod parse {
/// other factors, such as other options, or target options.)
pub(crate) fn parse_opt_bool(slot: &mut Option<bool>, v: Option<&str>) -> bool {
match v {
- Some("y") | Some("yes") | Some("on") | None => {
+ Some("y") | Some("yes") | Some("on") | Some("true") | None => {
*slot = Some(true);
true
}
- Some("n") | Some("no") | Some("off") => {
+ Some("n") | Some("no") | Some("off") | Some("false") => {
*slot = Some(false);
true
}
@@ -679,6 +684,7 @@ mod parse {
"address" => SanitizerSet::ADDRESS,
"cfi" => SanitizerSet::CFI,
"kcfi" => SanitizerSet::KCFI,
+ "kernel-address" => SanitizerSet::KERNELADDRESS,
"leak" => SanitizerSet::LEAK,
"memory" => SanitizerSet::MEMORY,
"memtag" => SanitizerSet::MEMTAG,
@@ -804,7 +810,7 @@ mod parse {
if v.is_some() {
let mut bool_arg = None;
if parse_opt_bool(&mut bool_arg, v) {
- *slot = if bool_arg.unwrap() { Some(MirSpanview::Statement) } else { None };
+ *slot = bool_arg.unwrap().then_some(MirSpanview::Statement);
return true;
}
}
@@ -845,7 +851,7 @@ mod parse {
if v.is_some() {
let mut bool_arg = None;
if parse_opt_bool(&mut bool_arg, v) {
- *slot = if bool_arg.unwrap() { Some(InstrumentCoverage::All) } else { None };
+ *slot = bool_arg.unwrap().then_some(InstrumentCoverage::All);
return true;
}
}
@@ -869,6 +875,68 @@ mod parse {
true
}
+ pub(crate) fn parse_instrument_xray(
+ slot: &mut Option<InstrumentXRay>,
+ v: Option<&str>,
+ ) -> bool {
+ if v.is_some() {
+ let mut bool_arg = None;
+ if parse_opt_bool(&mut bool_arg, v) {
+ *slot = if bool_arg.unwrap() { Some(InstrumentXRay::default()) } else { None };
+ return true;
+ }
+ }
+
+ let mut options = slot.get_or_insert_default();
+ let mut seen_always = false;
+ let mut seen_never = false;
+ let mut seen_ignore_loops = false;
+ let mut seen_instruction_threshold = false;
+ let mut seen_skip_entry = false;
+ let mut seen_skip_exit = false;
+ for option in v.into_iter().map(|v| v.split(',')).flatten() {
+ match option {
+ "always" if !seen_always && !seen_never => {
+ options.always = true;
+ options.never = false;
+ seen_always = true;
+ }
+ "never" if !seen_never && !seen_always => {
+ options.never = true;
+ options.always = false;
+ seen_never = true;
+ }
+ "ignore-loops" if !seen_ignore_loops => {
+ options.ignore_loops = true;
+ seen_ignore_loops = true;
+ }
+ option
+ if option.starts_with("instruction-threshold")
+ && !seen_instruction_threshold =>
+ {
+ let Some(("instruction-threshold", n)) = option.split_once('=') else {
+ return false;
+ };
+ match n.parse() {
+ Ok(n) => options.instruction_threshold = Some(n),
+ Err(_) => return false,
+ }
+ seen_instruction_threshold = true;
+ }
+ "skip-entry" if !seen_skip_entry => {
+ options.skip_entry = true;
+ seen_skip_entry = true;
+ }
+ "skip-exit" if !seen_skip_exit => {
+ options.skip_exit = true;
+ seen_skip_exit = true;
+ }
+ _ => return false,
+ }
+ }
+ true
+ }
+
pub(crate) fn parse_treat_err_as_bug(slot: &mut Option<NonZeroUsize>, v: Option<&str>) -> bool {
match v {
Some(s) => {
@@ -979,6 +1047,16 @@ mod parse {
true
}
+ pub(crate) fn parse_terminal_url(slot: &mut TerminalUrl, v: Option<&str>) -> bool {
+ *slot = match v {
+ Some("on" | "" | "yes" | "y") | None => TerminalUrl::Yes,
+ Some("off" | "no" | "n") => TerminalUrl::No,
+ Some("auto") => TerminalUrl::Auto,
+ _ => return false,
+ };
+ true
+ }
+
pub(crate) fn parse_symbol_mangling_version(
slot: &mut Option<SymbolManglingVersion>,
v: Option<&str>,
@@ -1290,6 +1368,8 @@ options! {
(default: no)"),
drop_tracking: bool = (false, parse_bool, [TRACKED],
"enables drop tracking in generators (default: no)"),
+ drop_tracking_mir: bool = (false, parse_bool, [TRACKED],
+ "enables drop tracking on MIR in generators (default: no)"),
dual_proc_macros: bool = (false, parse_bool, [TRACKED],
"load proc macros for both target and host, but only link to the target (default: no)"),
dump_dep_graph: bool = (false, parse_bool, [UNTRACKED],
@@ -1395,10 +1475,22 @@ options! {
`=off` (default)"),
instrument_mcount: bool = (false, parse_bool, [TRACKED],
"insert function instrument code for mcount-based tracing (default: no)"),
+ instrument_xray: Option<InstrumentXRay> = (None, parse_instrument_xray, [TRACKED],
+ "insert function instrument code for XRay-based tracing (default: no)
+ Optional extra settings:
+ `=always`
+ `=never`
+ `=ignore-loops`
+ `=instruction-threshold=N`
+ `=skip-entry`
+ `=skip-exit`
+ Multiple options can be combined with commas."),
keep_hygiene_data: bool = (false, parse_bool, [UNTRACKED],
"keep hygiene data after analysis (default: no)"),
layout_seed: Option<u64> = (None, parse_opt_number, [TRACKED],
"seed layout randomization"),
+ link_directives: bool = (true, parse_bool, [TRACKED],
+ "honor #[link] directives in the compiled crate (default: yes)"),
link_native_libraries: bool = (true, parse_bool, [UNTRACKED],
"link native libraries in the linker invocation (default: yes)"),
link_only: bool = (false, parse_bool, [TRACKED],
@@ -1411,8 +1503,9 @@ options! {
"what location details should be tracked when using caller_location, either \
`none`, or a comma separated list of location details, for which \
valid options are `file`, `line`, and `column` (default: `file,line,column`)"),
- log_backtrace: Option<String> = (None, parse_opt_string, [TRACKED],
- "add a backtrace along with logging"),
+ lower_impl_trait_in_trait_to_assoc_ty: bool = (false, parse_bool, [TRACKED],
+ "modify the lowering strategy for `impl Trait` in traits so that they are lowered to \
+ generic associated types"),
ls: bool = (false, parse_bool, [UNTRACKED],
"list the symbols defined by a library crate (default: no)"),
macro_backtrace: bool = (false, parse_bool, [UNTRACKED],
@@ -1479,8 +1572,6 @@ options! {
"parse only; do not compile, assemble, or link (default: no)"),
perf_stats: bool = (false, parse_bool, [UNTRACKED],
"print some performance-related statistics (default: no)"),
- pick_stable_methods_before_any_unstable: bool = (true, parse_bool, [TRACKED],
- "try to pick stable methods first before picking any unstable methods (default: yes)"),
plt: Option<bool> = (None, parse_opt_bool, [TRACKED],
"whether to use the PLT when calling into shared libraries;
only has effect for PIC code on systems with ELF binaries
@@ -1542,9 +1633,6 @@ options! {
saturating_float_casts: Option<bool> = (None, parse_opt_bool, [TRACKED],
"make float->int casts UB-free: numbers outside the integer type's range are clipped to \
the max/min integer respectively, and NaN is mapped to 0 (default: yes)"),
- save_analysis: bool = (false, parse_bool, [UNTRACKED],
- "write syntax and type analysis (in JSON format) information, in \
- addition to normal output (default: no)"),
self_profile: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
parse_switch_with_opt_path, [UNTRACKED],
"run the self profiler and output the raw event data"),
@@ -1600,6 +1688,8 @@ options! {
"show extended diagnostic help (default: no)"),
temps_dir: Option<String> = (None, parse_opt_string, [UNTRACKED],
"the directory the intermediate files are written to"),
+ terminal_urls: TerminalUrl = (TerminalUrl::No, parse_terminal_url, [UNTRACKED],
+ "use the OSC 8 hyperlink terminal specification to print hyperlinks in the compiler output"),
#[rustc_lint_opt_deny_field_access("use `Session::lto` instead of this field")]
thinlto: Option<bool> = (None, parse_opt_bool, [TRACKED],
"enable ThinLTO when possible"),
@@ -1616,6 +1706,8 @@ options! {
"measure time of each LLVM pass (default: no)"),
time_passes: bool = (false, parse_bool, [UNTRACKED],
"measure time of each rustc pass (default: no)"),
+ tiny_const_eval_limit: bool = (false, parse_bool, [TRACKED],
+ "sets a tiny, non-configurable limit for const eval; useful for compiler tests"),
#[rustc_lint_opt_deny_field_access("use `Session::tls_model` instead of this field")]
tls_model: Option<TlsModel> = (None, parse_tls_model, [TRACKED],
"choose the TLS model to use (`rustc --print tls-models` for details)"),