2019-12-17 23:22:55 +11:00
|
|
|
use crate::config::*;
|
|
|
|
|
|
|
|
use crate::early_error;
|
2019-12-22 17:42:04 -05:00
|
|
|
use crate::lint;
|
2019-12-17 23:22:55 +11:00
|
|
|
use crate::search_paths::SearchPath;
|
2020-05-18 00:18:50 +03:00
|
|
|
use crate::utils::NativeLibKind;
|
2019-12-17 23:22:55 +11:00
|
|
|
|
2020-05-07 03:34:27 +03:00
|
|
|
use rustc_target::spec::{CodeModel, LinkerFlavor, MergeFunctions, PanicStrategy};
|
|
|
|
use rustc_target::spec::{RelocModel, RelroLevel, TargetTriple, TlsModel};
|
2019-12-17 23:22:55 +11:00
|
|
|
|
|
|
|
use rustc_feature::UnstableFeatures;
|
2019-12-31 20:15:40 +03:00
|
|
|
use rustc_span::edition::Edition;
|
2020-03-30 22:17:15 -07:00
|
|
|
use rustc_span::SourceFileHashAlgorithm;
|
2019-12-17 23:22:55 +11:00
|
|
|
|
|
|
|
use std::collections::BTreeMap;
|
|
|
|
|
|
|
|
use std::collections::hash_map::DefaultHasher;
|
2019-12-22 17:42:04 -05:00
|
|
|
use std::hash::Hasher;
|
2019-12-17 23:22:55 +11:00
|
|
|
use std::path::PathBuf;
|
2019-12-22 17:42:04 -05:00
|
|
|
use std::str;
|
2019-12-17 23:22:55 +11:00
|
|
|
|
|
|
|
macro_rules! hash_option {
|
2019-12-22 17:42:04 -05:00
|
|
|
($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, [UNTRACKED]) => {{}};
|
|
|
|
($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, [TRACKED]) => {{
|
|
|
|
if $sub_hashes
|
|
|
|
.insert(stringify!($opt_name), $opt_expr as &dyn dep_tracking::DepTrackingHash)
|
|
|
|
.is_some()
|
|
|
|
{
|
2019-12-17 23:22:55 +11:00
|
|
|
panic!("duplicate key in CLI DepTrackingHash: {}", stringify!($opt_name))
|
|
|
|
}
|
2019-12-22 17:42:04 -05:00
|
|
|
}};
|
2019-12-17 23:22:55 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! top_level_options {
|
|
|
|
(pub struct Options { $(
|
|
|
|
$opt:ident : $t:ty [$dep_tracking_marker:ident $($warn_val:expr, $warn_text:expr)*],
|
|
|
|
)* } ) => (
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub struct Options {
|
|
|
|
$(pub $opt: $t),*
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Options {
|
|
|
|
pub fn dep_tracking_hash(&self) -> u64 {
|
|
|
|
let mut sub_hashes = BTreeMap::new();
|
|
|
|
$({
|
|
|
|
hash_option!($opt,
|
|
|
|
&self.$opt,
|
|
|
|
&mut sub_hashes,
|
|
|
|
[$dep_tracking_marker $($warn_val,
|
|
|
|
$warn_text,
|
|
|
|
self.error_format)*]);
|
|
|
|
})*
|
|
|
|
let mut hasher = DefaultHasher::new();
|
|
|
|
dep_tracking::stable_hash(sub_hashes,
|
|
|
|
&mut hasher,
|
|
|
|
self.error_format);
|
|
|
|
hasher.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// The top-level command-line options struct.
|
|
|
|
//
|
|
|
|
// For each option, one has to specify how it behaves with regard to the
|
|
|
|
// dependency tracking system of incremental compilation. This is done via the
|
|
|
|
// square-bracketed directive after the field type. The options are:
|
|
|
|
//
|
|
|
|
// [TRACKED]
|
|
|
|
// A change in the given field will cause the compiler to completely clear the
|
|
|
|
// incremental compilation cache before proceeding.
|
|
|
|
//
|
|
|
|
// [UNTRACKED]
|
|
|
|
// Incremental compilation is not influenced by this option.
|
|
|
|
//
|
|
|
|
// If you add a new option to this struct or one of the sub-structs like
|
|
|
|
// `CodegenOptions`, think about how it influences incremental compilation. If in
|
|
|
|
// doubt, specify [TRACKED], which is always "correct" but might lead to
|
|
|
|
// unnecessary re-compilation.
|
|
|
|
top_level_options!(
|
|
|
|
pub struct Options {
|
|
|
|
// The crate config requested for the session, which may be combined
|
|
|
|
// with additional crate configurations during the compile process.
|
|
|
|
crate_types: Vec<CrateType> [TRACKED],
|
|
|
|
optimize: OptLevel [TRACKED],
|
|
|
|
// Include the `debug_assertions` flag in dependency tracking, since it
|
|
|
|
// can influence whether overflow checks are done or not.
|
|
|
|
debug_assertions: bool [TRACKED],
|
|
|
|
debuginfo: DebugInfo [TRACKED],
|
|
|
|
lint_opts: Vec<(String, lint::Level)> [TRACKED],
|
|
|
|
lint_cap: Option<lint::Level> [TRACKED],
|
|
|
|
describe_lints: bool [UNTRACKED],
|
|
|
|
output_types: OutputTypes [TRACKED],
|
|
|
|
search_paths: Vec<SearchPath> [UNTRACKED],
|
2020-05-18 01:52:34 +03:00
|
|
|
libs: Vec<(String, Option<String>, NativeLibKind)> [TRACKED],
|
2019-12-17 23:22:55 +11:00
|
|
|
maybe_sysroot: Option<PathBuf> [UNTRACKED],
|
|
|
|
|
|
|
|
target_triple: TargetTriple [TRACKED],
|
|
|
|
|
|
|
|
test: bool [TRACKED],
|
|
|
|
error_format: ErrorOutputType [UNTRACKED],
|
|
|
|
|
|
|
|
// If `Some`, enable incremental compilation, using the given
|
|
|
|
// directory to store intermediate results.
|
|
|
|
incremental: Option<PathBuf> [UNTRACKED],
|
|
|
|
|
|
|
|
debugging_opts: DebuggingOptions [TRACKED],
|
|
|
|
prints: Vec<PrintRequest> [UNTRACKED],
|
|
|
|
// Determines which borrow checker(s) to run. This is the parsed, sanitized
|
|
|
|
// version of `debugging_opts.borrowck`, which is just a plain string.
|
|
|
|
borrowck_mode: BorrowckMode [UNTRACKED],
|
|
|
|
cg: CodegenOptions [TRACKED],
|
|
|
|
externs: Externs [UNTRACKED],
|
|
|
|
crate_name: Option<String> [TRACKED],
|
|
|
|
// An optional name to use as the crate for std during std injection,
|
|
|
|
// written `extern crate name as std`. Defaults to `std`. Used by
|
|
|
|
// out-of-tree drivers.
|
|
|
|
alt_std_name: Option<String> [TRACKED],
|
|
|
|
// Indicates how the compiler should treat unstable features.
|
|
|
|
unstable_features: UnstableFeatures [TRACKED],
|
|
|
|
|
|
|
|
// Indicates whether this run of the compiler is actually rustdoc. This
|
|
|
|
// is currently just a hack and will be removed eventually, so please
|
|
|
|
// try to not rely on this too much.
|
|
|
|
actually_rustdoc: bool [TRACKED],
|
|
|
|
|
2020-09-02 10:40:56 +03:00
|
|
|
// Control path trimming.
|
|
|
|
trimmed_def_paths: TrimmedDefPaths [TRACKED],
|
|
|
|
|
2019-12-17 23:22:55 +11:00
|
|
|
// Specifications of codegen units / ThinLTO which are forced as a
|
|
|
|
// result of parsing command line options. These are not necessarily
|
|
|
|
// what rustc was invoked with, but massaged a bit to agree with
|
|
|
|
// commands like `--emit llvm-ir` which they're often incompatible with
|
|
|
|
// if we otherwise use the defaults of rustc.
|
|
|
|
cli_forced_codegen_units: Option<usize> [UNTRACKED],
|
|
|
|
cli_forced_thinlto_off: bool [UNTRACKED],
|
|
|
|
|
|
|
|
// Remap source path prefixes in all output (messages, object files, debug, etc.).
|
|
|
|
remap_path_prefix: Vec<(PathBuf, PathBuf)> [UNTRACKED],
|
|
|
|
|
|
|
|
edition: Edition [TRACKED],
|
|
|
|
|
|
|
|
// `true` if we're emitting JSON blobs about each artifact produced
|
|
|
|
// by the compiler.
|
|
|
|
json_artifact_notifications: bool [TRACKED],
|
|
|
|
|
|
|
|
pretty: Option<PpMode> [UNTRACKED],
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
/// Defines all `CodegenOptions`/`DebuggingOptions` fields and parsers all at once. The goal of this
|
|
|
|
/// macro is to define an interface that can be programmatically used by the option parser
|
|
|
|
/// to initialize the struct without hardcoding field names all over the place.
|
|
|
|
///
|
|
|
|
/// The goal is to invoke this macro once with the correct fields, and then this macro generates all
|
|
|
|
/// necessary code. The main gotcha of this macro is the `cgsetters` module which is a bunch of
|
|
|
|
/// generated code to parse an option into its respective field in the struct. There are a few
|
|
|
|
/// hand-written parsers for parsing specific types of values in this module.
|
|
|
|
macro_rules! options {
|
|
|
|
($struct_name:ident, $setter_name:ident, $defaultfn:ident,
|
|
|
|
$buildfn:ident, $prefix:expr, $outputname:expr,
|
|
|
|
$stat:ident, $mod_desc:ident, $mod_set:ident,
|
|
|
|
$($opt:ident : $t:ty = (
|
|
|
|
$init:expr,
|
|
|
|
$parse:ident,
|
|
|
|
[$dep_tracking_marker:ident $(($dep_warn_val:expr, $dep_warn_text:expr))*],
|
|
|
|
$desc:expr)
|
|
|
|
),* ,) =>
|
|
|
|
(
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub struct $struct_name { $(pub $opt: $t),* }
|
|
|
|
|
|
|
|
pub fn $defaultfn() -> $struct_name {
|
|
|
|
$struct_name { $($opt: $init),* }
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn $buildfn(matches: &getopts::Matches, error_format: ErrorOutputType) -> $struct_name
|
|
|
|
{
|
|
|
|
let mut op = $defaultfn();
|
|
|
|
for option in matches.opt_strs($prefix) {
|
|
|
|
let mut iter = option.splitn(2, '=');
|
|
|
|
let key = iter.next().unwrap();
|
|
|
|
let value = iter.next();
|
|
|
|
let option_to_lookup = key.replace("-", "_");
|
|
|
|
let mut found = false;
|
2020-04-03 14:15:10 +11:00
|
|
|
for &(candidate, setter, type_desc, _) in $stat {
|
2019-12-17 23:22:55 +11:00
|
|
|
if option_to_lookup != candidate { continue }
|
|
|
|
if !setter(&mut op, value) {
|
2020-04-03 14:15:10 +11:00
|
|
|
match value {
|
|
|
|
None => {
|
2019-12-17 23:22:55 +11:00
|
|
|
early_error(error_format, &format!("{0} option `{1}` requires \
|
|
|
|
{2} ({3} {1}=<value>)",
|
|
|
|
$outputname, key,
|
|
|
|
type_desc, $prefix))
|
|
|
|
}
|
2020-04-03 14:15:10 +11:00
|
|
|
Some(value) => {
|
2019-12-17 23:22:55 +11:00
|
|
|
early_error(error_format, &format!("incorrect value `{}` for {} \
|
|
|
|
option `{}` - {} was expected",
|
|
|
|
value, $outputname,
|
|
|
|
key, type_desc))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if !found {
|
|
|
|
early_error(error_format, &format!("unknown {} option: `{}`",
|
|
|
|
$outputname, key));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return op;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl dep_tracking::DepTrackingHash for $struct_name {
|
|
|
|
fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType) {
|
|
|
|
let mut sub_hashes = BTreeMap::new();
|
|
|
|
$({
|
|
|
|
hash_option!($opt,
|
|
|
|
&self.$opt,
|
|
|
|
&mut sub_hashes,
|
|
|
|
[$dep_tracking_marker $($dep_warn_val,
|
|
|
|
$dep_warn_text,
|
|
|
|
error_format)*]);
|
|
|
|
})*
|
|
|
|
dep_tracking::stable_hash(sub_hashes, hasher, error_format);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub type $setter_name = fn(&mut $struct_name, v: Option<&str>) -> bool;
|
2020-04-03 14:15:10 +11:00
|
|
|
pub const $stat: &[(&str, $setter_name, &str, &str)] =
|
2019-12-17 23:22:55 +11:00
|
|
|
&[ $( (stringify!($opt), $mod_set::$opt, $mod_desc::$parse, $desc) ),* ];
|
|
|
|
|
|
|
|
#[allow(non_upper_case_globals, dead_code)]
|
|
|
|
mod $mod_desc {
|
2020-04-06 09:29:19 +10:00
|
|
|
pub const parse_no_flag: &str = "no value";
|
2020-04-03 14:15:10 +11:00
|
|
|
pub const parse_bool: &str = "one of: `y`, `yes`, `on`, `n`, `no`, or `off`";
|
|
|
|
pub const parse_opt_bool: &str = parse_bool;
|
|
|
|
pub const parse_string: &str = "a string";
|
|
|
|
pub const parse_opt_string: &str = parse_string;
|
|
|
|
pub const parse_string_push: &str = parse_string;
|
|
|
|
pub const parse_opt_pathbuf: &str = "a path";
|
|
|
|
pub const parse_pathbuf_push: &str = parse_opt_pathbuf;
|
|
|
|
pub const parse_list: &str = "a space-separated list of strings";
|
|
|
|
pub const parse_opt_list: &str = parse_list;
|
|
|
|
pub const parse_opt_comma_list: &str = "a comma-separated list of strings";
|
|
|
|
pub const parse_uint: &str = "a number";
|
|
|
|
pub const parse_opt_uint: &str = parse_uint;
|
|
|
|
pub const parse_threads: &str = parse_uint;
|
|
|
|
pub const parse_passes: &str = "a space-separated list of passes, or `all`";
|
|
|
|
pub const parse_panic_strategy: &str = "either `unwind` or `abort`";
|
|
|
|
pub const parse_relro_level: &str = "one of: `full`, `partial`, or `off`";
|
2020-06-14 00:00:00 +00:00
|
|
|
pub const parse_sanitizers: &str = "comma separated list of sanitizers: `address`, `leak`, `memory` or `thread`";
|
2020-04-03 14:15:10 +11:00
|
|
|
pub const parse_sanitizer_memory_track_origins: &str = "0, 1, or 2";
|
2020-06-16 17:44:03 +01:00
|
|
|
pub const parse_cfguard: &str =
|
|
|
|
"either a boolean (`yes`, `no`, `on`, `off`, etc), `checks`, or `nochecks`";
|
2020-05-03 12:36:12 +08:00
|
|
|
pub const parse_strip: &str = "either `none`, `debuginfo`, or `symbols`";
|
2020-04-03 14:15:10 +11:00
|
|
|
pub const parse_linker_flavor: &str = ::rustc_target::spec::LinkerFlavor::one_of();
|
|
|
|
pub const parse_optimization_fuel: &str = "crate=integer";
|
2020-08-29 10:55:46 -07:00
|
|
|
pub const parse_mir_spanview: &str = "`statement` (default), `terminator`, or `block`";
|
2020-04-03 14:15:10 +11:00
|
|
|
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_lto: &str =
|
|
|
|
"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_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`";
|
|
|
|
pub const parse_symbol_mangling_version: &str = "either `legacy` or `v0` (RFC 2603)";
|
|
|
|
pub const parse_src_file_hash: &str = "either `md5` or `sha1`";
|
2020-04-23 00:46:45 +03:00
|
|
|
pub const parse_relocation_model: &str =
|
|
|
|
"one of supported relocation models (`rustc --print relocation-models`)";
|
2020-05-07 03:34:27 +03:00
|
|
|
pub const parse_code_model: &str =
|
|
|
|
"one of supported code models (`rustc --print code-models`)";
|
2020-04-25 21:45:21 +03:00
|
|
|
pub const parse_tls_model: &str =
|
|
|
|
"one of supported TLS models (`rustc --print tls-models`)";
|
2020-05-11 00:16:16 +03:00
|
|
|
pub const parse_target_feature: &str = parse_string;
|
2019-12-17 23:22:55 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
#[allow(dead_code)]
|
|
|
|
mod $mod_set {
|
2020-04-23 00:46:45 +03:00
|
|
|
use super::*;
|
2019-12-17 23:22:55 +11:00
|
|
|
use std::str::FromStr;
|
|
|
|
|
2020-04-01 19:17:08 +03:00
|
|
|
// Sometimes different options need to build a common structure.
|
|
|
|
// That structure can kept in one of the options' fields, the others become dummy.
|
|
|
|
macro_rules! redirect_field {
|
|
|
|
($cg:ident.link_arg) => { $cg.link_args };
|
|
|
|
($cg:ident.pre_link_arg) => { $cg.pre_link_args };
|
|
|
|
($cg:ident.$field:ident) => { $cg.$field };
|
|
|
|
}
|
|
|
|
|
2019-12-17 23:22:55 +11:00
|
|
|
$(
|
|
|
|
pub fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool {
|
2020-04-01 19:17:08 +03:00
|
|
|
$parse(&mut redirect_field!(cg.$opt), v)
|
2019-12-17 23:22:55 +11:00
|
|
|
}
|
|
|
|
)*
|
|
|
|
|
2020-04-06 09:29:19 +10:00
|
|
|
/// This is for boolean options that don't take a value and start with
|
|
|
|
/// `no-`. This style of option is deprecated.
|
|
|
|
fn parse_no_flag(slot: &mut bool, v: Option<&str>) -> bool {
|
|
|
|
match v {
|
|
|
|
None => { *slot = true; true }
|
|
|
|
Some(_) => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-02 15:47:11 +11:00
|
|
|
/// Use this for any boolean option that has a static default.
|
2019-12-17 23:22:55 +11:00
|
|
|
fn parse_bool(slot: &mut bool, v: Option<&str>) -> bool {
|
|
|
|
match v {
|
2020-04-02 15:47:11 +11:00
|
|
|
Some("y") | Some("yes") | Some("on") | None => { *slot = true; true }
|
|
|
|
Some("n") | Some("no") | Some("off") => { *slot = false; true }
|
|
|
|
_ => false,
|
2019-12-17 23:22:55 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-02 15:47:11 +11:00
|
|
|
/// Use this for any boolean option that lacks a static default. (The
|
|
|
|
/// actions taken when such an option is not specified will depend on
|
|
|
|
/// other factors, such as other options, or target options.)
|
2019-12-17 23:22:55 +11:00
|
|
|
fn parse_opt_bool(slot: &mut Option<bool>, v: Option<&str>) -> bool {
|
|
|
|
match v {
|
2020-04-02 15:47:11 +11:00
|
|
|
Some("y") | Some("yes") | Some("on") | None => { *slot = Some(true); true }
|
|
|
|
Some("n") | Some("no") | Some("off") => { *slot = Some(false); true }
|
|
|
|
_ => false,
|
2019-12-17 23:22:55 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-02 15:47:11 +11:00
|
|
|
/// Use this for any string option that has a static default.
|
|
|
|
fn parse_string(slot: &mut String, v: Option<&str>) -> bool {
|
2019-12-17 23:22:55 +11:00
|
|
|
match v {
|
2020-04-02 15:47:11 +11:00
|
|
|
Some(s) => { *slot = s.to_string(); true },
|
2019-12-17 23:22:55 +11:00
|
|
|
None => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-02 15:47:11 +11:00
|
|
|
/// Use this for any string option that lacks a static default.
|
|
|
|
fn parse_opt_string(slot: &mut Option<String>, v: Option<&str>) -> bool {
|
2019-12-17 23:22:55 +11:00
|
|
|
match v {
|
2020-04-02 15:47:11 +11:00
|
|
|
Some(s) => { *slot = Some(s.to_string()); true },
|
2019-12-17 23:22:55 +11:00
|
|
|
None => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-02 15:47:11 +11:00
|
|
|
fn parse_opt_pathbuf(slot: &mut Option<PathBuf>, v: Option<&str>) -> bool {
|
2019-12-17 23:22:55 +11:00
|
|
|
match v {
|
2020-04-02 15:47:11 +11:00
|
|
|
Some(s) => { *slot = Some(PathBuf::from(s)); true },
|
2019-12-17 23:22:55 +11:00
|
|
|
None => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parse_string_push(slot: &mut Vec<String>, v: Option<&str>) -> bool {
|
|
|
|
match v {
|
|
|
|
Some(s) => { slot.push(s.to_string()); true },
|
|
|
|
None => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parse_pathbuf_push(slot: &mut Vec<PathBuf>, v: Option<&str>) -> bool {
|
|
|
|
match v {
|
|
|
|
Some(s) => { slot.push(PathBuf::from(s)); true },
|
|
|
|
None => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parse_list(slot: &mut Vec<String>, v: Option<&str>)
|
|
|
|
-> bool {
|
|
|
|
match v {
|
|
|
|
Some(s) => {
|
|
|
|
slot.extend(s.split_whitespace().map(|s| s.to_string()));
|
|
|
|
true
|
|
|
|
},
|
|
|
|
None => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parse_opt_list(slot: &mut Option<Vec<String>>, v: Option<&str>)
|
|
|
|
-> bool {
|
|
|
|
match v {
|
|
|
|
Some(s) => {
|
|
|
|
let v = s.split_whitespace().map(|s| s.to_string()).collect();
|
|
|
|
*slot = Some(v);
|
|
|
|
true
|
|
|
|
},
|
|
|
|
None => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parse_opt_comma_list(slot: &mut Option<Vec<String>>, v: Option<&str>)
|
|
|
|
-> bool {
|
|
|
|
match v {
|
|
|
|
Some(s) => {
|
|
|
|
let v = s.split(',').map(|s| s.to_string()).collect();
|
|
|
|
*slot = Some(v);
|
|
|
|
true
|
|
|
|
},
|
|
|
|
None => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parse_threads(slot: &mut usize, v: Option<&str>) -> bool {
|
|
|
|
match v.and_then(|s| s.parse().ok()) {
|
|
|
|
Some(0) => { *slot = ::num_cpus::get(); true },
|
|
|
|
Some(i) => { *slot = i; true },
|
|
|
|
None => false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-02 15:47:11 +11:00
|
|
|
/// Use this for any uint option that has a static default.
|
2019-12-17 23:22:55 +11:00
|
|
|
fn parse_uint(slot: &mut usize, v: Option<&str>) -> bool {
|
|
|
|
match v.and_then(|s| s.parse().ok()) {
|
|
|
|
Some(i) => { *slot = i; true },
|
|
|
|
None => false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-02 15:47:11 +11:00
|
|
|
/// Use this for any uint option that lacks a static default.
|
2019-12-17 23:22:55 +11:00
|
|
|
fn parse_opt_uint(slot: &mut Option<usize>, v: Option<&str>) -> bool {
|
|
|
|
match v {
|
|
|
|
Some(s) => { *slot = s.parse().ok(); slot.is_some() }
|
2020-04-03 14:02:44 +11:00
|
|
|
None => false
|
2019-12-17 23:22:55 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parse_passes(slot: &mut Passes, v: Option<&str>) -> bool {
|
|
|
|
match v {
|
|
|
|
Some("all") => {
|
|
|
|
*slot = Passes::All;
|
|
|
|
true
|
|
|
|
}
|
|
|
|
v => {
|
|
|
|
let mut passes = vec![];
|
|
|
|
if parse_list(&mut passes, v) {
|
|
|
|
*slot = Passes::Some(passes);
|
|
|
|
true
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parse_panic_strategy(slot: &mut Option<PanicStrategy>, v: Option<&str>) -> bool {
|
|
|
|
match v {
|
|
|
|
Some("unwind") => *slot = Some(PanicStrategy::Unwind),
|
|
|
|
Some("abort") => *slot = Some(PanicStrategy::Abort),
|
|
|
|
_ => return false
|
|
|
|
}
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parse_relro_level(slot: &mut Option<RelroLevel>, v: Option<&str>) -> bool {
|
|
|
|
match v {
|
|
|
|
Some(s) => {
|
|
|
|
match s.parse::<RelroLevel>() {
|
|
|
|
Ok(level) => *slot = Some(level),
|
|
|
|
_ => return false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
_ => return false
|
|
|
|
}
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
2020-06-14 00:00:00 +00:00
|
|
|
fn parse_sanitizers(slot: &mut SanitizerSet, v: Option<&str>) -> bool {
|
2019-12-17 23:22:55 +11:00
|
|
|
if let Some(v) = v {
|
2020-06-14 00:00:00 +00:00
|
|
|
for s in v.split(',') {
|
|
|
|
*slot |= match s {
|
|
|
|
"address" => SanitizerSet::ADDRESS,
|
|
|
|
"leak" => SanitizerSet::LEAK,
|
|
|
|
"memory" => SanitizerSet::MEMORY,
|
|
|
|
"thread" => SanitizerSet::THREAD,
|
|
|
|
_ => return false,
|
2019-12-17 23:22:55 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
true
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parse_sanitizer_memory_track_origins(slot: &mut usize, v: Option<&str>) -> bool {
|
2020-04-02 15:58:07 +11:00
|
|
|
match v {
|
|
|
|
Some("2") | None => { *slot = 2; true }
|
|
|
|
Some("1") => { *slot = 1; true }
|
|
|
|
Some("0") => { *slot = 0; true }
|
|
|
|
Some(_) => false,
|
2019-12-17 23:22:55 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-03 12:36:12 +08:00
|
|
|
fn parse_strip(slot: &mut Strip, v: Option<&str>) -> bool {
|
|
|
|
match v {
|
|
|
|
Some("none") => *slot = Strip::None,
|
|
|
|
Some("debuginfo") => *slot = Strip::Debuginfo,
|
|
|
|
Some("symbols") => *slot = Strip::Symbols,
|
|
|
|
_ => return false,
|
|
|
|
}
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
2020-01-13 13:25:39 +00:00
|
|
|
fn parse_cfguard(slot: &mut CFGuard, v: Option<&str>) -> bool {
|
2020-06-16 17:44:03 +01:00
|
|
|
if v.is_some() {
|
|
|
|
let mut bool_arg = None;
|
|
|
|
if parse_opt_bool(&mut bool_arg, v) {
|
|
|
|
*slot = if bool_arg.unwrap() {
|
|
|
|
CFGuard::Checks
|
|
|
|
} else {
|
|
|
|
CFGuard::Disabled
|
|
|
|
};
|
|
|
|
return true
|
|
|
|
}
|
2020-01-13 13:25:39 +00:00
|
|
|
}
|
2020-06-16 17:44:03 +01:00
|
|
|
|
|
|
|
*slot = match v {
|
|
|
|
None => CFGuard::Checks,
|
|
|
|
Some("checks") => CFGuard::Checks,
|
|
|
|
Some("nochecks") => CFGuard::NoChecks,
|
|
|
|
Some(_) => return false,
|
|
|
|
};
|
2020-01-13 13:25:39 +00:00
|
|
|
true
|
|
|
|
}
|
|
|
|
|
2019-12-17 23:22:55 +11:00
|
|
|
fn parse_linker_flavor(slote: &mut Option<LinkerFlavor>, v: Option<&str>) -> bool {
|
|
|
|
match v.and_then(LinkerFlavor::from_str) {
|
|
|
|
Some(lf) => *slote = Some(lf),
|
|
|
|
_ => return false,
|
|
|
|
}
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parse_optimization_fuel(slot: &mut Option<(String, u64)>, v: Option<&str>) -> bool {
|
|
|
|
match v {
|
|
|
|
None => false,
|
|
|
|
Some(s) => {
|
|
|
|
let parts = s.split('=').collect::<Vec<_>>();
|
|
|
|
if parts.len() != 2 { return false; }
|
|
|
|
let crate_name = parts[0].to_string();
|
|
|
|
let fuel = parts[1].parse::<u64>();
|
|
|
|
if fuel.is_err() { return false; }
|
|
|
|
*slot = Some((crate_name, fuel.unwrap()));
|
|
|
|
true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parse_unpretty(slot: &mut Option<String>, v: Option<&str>) -> bool {
|
|
|
|
match v {
|
|
|
|
None => false,
|
|
|
|
Some(s) if s.split('=').count() <= 2 => {
|
|
|
|
*slot = Some(s.to_string());
|
|
|
|
true
|
|
|
|
}
|
|
|
|
_ => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-29 10:55:46 -07:00
|
|
|
fn parse_mir_spanview(slot: &mut Option<MirSpanview>, 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(MirSpanview::Statement)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
};
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let v = match v {
|
|
|
|
None => {
|
|
|
|
*slot = Some(MirSpanview::Statement);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
Some(v) => v,
|
|
|
|
};
|
|
|
|
|
|
|
|
*slot = Some(match v.trim_end_matches("s") {
|
|
|
|
"statement" | "stmt" => MirSpanview::Statement,
|
|
|
|
"terminator" | "term" => MirSpanview::Terminator,
|
|
|
|
"block" | "basicblock" => MirSpanview::Block,
|
|
|
|
_ => return false,
|
|
|
|
});
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
2019-12-17 23:22:55 +11:00
|
|
|
fn parse_treat_err_as_bug(slot: &mut Option<usize>, v: Option<&str>) -> bool {
|
|
|
|
match v {
|
|
|
|
Some(s) => { *slot = s.parse().ok().filter(|&x| x != 0); slot.unwrap_or(0) != 0 }
|
|
|
|
None => { *slot = Some(1); true }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parse_lto(slot: &mut LtoCli, 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() {
|
|
|
|
LtoCli::Yes
|
|
|
|
} else {
|
|
|
|
LtoCli::No
|
|
|
|
};
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*slot = match v {
|
|
|
|
None => LtoCli::NoParam,
|
|
|
|
Some("thin") => LtoCli::Thin,
|
|
|
|
Some("fat") => LtoCli::Fat,
|
|
|
|
Some(_) => return false,
|
|
|
|
};
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parse_linker_plugin_lto(slot: &mut LinkerPluginLto, 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() {
|
|
|
|
LinkerPluginLto::LinkerPluginAuto
|
|
|
|
} else {
|
|
|
|
LinkerPluginLto::Disabled
|
|
|
|
};
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*slot = match v {
|
|
|
|
None => LinkerPluginLto::LinkerPluginAuto,
|
|
|
|
Some(path) => LinkerPluginLto::LinkerPlugin(PathBuf::from(path)),
|
|
|
|
};
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parse_switch_with_opt_path(slot: &mut SwitchWithOptPath, v: Option<&str>) -> bool {
|
|
|
|
*slot = match v {
|
|
|
|
None => SwitchWithOptPath::Enabled(None),
|
|
|
|
Some(path) => SwitchWithOptPath::Enabled(Some(PathBuf::from(path))),
|
|
|
|
};
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parse_merge_functions(slot: &mut Option<MergeFunctions>, v: Option<&str>) -> bool {
|
|
|
|
match v.and_then(|s| MergeFunctions::from_str(s).ok()) {
|
|
|
|
Some(mergefunc) => *slot = Some(mergefunc),
|
|
|
|
_ => return false,
|
|
|
|
}
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
2020-04-23 00:46:45 +03:00
|
|
|
fn parse_relocation_model(slot: &mut Option<RelocModel>, v: Option<&str>) -> bool {
|
|
|
|
match v.and_then(|s| RelocModel::from_str(s).ok()) {
|
|
|
|
Some(relocation_model) => *slot = Some(relocation_model),
|
|
|
|
None if v == Some("default") => *slot = None,
|
|
|
|
_ => return false,
|
|
|
|
}
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
2020-05-07 03:34:27 +03:00
|
|
|
fn parse_code_model(slot: &mut Option<CodeModel>, v: Option<&str>) -> bool {
|
|
|
|
match v.and_then(|s| CodeModel::from_str(s).ok()) {
|
|
|
|
Some(code_model) => *slot = Some(code_model),
|
|
|
|
_ => return false,
|
|
|
|
}
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
2020-04-25 21:45:21 +03:00
|
|
|
fn parse_tls_model(slot: &mut Option<TlsModel>, v: Option<&str>) -> bool {
|
|
|
|
match v.and_then(|s| TlsModel::from_str(s).ok()) {
|
|
|
|
Some(tls_model) => *slot = Some(tls_model),
|
|
|
|
_ => return false,
|
|
|
|
}
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
2019-12-17 23:22:55 +11:00
|
|
|
fn parse_symbol_mangling_version(
|
|
|
|
slot: &mut SymbolManglingVersion,
|
|
|
|
v: Option<&str>,
|
|
|
|
) -> bool {
|
|
|
|
*slot = match v {
|
|
|
|
Some("legacy") => SymbolManglingVersion::Legacy,
|
|
|
|
Some("v0") => SymbolManglingVersion::V0,
|
|
|
|
_ => return false,
|
|
|
|
};
|
|
|
|
true
|
|
|
|
}
|
2020-03-30 22:17:15 -07:00
|
|
|
|
|
|
|
fn parse_src_file_hash(slot: &mut Option<SourceFileHashAlgorithm>, v: Option<&str>) -> bool {
|
|
|
|
match v.and_then(|s| SourceFileHashAlgorithm::from_str(s).ok()) {
|
|
|
|
Some(hash_kind) => *slot = Some(hash_kind),
|
|
|
|
_ => return false,
|
|
|
|
}
|
|
|
|
true
|
|
|
|
}
|
2020-05-11 00:16:16 +03:00
|
|
|
|
|
|
|
fn parse_target_feature(slot: &mut String, v: Option<&str>) -> bool {
|
|
|
|
match v {
|
|
|
|
Some(s) => {
|
|
|
|
if !slot.is_empty() {
|
|
|
|
slot.push_str(",");
|
|
|
|
}
|
|
|
|
slot.push_str(s);
|
|
|
|
true
|
|
|
|
}
|
|
|
|
None => false,
|
|
|
|
}
|
|
|
|
}
|
2019-12-17 23:22:55 +11:00
|
|
|
}
|
|
|
|
) }
|
|
|
|
|
|
|
|
options! {CodegenOptions, CodegenSetter, basic_codegen_options,
|
|
|
|
build_codegen_options, "C", "codegen",
|
|
|
|
CG_OPTIONS, cg_type_desc, cgsetters,
|
2020-04-21 10:06:13 +10:00
|
|
|
|
|
|
|
// This list is in alphabetical order.
|
|
|
|
//
|
|
|
|
// If you add a new option, please update:
|
|
|
|
// - src/librustc_interface/tests.rs
|
|
|
|
// - src/doc/rustc/src/codegen-options/index.md
|
|
|
|
|
2020-04-02 16:44:47 +11:00
|
|
|
ar: String = (String::new(), parse_string, [UNTRACKED],
|
2019-12-17 23:22:55 +11:00
|
|
|
"this option is deprecated and does nothing"),
|
2020-05-07 03:34:27 +03:00
|
|
|
code_model: Option<CodeModel> = (None, parse_code_model, [TRACKED],
|
2020-04-21 10:06:13 +10:00
|
|
|
"choose the code model to use (`rustc --print code-models` for details)"),
|
|
|
|
codegen_units: Option<usize> = (None, parse_opt_uint, [UNTRACKED],
|
|
|
|
"divide crate into N units to optimize in parallel"),
|
2020-07-14 15:27:42 +01:00
|
|
|
control_flow_guard: CFGuard = (CFGuard::Disabled, parse_cfguard, [TRACKED],
|
|
|
|
"use Windows Control Flow Guard (default: no)"),
|
2020-04-21 10:06:13 +10:00
|
|
|
debug_assertions: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
|
|
|
"explicitly enable the `cfg(debug_assertions)` directive"),
|
|
|
|
debuginfo: usize = (0, parse_uint, [TRACKED],
|
|
|
|
"debug info emission level (0 = no debug info, 1 = line tables only, \
|
|
|
|
2 = full debug info with variable and type information; default: 0)"),
|
|
|
|
default_linker_libraries: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"allow the linker to link its default libraries (default: no)"),
|
2020-04-30 10:53:16 -07:00
|
|
|
embed_bitcode: bool = (true, parse_bool, [TRACKED],
|
|
|
|
"emit bitcode in rlibs (default: yes)"),
|
2020-04-21 10:06:13 +10:00
|
|
|
extra_filename: String = (String::new(), parse_string, [UNTRACKED],
|
|
|
|
"extra data to put in each output filename"),
|
|
|
|
force_frame_pointers: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
|
|
|
"force use of the frame pointers"),
|
Add Option to Force Unwind Tables
When panic != unwind, `nounwind` is added to all functions for a target.
This can cause issues when a panic happens with RUST_BACKTRACE=1, as
there needs to be a way to reconstruct the backtrace. There are three
possible sources of this information: forcing frame pointers (for which
an option exists already), debug info (for which an option exists), or
unwind tables.
Especially for embedded devices, forcing frame pointers can have code
size overheads (RISC-V sees ~10% overheads, ARM sees ~2-3% overheads).
In code, it can be the case that debug info is not kept, so it is useful
to provide this third option, unwind tables, that users can use to
reconstruct the call stack. Reconstructing this stack is harder than
with frame pointers, but it is still possible.
This commit adds a compiler option which allows a user to force the
addition of unwind tables. Unwind tables cannot be disabled on targets
that require them for correctness, or when using `-C panic=unwind`.
2020-05-04 12:08:35 +01:00
|
|
|
force_unwind_tables: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
|
|
|
"force use of unwind tables"),
|
2020-04-21 10:06:13 +10:00
|
|
|
incremental: Option<String> = (None, parse_opt_string, [UNTRACKED],
|
|
|
|
"enable incremental compilation"),
|
|
|
|
inline_threshold: Option<usize> = (None, parse_opt_uint, [TRACKED],
|
|
|
|
"set the threshold for inlining a function"),
|
2020-04-01 19:17:08 +03:00
|
|
|
link_arg: (/* redirected to link_args */) = ((), parse_string_push, [UNTRACKED],
|
2019-12-17 23:22:55 +11:00
|
|
|
"a single extra argument to append to the linker invocation (can be used several times)"),
|
2020-04-01 19:17:08 +03:00
|
|
|
link_args: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],
|
2019-12-17 23:22:55 +11:00
|
|
|
"extra arguments to append to the linker invocation (space separated)"),
|
2020-07-02 11:27:15 -07:00
|
|
|
link_dead_code: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
|
2020-04-03 10:42:29 +11:00
|
|
|
"keep dead code at link time (useful for code coverage) (default: no)"),
|
2020-07-30 22:10:48 +02:00
|
|
|
link_self_contained: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
|
|
|
|
"control whether to link Rust provided C objects/libraries or rely
|
|
|
|
on C toolchain installed in the system"),
|
2020-04-21 10:06:13 +10:00
|
|
|
linker: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
|
|
|
|
"system linker to link outputs with"),
|
|
|
|
linker_flavor: Option<LinkerFlavor> = (None, parse_linker_flavor, [UNTRACKED],
|
|
|
|
"linker flavor"),
|
|
|
|
linker_plugin_lto: LinkerPluginLto = (LinkerPluginLto::Disabled,
|
|
|
|
parse_linker_plugin_lto, [TRACKED],
|
|
|
|
"generate build artifacts that are compatible with linker-based LTO"),
|
2019-12-17 23:22:55 +11:00
|
|
|
llvm_args: Vec<String> = (Vec::new(), parse_list, [TRACKED],
|
|
|
|
"a list of arguments to pass to LLVM (space separated)"),
|
2020-04-21 10:06:13 +10:00
|
|
|
lto: LtoCli = (LtoCli::Unspecified, parse_lto, [TRACKED],
|
|
|
|
"perform LLVM link-time optimizations"),
|
|
|
|
metadata: Vec<String> = (Vec::new(), parse_list, [TRACKED],
|
|
|
|
"metadata to mangle symbol names with"),
|
2020-04-06 09:29:19 +10:00
|
|
|
no_prepopulate_passes: bool = (false, parse_no_flag, [TRACKED],
|
|
|
|
"give an empty list of passes to the pass manager"),
|
2019-12-17 23:22:55 +11:00
|
|
|
no_redzone: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
|
|
|
"disable the use of the redzone"),
|
2020-04-06 09:29:19 +10:00
|
|
|
no_stack_check: bool = (false, parse_no_flag, [UNTRACKED],
|
2020-04-03 10:42:29 +11:00
|
|
|
"this option is deprecated and does nothing"),
|
2020-04-21 10:06:13 +10:00
|
|
|
no_vectorize_loops: bool = (false, parse_no_flag, [TRACKED],
|
|
|
|
"disable loop vectorization optimization passes"),
|
|
|
|
no_vectorize_slp: bool = (false, parse_no_flag, [TRACKED],
|
|
|
|
"disable LLVM's SLP vectorization pass"),
|
2020-04-02 16:44:47 +11:00
|
|
|
opt_level: String = ("0".to_string(), parse_string, [TRACKED],
|
2020-04-03 10:42:29 +11:00
|
|
|
"optimization level (0-3, s, or z; default: 0)"),
|
2020-04-21 10:06:13 +10:00
|
|
|
overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
|
|
|
"use overflow checks for integer arithmetic"),
|
|
|
|
panic: Option<PanicStrategy> = (None, parse_panic_strategy, [TRACKED],
|
|
|
|
"panic strategy to compile crate with"),
|
|
|
|
passes: Vec<String> = (Vec::new(), parse_list, [TRACKED],
|
|
|
|
"a list of extra LLVM passes to run (space separated)"),
|
|
|
|
prefer_dynamic: bool = (false, parse_bool, [TRACKED],
|
|
|
|
"prefer dynamic linking to static linking (default: no)"),
|
2019-12-17 23:22:55 +11:00
|
|
|
profile_generate: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
|
|
|
|
parse_switch_with_opt_path, [TRACKED],
|
|
|
|
"compile the program with profiling instrumentation"),
|
|
|
|
profile_use: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
|
|
|
|
"use the given `.profdata` file for profile-guided optimization"),
|
2020-04-23 00:46:45 +03:00
|
|
|
relocation_model: Option<RelocModel> = (None, parse_relocation_model, [TRACKED],
|
2020-04-24 00:53:25 +03:00
|
|
|
"control generation of position-independent code (PIC) \
|
|
|
|
(`rustc --print relocation-models` for details)"),
|
2020-04-21 10:06:13 +10:00
|
|
|
remark: Passes = (Passes::Some(Vec::new()), parse_passes, [UNTRACKED],
|
|
|
|
"print remarks for these optimization passes (space separated, or \"all\")"),
|
|
|
|
rpath: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"set rpath values in libs/exes (default: no)"),
|
|
|
|
save_temps: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"save all temporary output files during compilation (default: no)"),
|
|
|
|
soft_float: bool = (false, parse_bool, [TRACKED],
|
|
|
|
"use soft float ABI (*eabihf targets only) (default: no)"),
|
|
|
|
target_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
|
|
|
|
"select target processor (`rustc --print target-cpus` for details)"),
|
2020-05-11 00:16:16 +03:00
|
|
|
target_feature: String = (String::new(), parse_target_feature, [TRACKED],
|
2020-04-21 10:06:13 +10:00
|
|
|
"target specific attributes. (`rustc --print target-features` for details). \
|
|
|
|
This feature is unsafe."),
|
|
|
|
|
|
|
|
// This list is in alphabetical order.
|
|
|
|
//
|
|
|
|
// If you add a new option, please update:
|
|
|
|
// - src/librustc_interface/tests.rs
|
|
|
|
// - src/doc/rustc/src/codegen-options/index.md
|
2019-12-17 23:22:55 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
|
|
|
build_debugging_options, "Z", "debugging",
|
|
|
|
DB_OPTIONS, db_type_desc, dbsetters,
|
2020-04-21 10:06:13 +10:00
|
|
|
|
|
|
|
// This list is in alphabetical order.
|
|
|
|
//
|
|
|
|
// If you add a new option, please update:
|
|
|
|
// - src/librustc_interface/tests.rs
|
|
|
|
|
|
|
|
allow_features: Option<Vec<String>> = (None, parse_opt_comma_list, [TRACKED],
|
|
|
|
"only allow the listed language features to be enabled in code (space separated)"),
|
|
|
|
always_encode_mir: bool = (false, parse_bool, [TRACKED],
|
|
|
|
"encode MIR of all functions into the crate metadata (default: no)"),
|
2019-12-17 23:22:55 +11:00
|
|
|
asm_comments: bool = (false, parse_bool, [TRACKED],
|
2020-04-03 10:42:29 +11:00
|
|
|
"generate comments into the assembly (may change behavior) (default: no)"),
|
2019-12-17 23:22:55 +11:00
|
|
|
ast_json: bool = (false, parse_bool, [UNTRACKED],
|
2020-04-03 10:42:29 +11:00
|
|
|
"print the AST as JSON and halt (default: no)"),
|
2019-12-17 23:22:55 +11:00
|
|
|
ast_json_noexpand: bool = (false, parse_bool, [UNTRACKED],
|
2020-04-03 10:42:29 +11:00
|
|
|
"print the pre-expansion AST as JSON and halt (default: no)"),
|
2020-04-21 10:06:13 +10:00
|
|
|
binary_dep_depinfo: bool = (false, parse_bool, [TRACKED],
|
|
|
|
"include artifacts (sysroot, crate dependencies) used during compilation in dep-info \
|
|
|
|
(default: no)"),
|
|
|
|
borrowck: String = ("migrate".to_string(), parse_string, [UNTRACKED],
|
|
|
|
"select which borrowck is used (`mir` or `migrate`) (default: `migrate`)"),
|
|
|
|
borrowck_stats: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"gather borrowck statistics (default: no)"),
|
2020-07-11 22:32:42 -04:00
|
|
|
cgu_partitioning_strategy: Option<String> = (None, parse_opt_string, [TRACKED],
|
|
|
|
"the codegen unit partitioning strategy to use"),
|
2020-03-03 11:25:03 -05:00
|
|
|
chalk: bool = (false, parse_bool, [TRACKED],
|
|
|
|
"enable the experimental Chalk-based trait solving engine"),
|
2020-04-21 10:06:13 +10:00
|
|
|
codegen_backend: Option<String> = (None, parse_opt_string, [TRACKED],
|
|
|
|
"the backend to use"),
|
|
|
|
crate_attr: Vec<String> = (Vec::new(), parse_string_push, [TRACKED],
|
|
|
|
"inject the given attribute in the crate"),
|
|
|
|
debug_macros: bool = (false, parse_bool, [TRACKED],
|
|
|
|
"emit line numbers debug info inside macros (default: no)"),
|
|
|
|
deduplicate_diagnostics: bool = (true, parse_bool, [UNTRACKED],
|
|
|
|
"deduplicate identical diagnostics (default: yes)"),
|
|
|
|
dep_info_omit_d_target: bool = (false, parse_bool, [TRACKED],
|
|
|
|
"in dep-info output, omit targets for tracking dependencies of the dep-info files \
|
|
|
|
themselves (default: no)"),
|
2019-12-17 23:22:55 +11:00
|
|
|
dep_tasks: bool = (false, parse_bool, [UNTRACKED],
|
2020-04-03 10:42:29 +11:00
|
|
|
"print tasks that execute and the color their dep node gets (requires debug build) \
|
|
|
|
(default: no)"),
|
2020-04-21 10:06:13 +10:00
|
|
|
dont_buffer_diagnostics: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"emit diagnostics rather than buffering (breaks NLL error downgrading, sorting) \
|
2020-04-03 10:42:29 +11:00
|
|
|
(default: no)"),
|
2020-04-21 10:06:13 +10:00
|
|
|
dual_proc_macros: bool = (false, parse_bool, [TRACKED],
|
|
|
|
"load proc macros for both target and host, but only link to the target (default: no)"),
|
2019-12-17 23:22:55 +11:00
|
|
|
dump_dep_graph: bool = (false, parse_bool, [UNTRACKED],
|
2020-04-03 10:42:29 +11:00
|
|
|
"dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv) \
|
|
|
|
(default: no)"),
|
2019-12-17 23:22:55 +11:00
|
|
|
dump_mir: Option<String> = (None, parse_opt_string, [UNTRACKED],
|
|
|
|
"dump MIR state to file.
|
|
|
|
`val` is used to select which passes and functions to dump. For example:
|
|
|
|
`all` matches all passes and functions,
|
|
|
|
`foo` matches all passes for functions whose name contains 'foo',
|
|
|
|
`foo & ConstProp` only the 'ConstProp' pass for function names containing 'foo',
|
|
|
|
`foo | bar` all passes for function names containing 'foo' or 'bar'."),
|
2020-04-21 10:06:13 +10:00
|
|
|
dump_mir_dataflow: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"in addition to `.mir` files, create graphviz `.dot` files with dataflow results \
|
|
|
|
(default: no)"),
|
2020-04-02 16:44:47 +11:00
|
|
|
dump_mir_dir: String = ("mir_dump".to_string(), parse_string, [UNTRACKED],
|
2020-04-03 10:42:29 +11:00
|
|
|
"the directory the MIR is dumped into (default: `mir_dump`)"),
|
2019-12-17 23:22:55 +11:00
|
|
|
dump_mir_exclude_pass_number: bool = (false, parse_bool, [UNTRACKED],
|
2020-04-03 10:42:29 +11:00
|
|
|
"exclude the pass number when dumping MIR (used in tests) (default: no)"),
|
2020-04-21 10:06:13 +10:00
|
|
|
dump_mir_graphviz: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"in addition to `.mir` files, create graphviz `.dot` files (default: no)"),
|
2020-08-29 10:55:46 -07:00
|
|
|
dump_mir_spanview: Option<MirSpanview> = (None, parse_mir_spanview, [UNTRACKED],
|
|
|
|
"in addition to `.mir` files, create `.html` files to view spans for \
|
|
|
|
all `statement`s (including terminators), only `terminator` spans, or \
|
|
|
|
computed `block` spans (one span encompassing a block's terminator and \
|
|
|
|
all statements)."),
|
2020-04-21 10:06:13 +10:00
|
|
|
emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"emit a section containing stack size metadata (default: no)"),
|
Tools, tests, and experimenting with MIR-derived coverage counters
Adds a new mir_dump output file in HTML/CSS to visualize code regions
and the MIR features that they came from (including overlapping spans).
See example below:
Includes a basic, MIR-block-based implementation of coverage injection,
available via `-Zexperimental-coverage`. This implementation has known
flaws and omissions, but is simple enough to validate the new tools and
tests.
The existing `-Zinstrument-coverage` option currently enables
function-level coverage only, which at least appears to generate
accurate coverage reports at that level.
Experimental coverage is not accurate at this time. When branch coverage
works as intended, the `-Zexperimental-coverage` option should be
removed.
This PR replaces the bulk of PR #75828, with the remaining parts of
that PR distributed among other separate and indentpent PRs.
This PR depends on three of those other PRs: #76000, #76002, and
Rust compiler MCP rust-lang/compiler-team#278
Relevant issue: #34701 - Implement support for LLVMs code coverage
instrumentation

2020-08-27 14:13:04 -07:00
|
|
|
experimental_coverage: bool = (false, parse_bool, [TRACKED],
|
|
|
|
"enable and extend the `-Z instrument-coverage` function-level coverage \
|
|
|
|
feature, adding additional experimental (likely inaccurate) counters and \
|
|
|
|
code regions (used by `rustc` compiler developers to test new coverage \
|
|
|
|
counter placements) (default: no)"),
|
2020-04-21 10:06:13 +10:00
|
|
|
fewer_names: bool = (false, parse_bool, [TRACKED],
|
|
|
|
"reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR) \
|
|
|
|
(default: no)"),
|
|
|
|
force_overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
|
|
|
"force overflow checks on or off"),
|
|
|
|
force_unstable_if_unmarked: bool = (false, parse_bool, [TRACKED],
|
|
|
|
"force all crates to be `rustc_private` unstable (default: no)"),
|
|
|
|
fuel: Option<(String, u64)> = (None, parse_optimization_fuel, [TRACKED],
|
|
|
|
"set the optimization fuel quota for a crate"),
|
|
|
|
hir_stats: bool = (false, parse_bool, [UNTRACKED],
|
2020-04-03 10:42:29 +11:00
|
|
|
"print some statistics about AST and HIR (default: no)"),
|
2020-04-21 10:06:13 +10:00
|
|
|
human_readable_cgu_names: bool = (false, parse_bool, [TRACKED],
|
|
|
|
"generate human-readable, predictable names for codegen units (default: no)"),
|
|
|
|
identify_regions: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"display unnamed regions as `'<id>`, using a non-ident unique id (default: no)"),
|
|
|
|
incremental_ignore_spans: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"ignore spans during ICH computation -- used for testing (default: no)"),
|
|
|
|
incremental_info: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"print high-level information about incremental reuse (or the lack thereof) \
|
|
|
|
(default: no)"),
|
|
|
|
incremental_verify_ich: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"verify incr. comp. hashes of green query instances (default: no)"),
|
|
|
|
inline_in_all_cgus: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
|
|
|
"control whether `#[inline]` functions are in all CGUs"),
|
|
|
|
input_stats: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"gather statistics about the input (default: no)"),
|
|
|
|
insert_sideeffect: bool = (false, parse_bool, [TRACKED],
|
|
|
|
"fix undefined behavior when a thread doesn't eventually make progress \
|
|
|
|
(such as entering an empty infinite loop) by inserting llvm.sideeffect \
|
|
|
|
(default: no)"),
|
2020-06-03 21:19:34 -07:00
|
|
|
instrument_coverage: bool = (false, parse_bool, [TRACKED],
|
2020-07-02 11:27:15 -07:00
|
|
|
"instrument the generated code to support LLVM source-based code coverage \
|
|
|
|
reports (note, the compiler build config must include `profiler = true`, \
|
|
|
|
and is mutually exclusive with `-C profile-generate`/`-C profile-use`); \
|
2020-08-27 12:53:43 -07:00
|
|
|
implies `-C link-dead-code` (unless targeting MSVC, or explicitly disabled) \
|
|
|
|
and `-Z symbol-mangling-version=v0`; disables/overrides some Rust \
|
|
|
|
optimizations (default: no)"),
|
2020-04-21 10:06:13 +10:00
|
|
|
instrument_mcount: bool = (false, parse_bool, [TRACKED],
|
|
|
|
"insert function instrument code for mcount-based tracing (default: no)"),
|
|
|
|
keep_hygiene_data: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"keep hygiene data after analysis (default: no)"),
|
|
|
|
link_native_libraries: bool = (true, parse_bool, [UNTRACKED],
|
|
|
|
"link native libraries in the linker invocation (default: yes)"),
|
|
|
|
link_only: bool = (false, parse_bool, [TRACKED],
|
|
|
|
"link the `.rlink` file generated by `-Z no-link` (default: no)"),
|
|
|
|
llvm_time_trace: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"generate JSON tracing data file from LLVM data (default: no)"),
|
|
|
|
ls: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"list the symbols defined by a library crate (default: no)"),
|
|
|
|
macro_backtrace: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"show macro backtraces (default: no)"),
|
|
|
|
merge_functions: Option<MergeFunctions> = (None, parse_merge_functions, [TRACKED],
|
|
|
|
"control the operation of the MergeFunctions LLVM pass, taking \
|
|
|
|
the same values as the target option of the same name"),
|
|
|
|
meta_stats: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"gather metadata statistics (default: no)"),
|
|
|
|
mir_emit_retag: bool = (false, parse_bool, [TRACKED],
|
|
|
|
"emit Retagging MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 \
|
|
|
|
(default: no)"),
|
|
|
|
mir_opt_level: usize = (1, parse_uint, [TRACKED],
|
|
|
|
"MIR optimization level (0-3; default: 1)"),
|
|
|
|
mutable_noalias: bool = (false, parse_bool, [TRACKED],
|
|
|
|
"emit noalias metadata for mutable references (default: no)"),
|
|
|
|
new_llvm_pass_manager: bool = (false, parse_bool, [TRACKED],
|
|
|
|
"use new LLVM pass manager (default: no)"),
|
|
|
|
nll_facts: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"dump facts from NLL analysis into side files (default: no)"),
|
|
|
|
no_analysis: bool = (false, parse_no_flag, [UNTRACKED],
|
|
|
|
"parse and expand the source, but run no analysis"),
|
|
|
|
no_codegen: bool = (false, parse_no_flag, [TRACKED],
|
|
|
|
"run all passes except codegen; no output"),
|
|
|
|
no_generate_arange_section: bool = (false, parse_no_flag, [TRACKED],
|
|
|
|
"omit DWARF address ranges that give faster lookups"),
|
|
|
|
no_interleave_lints: bool = (false, parse_no_flag, [UNTRACKED],
|
|
|
|
"execute lints separately; allows benchmarking individual lints"),
|
|
|
|
no_leak_check: bool = (false, parse_no_flag, [UNTRACKED],
|
|
|
|
"disable the 'leak check' for subtyping; unsound, but useful for tests"),
|
|
|
|
no_link: bool = (false, parse_no_flag, [TRACKED],
|
|
|
|
"compile without linking"),
|
|
|
|
no_parallel_llvm: bool = (false, parse_no_flag, [UNTRACKED],
|
|
|
|
"run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO)"),
|
|
|
|
no_profiler_runtime: bool = (false, parse_no_flag, [TRACKED],
|
|
|
|
"prevent automatic injection of the profiler_builtins crate"),
|
2019-12-17 23:22:55 +11:00
|
|
|
osx_rpath_install_name: bool = (false, parse_bool, [TRACKED],
|
2020-04-03 10:42:29 +11:00
|
|
|
"pass `-install_name @rpath/...` to the macOS linker (default: no)"),
|
2020-04-21 10:06:13 +10:00
|
|
|
panic_abort_tests: bool = (false, parse_bool, [TRACKED],
|
|
|
|
"support compiling tests with panic=abort (default: no)"),
|
|
|
|
parse_only: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"parse only; do not compile, assemble, or link (default: no)"),
|
|
|
|
perf_stats: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"print some performance-related statistics (default: no)"),
|
|
|
|
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
|
|
|
|
(default: PLT is disabled if full relro is enabled)"),
|
|
|
|
polonius: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"enable polonius-based borrow-checker (default: no)"),
|
2020-07-22 15:03:56 +01:00
|
|
|
polymorphize: bool = (false, parse_bool, [TRACKED],
|
2020-06-22 13:57:03 +01:00
|
|
|
"perform polymorphization analysis"),
|
2020-04-01 19:17:08 +03:00
|
|
|
pre_link_arg: (/* redirected to pre_link_args */) = ((), parse_string_push, [UNTRACKED],
|
2019-12-17 23:22:55 +11:00
|
|
|
"a single extra argument to prepend the linker invocation (can be used several times)"),
|
2020-04-01 19:17:08 +03:00
|
|
|
pre_link_args: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],
|
2019-12-17 23:22:55 +11:00
|
|
|
"extra arguments to prepend to the linker invocation (space separated)"),
|
2020-04-21 10:06:13 +10:00
|
|
|
print_fuel: Option<String> = (None, parse_opt_string, [TRACKED],
|
|
|
|
"make rustc print the total optimization fuel used by a crate"),
|
|
|
|
print_link_args: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"print the arguments passed to the linker (default: no)"),
|
|
|
|
print_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"print the LLVM optimization passes being run (default: no)"),
|
|
|
|
print_mono_items: Option<String> = (None, parse_opt_string, [UNTRACKED],
|
|
|
|
"print the result of the monomorphization collection pass"),
|
|
|
|
print_type_sizes: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"print layout information for each type encountered (default: no)"),
|
2020-08-30 22:17:24 -04:00
|
|
|
proc_macro_backtrace: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"show backtraces for panics during proc-macro execution (default: no)"),
|
2019-12-17 23:22:55 +11:00
|
|
|
profile: bool = (false, parse_bool, [TRACKED],
|
2020-04-03 10:42:29 +11:00
|
|
|
"insert profiling code (default: no)"),
|
2020-05-26 13:41:40 -04:00
|
|
|
profile_emit: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
|
|
|
|
"file path to emit profiling data at runtime when using 'profile' \
|
|
|
|
(default based on relative source path)"),
|
2020-04-21 10:06:13 +10:00
|
|
|
query_dep_graph: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"enable queries of the dependency graph for regression testing (default: no)"),
|
|
|
|
query_stats: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"print some statistics about the query system (default: no)"),
|
2019-12-17 23:22:55 +11:00
|
|
|
relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
|
|
|
|
"choose which RELRO level to use"),
|
2020-04-21 10:06:13 +10:00
|
|
|
report_delayed_bugs: bool = (false, parse_bool, [TRACKED],
|
|
|
|
"immediately print bugs registered with `delay_span_bug` (default: no)"),
|
2020-04-02 16:44:47 +11:00
|
|
|
// The default historical behavior was to always run dsymutil, so we're
|
|
|
|
// preserving that temporarily, but we're likely to switch the default
|
|
|
|
// soon.
|
|
|
|
run_dsymutil: bool = (true, parse_bool, [TRACKED],
|
2020-04-03 10:42:29 +11:00
|
|
|
"if on Mac, run `dsymutil` and delete intermediate object files (default: yes)"),
|
2020-06-14 00:00:00 +00:00
|
|
|
sanitizer: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED],
|
2020-04-21 10:06:13 +10:00
|
|
|
"use a sanitizer"),
|
|
|
|
sanitizer_memory_track_origins: usize = (0, parse_sanitizer_memory_track_origins, [TRACKED],
|
|
|
|
"enable origins tracking in MemorySanitizer"),
|
2020-06-14 00:00:00 +00:00
|
|
|
sanitizer_recover: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED],
|
2020-04-21 10:06:13 +10:00
|
|
|
"enable recovery for selected sanitizers"),
|
2020-04-17 21:42:22 -04:00
|
|
|
saturating_float_casts: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
2020-04-21 10:06:13 +10:00
|
|
|
"make float->int casts UB-free: numbers outside the integer type's range are clipped to \
|
2020-04-17 21:42:22 -04:00
|
|
|
the max/min integer respectively, and NaN is mapped to 0 (default: yes)"),
|
2020-04-21 10:06:13 +10:00
|
|
|
save_analysis: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"write syntax and type analysis (in JSON format) information, in \
|
|
|
|
addition to normal output (default: no)"),
|
2019-12-17 23:22:55 +11:00
|
|
|
self_profile: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
|
|
|
|
parse_switch_with_opt_path, [UNTRACKED],
|
|
|
|
"run the self profiler and output the raw event data"),
|
2020-01-16 08:24:34 -05:00
|
|
|
// keep this in sync with the event filter names in librustc_data_structures/profiling.rs
|
2019-12-17 23:22:55 +11:00
|
|
|
self_profile_events: Option<Vec<String>> = (None, parse_opt_comma_list, [UNTRACKED],
|
2020-04-03 10:42:29 +11:00
|
|
|
"specify the events recorded by the self profiler;
|
2020-01-16 08:24:34 -05:00
|
|
|
for example: `-Z self-profile-events=default,query-keys`
|
|
|
|
all options: none, all, default, generic-activity, query-provider, query-cache-hit
|
2020-02-11 22:37:16 +01:00
|
|
|
query-blocked, incr-cache-load, query-keys, function-args, args, llvm"),
|
2020-04-21 10:06:13 +10:00
|
|
|
share_generics: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
|
|
|
"make the current crate share its generic instantiations"),
|
|
|
|
show_span: Option<String> = (None, parse_opt_string, [TRACKED],
|
|
|
|
"show spans for compiler debugging (expr|pat|ty)"),
|
2020-05-31 16:20:50 -04:00
|
|
|
span_debug: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"forward proc_macro::Span's `Debug` impl to `Span`"),
|
2020-04-21 10:06:13 +10:00
|
|
|
// o/w tests have closure@path
|
|
|
|
span_free_formats: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"exclude spans when debug-printing compiler state (default: no)"),
|
|
|
|
src_hash_algorithm: Option<SourceFileHashAlgorithm> = (None, parse_src_file_hash, [TRACKED],
|
|
|
|
"hash algorithm of source files in debug info (`md5`, or `sha1`)"),
|
2020-05-03 12:36:12 +08:00
|
|
|
strip: Strip = (Strip::None, parse_strip, [UNTRACKED],
|
|
|
|
"tell the linker which information to strip (`none` (default), `debuginfo` or `symbols`)"),
|
2019-12-17 23:22:55 +11:00
|
|
|
symbol_mangling_version: SymbolManglingVersion = (SymbolManglingVersion::Legacy,
|
|
|
|
parse_symbol_mangling_version, [TRACKED],
|
|
|
|
"which mangling version to use for symbol names"),
|
2020-04-21 10:06:13 +10:00
|
|
|
teach: bool = (false, parse_bool, [TRACKED],
|
|
|
|
"show extended diagnostic help (default: no)"),
|
|
|
|
terminal_width: Option<usize> = (None, parse_opt_uint, [UNTRACKED],
|
|
|
|
"set the current terminal width"),
|
|
|
|
thinlto: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
|
|
|
"enable ThinLTO when possible"),
|
|
|
|
// We default to 1 here since we want to behave like
|
|
|
|
// a sequential compiler for now. This'll likely be adjusted
|
|
|
|
// in the future. Note that -Zthreads=0 is the way to get
|
|
|
|
// the num_cpus behavior.
|
|
|
|
threads: usize = (1, parse_threads, [UNTRACKED],
|
|
|
|
"use a thread pool with N threads"),
|
|
|
|
time: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"measure time of rustc processes (default: no)"),
|
|
|
|
time_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"measure time of each LLVM pass (default: no)"),
|
|
|
|
time_passes: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"measure time of each rustc pass (default: no)"),
|
2020-04-25 21:45:21 +03:00
|
|
|
tls_model: Option<TlsModel> = (None, parse_tls_model, [TRACKED],
|
2020-04-21 10:06:13 +10:00
|
|
|
"choose the TLS model to use (`rustc --print tls-models` for details)"),
|
|
|
|
trace_macros: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"for every macro invocation, print its name and arguments (default: no)"),
|
|
|
|
treat_err_as_bug: Option<usize> = (None, parse_treat_err_as_bug, [TRACKED],
|
|
|
|
"treat error number `val` that occurs as bug"),
|
2020-09-02 10:40:56 +03:00
|
|
|
trim_diagnostic_paths: bool = (true, parse_bool, [UNTRACKED],
|
|
|
|
"in diagnostics, use heuristics to shorten paths referring to items"),
|
2020-04-21 10:06:13 +10:00
|
|
|
ui_testing: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"emit compiler diagnostics in a form suitable for UI testing (default: no)"),
|
|
|
|
unleash_the_miri_inside_of_you: bool = (false, parse_bool, [TRACKED],
|
|
|
|
"take the brakes off const evaluation. NOTE: this is unsound (default: no)"),
|
|
|
|
unpretty: Option<String> = (None, parse_unpretty, [UNTRACKED],
|
|
|
|
"present the input source, unstable (and less-pretty) variants;
|
|
|
|
valid types are any of the types for `--pretty`, as well as:
|
|
|
|
`expanded`, `expanded,identified`,
|
|
|
|
`expanded,hygiene` (with internal representations),
|
|
|
|
`everybody_loops` (all function bodies replaced with `loop {}`),
|
|
|
|
`hir` (the HIR), `hir,identified`,
|
|
|
|
`hir,typed` (HIR with types for each node),
|
|
|
|
`hir-tree` (dump the raw HIR),
|
|
|
|
`mir` (the MIR), or `mir-cfg` (graphviz formatted MIR)"),
|
|
|
|
unstable_options: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"adds unstable command line options to rustc interface (default: no)"),
|
2020-04-16 19:40:11 -07:00
|
|
|
use_ctors_section: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
|
|
|
"use legacy .ctors section for initializers rather than .init_array"),
|
2020-05-24 00:55:44 +02:00
|
|
|
validate_mir: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"validate MIR after each transformation"),
|
2020-04-21 10:06:13 +10:00
|
|
|
verbose: bool = (false, parse_bool, [UNTRACKED],
|
|
|
|
"in general, enable more debug printouts (default: no)"),
|
|
|
|
verify_llvm_ir: bool = (false, parse_bool, [TRACKED],
|
|
|
|
"verify LLVM IR (default: no)"),
|
|
|
|
|
|
|
|
// This list is in alphabetical order.
|
|
|
|
//
|
|
|
|
// If you add a new option, please update:
|
|
|
|
// - src/librustc_interface/tests.rs
|
2019-12-17 23:22:55 +11:00
|
|
|
}
|