2019-10-11 16:48:16 -05:00
|
|
|
use crate::interface::parse_cfgspecs;
|
|
|
|
|
2019-12-22 16:42:04 -06:00
|
|
|
use rustc_data_structures::fx::FxHashSet;
|
|
|
|
use rustc_errors::{emitter::HumanReadableErrorType, registry, ColorConfig};
|
coverage bug fixes and optimization support
Adjusted LLVM codegen for code compiled with `-Zinstrument-coverage` to
address multiple, somewhat related issues.
Fixed a significant flaw in prior coverage solution: Every counter
generated a new counter variable, but there should have only been one
counter variable per function. This appears to have bloated .profraw
files significantly. (For a small program, it increased the size by
about 40%. I have not tested large programs, but there is anecdotal
evidence that profraw files were way too large. This is a good fix,
regardless, but hopefully it also addresses related issues.
Fixes: #82144
Invalid LLVM coverage data produced when compiled with -C opt-level=1
Existing tests now work up to at least `opt-level=3`. This required a
detailed analysis of the LLVM IR, comparisons with Clang C++ LLVM IR
when compiled with coverage, and a lot of trial and error with codegen
adjustments.
The biggest hurdle was figuring out how to continue to support coverage
results for unused functions and generics. Rust's coverage results have
three advantages over Clang's coverage results:
1. Rust's coverage map does not include any overlapping code regions,
making coverage counting unambiguous.
2. Rust generates coverage results (showing zero counts) for all unused
functions, including generics. (Clang does not generate coverage for
uninstantiated template functions.)
3. Rust's unused functions produce minimal stubbed functions in LLVM IR,
sufficient for including in the coverage results; while Clang must
generate the complete LLVM IR for each unused function, even though
it will never be called.
This PR removes the previous hack of attempting to inject coverage into
some other existing function instance, and generates dedicated instances
for each unused function. This change, and a few other adjustments
(similar to what is required for `-C link-dead-code`, but with lower
impact), makes it possible to support LLVM optimizations.
Fixes: #79651
Coverage report: "Unexecuted instantiation:..." for a generic function
from multiple crates
Fixed by removing the aforementioned hack. Some "Unexecuted
instantiation" notices are unavoidable, as explained in the
`used_crate.rs` test, but `-Zinstrument-coverage` has new options to
back off support for either unused generics, or all unused functions,
which avoids the notice, at the cost of less coverage of unused
functions.
Fixes: #82875
Invalid LLVM coverage data produced with crate brotli_decompressor
Fixed by disabling the LLVM function attribute that forces inlining, if
`-Z instrument-coverage` is enabled. This attribute is applied to
Rust functions with `#[inline(always)], and in some cases, the forced
inlining breaks coverage instrumentation and reports.
2021-03-15 18:32:45 -05:00
|
|
|
use rustc_session::config::InstrumentCoverage;
|
2020-05-02 23:36:12 -05:00
|
|
|
use rustc_session::config::Strip;
|
2020-03-11 06:49:08 -05:00
|
|
|
use rustc_session::config::{build_configuration, build_session_options, to_crate_config};
|
|
|
|
use rustc_session::config::{rustc_optgroups, ErrorOutputType, ExternLocation, Options, Passes};
|
2020-04-20 22:25:07 -05:00
|
|
|
use rustc_session::config::{CFGuard, ExternEntry, LinkerPluginLto, LtoCli, SwitchWithOptPath};
|
2020-06-13 19:00:00 -05:00
|
|
|
use rustc_session::config::{
|
2021-02-07 15:47:03 -06:00
|
|
|
Externs, OutputType, OutputTypes, SymbolManglingVersion, WasiExecModel,
|
2020-06-13 19:00:00 -05:00
|
|
|
};
|
2020-03-11 06:49:08 -05:00
|
|
|
use rustc_session::lint::Level;
|
|
|
|
use rustc_session::search_paths::SearchPath;
|
2021-01-26 15:27:42 -06:00
|
|
|
use rustc_session::utils::{CanonicalizedPath, NativeLibKind};
|
2020-05-27 13:34:17 -05:00
|
|
|
use rustc_session::{build_session, getopts, DiagnosticOutput, Session};
|
2020-01-01 12:40:49 -06:00
|
|
|
use rustc_span::edition::{Edition, DEFAULT_EDITION};
|
2020-01-01 12:30:57 -06:00
|
|
|
use rustc_span::symbol::sym;
|
2020-04-20 22:25:07 -05:00
|
|
|
use rustc_span::SourceFileHashAlgorithm;
|
2020-05-06 19:34:27 -05:00
|
|
|
use rustc_target::spec::{CodeModel, LinkerFlavor, MergeFunctions, PanicStrategy};
|
2021-02-07 15:47:03 -06:00
|
|
|
use rustc_target::spec::{RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, TlsModel};
|
2021-04-15 18:25:01 -05:00
|
|
|
|
2019-06-05 13:16:41 -05:00
|
|
|
use std::collections::{BTreeMap, BTreeSet};
|
|
|
|
use std::iter::FromIterator;
|
2021-02-18 05:25:45 -06:00
|
|
|
use std::num::NonZeroUsize;
|
2021-01-26 15:27:42 -06:00
|
|
|
use std::path::{Path, PathBuf};
|
2019-10-11 16:30:58 -05:00
|
|
|
|
2019-10-10 03:26:10 -05:00
|
|
|
type CfgSpecs = FxHashSet<(String, Option<String>)>;
|
|
|
|
|
|
|
|
fn build_session_options_and_crate_config(matches: getopts::Matches) -> (Options, CfgSpecs) {
|
|
|
|
let sessopts = build_session_options(&matches);
|
|
|
|
let cfg = parse_cfgspecs(matches.opt_strs("cfg"));
|
|
|
|
(sessopts, cfg)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn mk_session(matches: getopts::Matches) -> (Session, CfgSpecs) {
|
|
|
|
let registry = registry::Registry::new(&[]);
|
|
|
|
let (sessopts, cfg) = build_session_options_and_crate_config(matches);
|
2020-05-27 13:34:17 -05:00
|
|
|
let sess = build_session(
|
|
|
|
sessopts,
|
|
|
|
None,
|
|
|
|
registry,
|
|
|
|
DiagnosticOutput::Default,
|
|
|
|
Default::default(),
|
|
|
|
None,
|
2020-09-17 05:01:12 -05:00
|
|
|
None,
|
2020-05-27 13:34:17 -05:00
|
|
|
);
|
2019-10-10 03:26:10 -05:00
|
|
|
(sess, cfg)
|
2019-10-11 16:30:58 -05:00
|
|
|
}
|
2019-06-05 13:16:41 -05:00
|
|
|
|
2019-10-11 16:48:16 -05:00
|
|
|
fn new_public_extern_entry<S, I>(locations: I) -> ExternEntry
|
|
|
|
where
|
|
|
|
S: Into<String>,
|
2019-12-05 16:43:53 -06:00
|
|
|
I: IntoIterator<Item = S>,
|
2019-10-11 16:48:16 -05:00
|
|
|
{
|
2021-01-26 15:27:42 -06:00
|
|
|
let locations: BTreeSet<CanonicalizedPath> =
|
|
|
|
locations.into_iter().map(|s| CanonicalizedPath::new(Path::new(&s.into()))).collect();
|
2019-10-11 16:48:16 -05:00
|
|
|
|
|
|
|
ExternEntry {
|
2019-12-05 16:43:53 -06:00
|
|
|
location: ExternLocation::ExactPaths(locations),
|
|
|
|
is_private_dep: false,
|
|
|
|
add_prelude: true,
|
2019-06-05 13:16:41 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn optgroups() -> getopts::Options {
|
|
|
|
let mut opts = getopts::Options::new();
|
2019-10-11 16:48:16 -05:00
|
|
|
for group in rustc_optgroups() {
|
2019-06-05 13:16:41 -05:00
|
|
|
(group.apply)(&mut opts);
|
|
|
|
}
|
|
|
|
return opts;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn mk_map<K: Ord, V>(entries: Vec<(K, V)>) -> BTreeMap<K, V> {
|
|
|
|
BTreeMap::from_iter(entries.into_iter())
|
|
|
|
}
|
|
|
|
|
2021-04-15 18:25:01 -05:00
|
|
|
fn assert_same_clone(x: &Options) {
|
|
|
|
assert_eq!(x.dep_tracking_hash(true), x.clone().dep_tracking_hash(true));
|
|
|
|
assert_eq!(x.dep_tracking_hash(false), x.clone().dep_tracking_hash(false));
|
|
|
|
}
|
|
|
|
|
|
|
|
fn assert_same_hash(x: &Options, y: &Options) {
|
|
|
|
assert_eq!(x.dep_tracking_hash(true), y.dep_tracking_hash(true));
|
|
|
|
assert_eq!(x.dep_tracking_hash(false), y.dep_tracking_hash(false));
|
|
|
|
// Check clone
|
|
|
|
assert_same_clone(x);
|
|
|
|
assert_same_clone(y);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn assert_different_hash(x: &Options, y: &Options) {
|
|
|
|
assert_ne!(x.dep_tracking_hash(true), y.dep_tracking_hash(true));
|
|
|
|
assert_ne!(x.dep_tracking_hash(false), y.dep_tracking_hash(false));
|
|
|
|
// Check clone
|
|
|
|
assert_same_clone(x);
|
|
|
|
assert_same_clone(y);
|
|
|
|
}
|
|
|
|
|
2019-06-05 13:16:41 -05:00
|
|
|
// When the user supplies --test we should implicitly supply --cfg test
|
|
|
|
#[test]
|
|
|
|
fn test_switch_implies_cfg_test() {
|
2020-07-29 20:27:50 -05:00
|
|
|
rustc_span::with_default_session_globals(|| {
|
2019-10-10 03:26:10 -05:00
|
|
|
let matches = optgroups().parse(&["--test".to_string()]).unwrap();
|
|
|
|
let (sess, cfg) = mk_session(matches);
|
2019-06-05 13:16:41 -05:00
|
|
|
let cfg = build_configuration(&sess, to_crate_config(cfg));
|
|
|
|
assert!(cfg.contains(&(sym::test, None)));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-10-10 03:26:10 -05:00
|
|
|
// When the user supplies --test and --cfg test, don't implicitly add another --cfg test
|
2019-06-05 13:16:41 -05:00
|
|
|
#[test]
|
|
|
|
fn test_switch_implies_cfg_test_unless_cfg_test() {
|
2020-07-29 20:27:50 -05:00
|
|
|
rustc_span::with_default_session_globals(|| {
|
2019-10-10 03:26:10 -05:00
|
|
|
let matches = optgroups().parse(&["--test".to_string(), "--cfg=test".to_string()]).unwrap();
|
|
|
|
let (sess, cfg) = mk_session(matches);
|
2019-06-05 13:16:41 -05:00
|
|
|
let cfg = build_configuration(&sess, to_crate_config(cfg));
|
|
|
|
let mut test_items = cfg.iter().filter(|&&(name, _)| name == sym::test);
|
|
|
|
assert!(test_items.next().is_some());
|
|
|
|
assert!(test_items.next().is_none());
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_can_print_warnings() {
|
2020-07-29 20:27:50 -05:00
|
|
|
rustc_span::with_default_session_globals(|| {
|
2019-06-05 13:16:41 -05:00
|
|
|
let matches = optgroups().parse(&["-Awarnings".to_string()]).unwrap();
|
2019-10-10 03:26:10 -05:00
|
|
|
let (sess, _) = mk_session(matches);
|
2019-09-07 11:09:52 -05:00
|
|
|
assert!(!sess.diagnostic().can_emit_warnings());
|
2019-06-05 13:16:41 -05:00
|
|
|
});
|
|
|
|
|
2020-07-29 20:27:50 -05:00
|
|
|
rustc_span::with_default_session_globals(|| {
|
2019-12-22 16:42:04 -06:00
|
|
|
let matches =
|
|
|
|
optgroups().parse(&["-Awarnings".to_string(), "-Dwarnings".to_string()]).unwrap();
|
2019-10-10 03:26:10 -05:00
|
|
|
let (sess, _) = mk_session(matches);
|
2019-09-07 11:09:52 -05:00
|
|
|
assert!(sess.diagnostic().can_emit_warnings());
|
2019-06-05 13:16:41 -05:00
|
|
|
});
|
|
|
|
|
2020-07-29 20:27:50 -05:00
|
|
|
rustc_span::with_default_session_globals(|| {
|
2019-06-05 13:16:41 -05:00
|
|
|
let matches = optgroups().parse(&["-Adead_code".to_string()]).unwrap();
|
2019-10-10 03:26:10 -05:00
|
|
|
let (sess, _) = mk_session(matches);
|
2019-09-07 11:09:52 -05:00
|
|
|
assert!(sess.diagnostic().can_emit_warnings());
|
2019-06-05 13:16:41 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_output_types_tracking_hash_different_paths() {
|
|
|
|
let mut v1 = Options::default();
|
|
|
|
let mut v2 = Options::default();
|
|
|
|
let mut v3 = Options::default();
|
|
|
|
|
2019-12-22 16:42:04 -06:00
|
|
|
v1.output_types = OutputTypes::new(&[(OutputType::Exe, Some(PathBuf::from("./some/thing")))]);
|
|
|
|
v2.output_types = OutputTypes::new(&[(OutputType::Exe, Some(PathBuf::from("/some/thing")))]);
|
2019-06-05 13:16:41 -05:00
|
|
|
v3.output_types = OutputTypes::new(&[(OutputType::Exe, None)]);
|
|
|
|
|
2021-04-15 18:25:01 -05:00
|
|
|
assert_different_hash(&v1, &v2);
|
|
|
|
assert_different_hash(&v1, &v3);
|
|
|
|
assert_different_hash(&v2, &v3);
|
2019-06-05 13:16:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_output_types_tracking_hash_different_construction_order() {
|
|
|
|
let mut v1 = Options::default();
|
|
|
|
let mut v2 = Options::default();
|
|
|
|
|
|
|
|
v1.output_types = OutputTypes::new(&[
|
|
|
|
(OutputType::Exe, Some(PathBuf::from("./some/thing"))),
|
|
|
|
(OutputType::Bitcode, Some(PathBuf::from("./some/thing.bc"))),
|
|
|
|
]);
|
|
|
|
|
|
|
|
v2.output_types = OutputTypes::new(&[
|
|
|
|
(OutputType::Bitcode, Some(PathBuf::from("./some/thing.bc"))),
|
|
|
|
(OutputType::Exe, Some(PathBuf::from("./some/thing"))),
|
|
|
|
]);
|
|
|
|
|
2021-04-15 18:25:01 -05:00
|
|
|
assert_same_hash(&v1, &v2);
|
2019-06-05 13:16:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_externs_tracking_hash_different_construction_order() {
|
|
|
|
let mut v1 = Options::default();
|
|
|
|
let mut v2 = Options::default();
|
|
|
|
let mut v3 = Options::default();
|
|
|
|
|
|
|
|
v1.externs = Externs::new(mk_map(vec![
|
2019-12-22 16:42:04 -06:00
|
|
|
(String::from("a"), new_public_extern_entry(vec!["b", "c"])),
|
|
|
|
(String::from("d"), new_public_extern_entry(vec!["e", "f"])),
|
2019-06-05 13:16:41 -05:00
|
|
|
]));
|
|
|
|
|
|
|
|
v2.externs = Externs::new(mk_map(vec![
|
2019-12-22 16:42:04 -06:00
|
|
|
(String::from("d"), new_public_extern_entry(vec!["e", "f"])),
|
|
|
|
(String::from("a"), new_public_extern_entry(vec!["b", "c"])),
|
2019-06-05 13:16:41 -05:00
|
|
|
]));
|
|
|
|
|
|
|
|
v3.externs = Externs::new(mk_map(vec![
|
2019-12-22 16:42:04 -06:00
|
|
|
(String::from("a"), new_public_extern_entry(vec!["b", "c"])),
|
|
|
|
(String::from("d"), new_public_extern_entry(vec!["f", "e"])),
|
2019-06-05 13:16:41 -05:00
|
|
|
]));
|
|
|
|
|
2021-04-15 18:25:01 -05:00
|
|
|
assert_same_hash(&v1, &v2);
|
|
|
|
assert_same_hash(&v1, &v3);
|
|
|
|
assert_same_hash(&v2, &v3);
|
2019-06-05 13:16:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_lints_tracking_hash_different_values() {
|
|
|
|
let mut v1 = Options::default();
|
|
|
|
let mut v2 = Options::default();
|
|
|
|
let mut v3 = Options::default();
|
|
|
|
|
|
|
|
v1.lint_opts = vec![
|
2020-01-09 23:53:07 -06:00
|
|
|
(String::from("a"), Level::Allow),
|
|
|
|
(String::from("b"), Level::Warn),
|
|
|
|
(String::from("c"), Level::Deny),
|
|
|
|
(String::from("d"), Level::Forbid),
|
2019-06-05 13:16:41 -05:00
|
|
|
];
|
|
|
|
|
|
|
|
v2.lint_opts = vec![
|
2020-01-09 23:53:07 -06:00
|
|
|
(String::from("a"), Level::Allow),
|
|
|
|
(String::from("b"), Level::Warn),
|
|
|
|
(String::from("X"), Level::Deny),
|
|
|
|
(String::from("d"), Level::Forbid),
|
2019-06-05 13:16:41 -05:00
|
|
|
];
|
|
|
|
|
|
|
|
v3.lint_opts = vec![
|
2020-01-09 23:53:07 -06:00
|
|
|
(String::from("a"), Level::Allow),
|
|
|
|
(String::from("b"), Level::Warn),
|
|
|
|
(String::from("c"), Level::Forbid),
|
|
|
|
(String::from("d"), Level::Deny),
|
2019-06-05 13:16:41 -05:00
|
|
|
];
|
|
|
|
|
2021-04-15 18:25:01 -05:00
|
|
|
assert_different_hash(&v1, &v2);
|
|
|
|
assert_different_hash(&v1, &v3);
|
|
|
|
assert_different_hash(&v2, &v3);
|
2019-06-05 13:16:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_lints_tracking_hash_different_construction_order() {
|
|
|
|
let mut v1 = Options::default();
|
|
|
|
let mut v2 = Options::default();
|
|
|
|
|
|
|
|
v1.lint_opts = vec![
|
2020-01-09 23:53:07 -06:00
|
|
|
(String::from("a"), Level::Allow),
|
|
|
|
(String::from("b"), Level::Warn),
|
|
|
|
(String::from("c"), Level::Deny),
|
|
|
|
(String::from("d"), Level::Forbid),
|
2019-06-05 13:16:41 -05:00
|
|
|
];
|
|
|
|
|
|
|
|
v2.lint_opts = vec![
|
2020-01-09 23:53:07 -06:00
|
|
|
(String::from("a"), Level::Allow),
|
|
|
|
(String::from("c"), Level::Deny),
|
|
|
|
(String::from("b"), Level::Warn),
|
|
|
|
(String::from("d"), Level::Forbid),
|
2019-06-05 13:16:41 -05:00
|
|
|
];
|
|
|
|
|
2021-04-15 18:25:01 -05:00
|
|
|
assert_same_hash(&v1, &v2);
|
2019-06-05 13:16:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_search_paths_tracking_hash_different_order() {
|
|
|
|
let mut v1 = Options::default();
|
|
|
|
let mut v2 = Options::default();
|
|
|
|
let mut v3 = Options::default();
|
|
|
|
let mut v4 = Options::default();
|
|
|
|
|
2019-10-11 16:48:16 -05:00
|
|
|
const JSON: ErrorOutputType = ErrorOutputType::Json {
|
2019-06-05 13:16:41 -05:00
|
|
|
pretty: false,
|
2019-10-11 16:48:16 -05:00
|
|
|
json_rendered: HumanReadableErrorType::Default(ColorConfig::Never),
|
2019-06-05 13:16:41 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// Reference
|
2019-12-22 16:42:04 -06:00
|
|
|
v1.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
|
|
|
|
v1.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
|
|
|
|
v1.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
|
|
|
|
v1.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
|
|
|
|
v1.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
|
|
|
|
|
|
|
|
v2.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
|
|
|
|
v2.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
|
|
|
|
v2.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
|
|
|
|
v2.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
|
|
|
|
v2.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
|
|
|
|
|
|
|
|
v3.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
|
|
|
|
v3.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
|
|
|
|
v3.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
|
|
|
|
v3.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
|
|
|
|
v3.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
|
|
|
|
|
|
|
|
v4.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
|
|
|
|
v4.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
|
|
|
|
v4.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
|
|
|
|
v4.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
|
|
|
|
v4.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
|
2019-06-05 13:16:41 -05:00
|
|
|
|
2021-04-15 18:25:01 -05:00
|
|
|
assert_same_hash(&v1, &v2);
|
|
|
|
assert_same_hash(&v1, &v3);
|
|
|
|
assert_same_hash(&v1, &v4);
|
2019-06-05 13:16:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_native_libs_tracking_hash_different_values() {
|
|
|
|
let mut v1 = Options::default();
|
|
|
|
let mut v2 = Options::default();
|
|
|
|
let mut v3 = Options::default();
|
|
|
|
let mut v4 = Options::default();
|
|
|
|
|
|
|
|
// Reference
|
|
|
|
v1.libs = vec![
|
2020-05-17 17:52:34 -05:00
|
|
|
(String::from("a"), None, NativeLibKind::StaticBundle),
|
|
|
|
(String::from("b"), None, NativeLibKind::Framework),
|
|
|
|
(String::from("c"), None, NativeLibKind::Unspecified),
|
2019-06-05 13:16:41 -05:00
|
|
|
];
|
|
|
|
|
|
|
|
// Change label
|
|
|
|
v2.libs = vec![
|
2020-05-17 17:52:34 -05:00
|
|
|
(String::from("a"), None, NativeLibKind::StaticBundle),
|
|
|
|
(String::from("X"), None, NativeLibKind::Framework),
|
|
|
|
(String::from("c"), None, NativeLibKind::Unspecified),
|
2019-06-05 13:16:41 -05:00
|
|
|
];
|
|
|
|
|
|
|
|
// Change kind
|
|
|
|
v3.libs = vec![
|
2020-05-17 17:52:34 -05:00
|
|
|
(String::from("a"), None, NativeLibKind::StaticBundle),
|
|
|
|
(String::from("b"), None, NativeLibKind::StaticBundle),
|
|
|
|
(String::from("c"), None, NativeLibKind::Unspecified),
|
2019-06-05 13:16:41 -05:00
|
|
|
];
|
|
|
|
|
|
|
|
// Change new-name
|
|
|
|
v4.libs = vec![
|
2020-05-17 17:52:34 -05:00
|
|
|
(String::from("a"), None, NativeLibKind::StaticBundle),
|
|
|
|
(String::from("b"), Some(String::from("X")), NativeLibKind::Framework),
|
|
|
|
(String::from("c"), None, NativeLibKind::Unspecified),
|
2019-06-05 13:16:41 -05:00
|
|
|
];
|
|
|
|
|
2021-04-15 18:25:01 -05:00
|
|
|
assert_different_hash(&v1, &v2);
|
|
|
|
assert_different_hash(&v1, &v3);
|
|
|
|
assert_different_hash(&v1, &v4);
|
2019-06-05 13:16:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_native_libs_tracking_hash_different_order() {
|
|
|
|
let mut v1 = Options::default();
|
|
|
|
let mut v2 = Options::default();
|
|
|
|
let mut v3 = Options::default();
|
|
|
|
|
|
|
|
// Reference
|
|
|
|
v1.libs = vec![
|
2020-05-17 17:52:34 -05:00
|
|
|
(String::from("a"), None, NativeLibKind::StaticBundle),
|
|
|
|
(String::from("b"), None, NativeLibKind::Framework),
|
|
|
|
(String::from("c"), None, NativeLibKind::Unspecified),
|
2019-06-05 13:16:41 -05:00
|
|
|
];
|
|
|
|
|
|
|
|
v2.libs = vec![
|
2020-05-17 17:52:34 -05:00
|
|
|
(String::from("b"), None, NativeLibKind::Framework),
|
|
|
|
(String::from("a"), None, NativeLibKind::StaticBundle),
|
|
|
|
(String::from("c"), None, NativeLibKind::Unspecified),
|
2019-06-05 13:16:41 -05:00
|
|
|
];
|
|
|
|
|
|
|
|
v3.libs = vec![
|
2020-05-17 17:52:34 -05:00
|
|
|
(String::from("c"), None, NativeLibKind::Unspecified),
|
|
|
|
(String::from("a"), None, NativeLibKind::StaticBundle),
|
|
|
|
(String::from("b"), None, NativeLibKind::Framework),
|
2019-06-05 13:16:41 -05:00
|
|
|
];
|
|
|
|
|
2021-04-15 18:25:01 -05:00
|
|
|
assert_same_hash(&v1, &v2);
|
|
|
|
assert_same_hash(&v1, &v3);
|
|
|
|
assert_same_hash(&v2, &v3);
|
2019-06-05 13:16:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_codegen_options_tracking_hash() {
|
|
|
|
let reference = Options::default();
|
|
|
|
let mut opts = Options::default();
|
|
|
|
|
2020-04-21 00:55:02 -05:00
|
|
|
macro_rules! untracked {
|
|
|
|
($name: ident, $non_default_value: expr) => {
|
2021-04-15 22:06:32 -05:00
|
|
|
assert_ne!(opts.cg.$name, $non_default_value);
|
2020-04-21 00:55:02 -05:00
|
|
|
opts.cg.$name = $non_default_value;
|
2021-04-15 18:25:01 -05:00
|
|
|
assert_same_hash(&reference, &opts);
|
2020-04-21 00:55:02 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-04-20 19:06:13 -05:00
|
|
|
// Make sure that changing an [UNTRACKED] option leaves the hash unchanged.
|
|
|
|
// This list is in alphabetical order.
|
2020-04-21 00:55:02 -05:00
|
|
|
untracked!(ar, String::from("abc"));
|
|
|
|
untracked!(codegen_units, Some(42));
|
|
|
|
untracked!(default_linker_libraries, true);
|
|
|
|
untracked!(extra_filename, String::from("extra-filename"));
|
|
|
|
untracked!(incremental, Some(String::from("abc")));
|
2020-04-20 22:25:07 -05:00
|
|
|
// `link_arg` is omitted because it just forwards to `link_args`.
|
2020-04-21 00:55:02 -05:00
|
|
|
untracked!(link_args, vec![String::from("abc"), String::from("def")]);
|
2020-07-30 15:10:48 -05:00
|
|
|
untracked!(link_self_contained, Some(true));
|
2020-04-21 00:55:02 -05:00
|
|
|
untracked!(linker, Some(PathBuf::from("linker")));
|
|
|
|
untracked!(linker_flavor, Some(LinkerFlavor::Gcc));
|
|
|
|
untracked!(no_stack_check, true);
|
|
|
|
untracked!(remark, Passes::Some(vec![String::from("pass1"), String::from("pass2")]));
|
|
|
|
untracked!(rpath, true);
|
|
|
|
untracked!(save_temps, true);
|
|
|
|
|
|
|
|
macro_rules! tracked {
|
|
|
|
($name: ident, $non_default_value: expr) => {
|
|
|
|
opts = reference.clone();
|
2021-04-15 22:06:32 -05:00
|
|
|
assert_ne!(opts.cg.$name, $non_default_value);
|
2020-04-21 00:55:02 -05:00
|
|
|
opts.cg.$name = $non_default_value;
|
2021-04-15 18:25:01 -05:00
|
|
|
assert_different_hash(&reference, &opts);
|
2020-04-21 00:55:02 -05:00
|
|
|
};
|
|
|
|
}
|
2019-06-05 13:16:41 -05:00
|
|
|
|
2020-04-20 19:06:13 -05:00
|
|
|
// Make sure that changing a [TRACKED] option changes the hash.
|
|
|
|
// This list is in alphabetical order.
|
2020-05-06 19:34:27 -05:00
|
|
|
tracked!(code_model, Some(CodeModel::Large));
|
2020-07-14 09:27:42 -05:00
|
|
|
tracked!(control_flow_guard, CFGuard::Checks);
|
2020-04-21 00:55:02 -05:00
|
|
|
tracked!(debug_assertions, Some(true));
|
|
|
|
tracked!(debuginfo, 0xdeadbeef);
|
2020-04-30 12:53:16 -05:00
|
|
|
tracked!(embed_bitcode, false);
|
2020-04-21 00:55:02 -05:00
|
|
|
tracked!(force_frame_pointers, Some(false));
|
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 06:08:35 -05:00
|
|
|
tracked!(force_unwind_tables, Some(true));
|
2020-04-21 00:55:02 -05:00
|
|
|
tracked!(inline_threshold, Some(0xf007ba11));
|
|
|
|
tracked!(linker_plugin_lto, LinkerPluginLto::LinkerPluginAuto);
|
2021-04-15 14:05:26 -05:00
|
|
|
tracked!(link_dead_code, Some(true));
|
2020-04-21 00:55:02 -05:00
|
|
|
tracked!(llvm_args, vec![String::from("1"), String::from("2")]);
|
|
|
|
tracked!(lto, LtoCli::Fat);
|
|
|
|
tracked!(metadata, vec![String::from("A"), String::from("B")]);
|
|
|
|
tracked!(no_prepopulate_passes, true);
|
|
|
|
tracked!(no_redzone, Some(true));
|
|
|
|
tracked!(no_vectorize_loops, true);
|
|
|
|
tracked!(no_vectorize_slp, true);
|
|
|
|
tracked!(opt_level, "3".to_string());
|
|
|
|
tracked!(overflow_checks, Some(true));
|
|
|
|
tracked!(panic, Some(PanicStrategy::Abort));
|
|
|
|
tracked!(passes, vec![String::from("1"), String::from("2")]);
|
|
|
|
tracked!(prefer_dynamic, true);
|
|
|
|
tracked!(profile_generate, SwitchWithOptPath::Enabled(None));
|
|
|
|
tracked!(profile_use, Some(PathBuf::from("abc")));
|
2020-04-22 16:46:45 -05:00
|
|
|
tracked!(relocation_model, Some(RelocModel::Pic));
|
2020-04-21 00:55:02 -05:00
|
|
|
tracked!(soft_float, true);
|
2020-11-30 10:39:08 -06:00
|
|
|
tracked!(split_debuginfo, Some(SplitDebuginfo::Packed));
|
2020-04-21 00:55:02 -05:00
|
|
|
tracked!(target_cpu, Some(String::from("abc")));
|
|
|
|
tracked!(target_feature, String::from("all the features, all of them"));
|
2019-06-05 13:16:41 -05:00
|
|
|
}
|
|
|
|
|
2021-04-15 18:25:01 -05:00
|
|
|
#[test]
|
|
|
|
fn test_top_level_options_tracked_no_crate() {
|
|
|
|
let reference = Options::default();
|
|
|
|
let mut opts;
|
|
|
|
|
|
|
|
macro_rules! tracked {
|
|
|
|
($name: ident, $non_default_value: expr) => {
|
|
|
|
opts = reference.clone();
|
|
|
|
assert_ne!(opts.$name, $non_default_value);
|
|
|
|
opts.$name = $non_default_value;
|
|
|
|
// The crate hash should be the same
|
|
|
|
assert_eq!(reference.dep_tracking_hash(true), opts.dep_tracking_hash(true));
|
|
|
|
// The incremental hash should be different
|
|
|
|
assert_ne!(reference.dep_tracking_hash(false), opts.dep_tracking_hash(false));
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure that changing a [TRACKED_NO_CRATE_HASH] option leaves the crate hash unchanged but changes the incremental hash.
|
|
|
|
// This list is in alphabetical order.
|
|
|
|
tracked!(remap_path_prefix, vec![("/home/bors/rust".into(), "src".into())]);
|
2021-04-27 11:25:12 -05:00
|
|
|
tracked!(
|
|
|
|
real_rust_source_base_dir,
|
|
|
|
Some("/home/bors/rust/.rustup/toolchains/nightly/lib/rustlib/src/rust".into())
|
|
|
|
);
|
2021-04-15 18:25:01 -05:00
|
|
|
}
|
|
|
|
|
2019-06-05 13:16:41 -05:00
|
|
|
#[test]
|
|
|
|
fn test_debugging_options_tracking_hash() {
|
|
|
|
let reference = Options::default();
|
|
|
|
let mut opts = Options::default();
|
|
|
|
|
2020-04-21 00:55:02 -05:00
|
|
|
macro_rules! untracked {
|
|
|
|
($name: ident, $non_default_value: expr) => {
|
2021-04-15 22:06:32 -05:00
|
|
|
assert_ne!(opts.debugging_opts.$name, $non_default_value);
|
2020-04-21 00:55:02 -05:00
|
|
|
opts.debugging_opts.$name = $non_default_value;
|
2021-04-15 18:25:01 -05:00
|
|
|
assert_same_hash(&reference, &opts);
|
2020-04-21 00:55:02 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-04-20 19:06:13 -05:00
|
|
|
// Make sure that changing an [UNTRACKED] option leaves the hash unchanged.
|
|
|
|
// This list is in alphabetical order.
|
2020-04-21 00:55:02 -05:00
|
|
|
untracked!(ast_json, true);
|
|
|
|
untracked!(ast_json_noexpand, true);
|
|
|
|
untracked!(borrowck, String::from("other"));
|
2021-04-15 22:06:32 -05:00
|
|
|
untracked!(deduplicate_diagnostics, false);
|
2020-04-21 00:55:02 -05:00
|
|
|
untracked!(dep_tasks, true);
|
|
|
|
untracked!(dont_buffer_diagnostics, true);
|
|
|
|
untracked!(dump_dep_graph, true);
|
|
|
|
untracked!(dump_mir, Some(String::from("abc")));
|
|
|
|
untracked!(dump_mir_dataflow, true);
|
|
|
|
untracked!(dump_mir_dir, String::from("abc"));
|
|
|
|
untracked!(dump_mir_exclude_pass_number, true);
|
|
|
|
untracked!(dump_mir_graphviz, true);
|
2020-10-20 06:57:24 -05:00
|
|
|
untracked!(emit_future_incompat_report, true);
|
2020-04-21 00:55:02 -05:00
|
|
|
untracked!(emit_stack_sizes, true);
|
|
|
|
untracked!(hir_stats, true);
|
|
|
|
untracked!(identify_regions, true);
|
|
|
|
untracked!(incremental_ignore_spans, true);
|
|
|
|
untracked!(incremental_info, true);
|
|
|
|
untracked!(incremental_verify_ich, true);
|
|
|
|
untracked!(input_stats, true);
|
|
|
|
untracked!(keep_hygiene_data, true);
|
|
|
|
untracked!(link_native_libraries, false);
|
|
|
|
untracked!(llvm_time_trace, true);
|
|
|
|
untracked!(ls, true);
|
|
|
|
untracked!(macro_backtrace, true);
|
|
|
|
untracked!(meta_stats, true);
|
|
|
|
untracked!(nll_facts, true);
|
|
|
|
untracked!(no_analysis, true);
|
|
|
|
untracked!(no_interleave_lints, true);
|
|
|
|
untracked!(no_leak_check, true);
|
|
|
|
untracked!(no_parallel_llvm, true);
|
|
|
|
untracked!(parse_only, true);
|
|
|
|
untracked!(perf_stats, true);
|
2020-04-20 22:25:07 -05:00
|
|
|
// `pre_link_arg` is omitted because it just forwards to `pre_link_args`.
|
2020-04-21 00:55:02 -05:00
|
|
|
untracked!(pre_link_args, vec![String::from("abc"), String::from("def")]);
|
|
|
|
untracked!(print_link_args, true);
|
|
|
|
untracked!(print_llvm_passes, true);
|
|
|
|
untracked!(print_mono_items, Some(String::from("abc")));
|
|
|
|
untracked!(print_type_sizes, true);
|
2020-08-30 21:17:24 -05:00
|
|
|
untracked!(proc_macro_backtrace, true);
|
2020-04-21 00:55:02 -05:00
|
|
|
untracked!(query_dep_graph, true);
|
|
|
|
untracked!(query_stats, true);
|
|
|
|
untracked!(save_analysis, true);
|
|
|
|
untracked!(self_profile, SwitchWithOptPath::Enabled(None));
|
|
|
|
untracked!(self_profile_events, Some(vec![String::new()]));
|
2020-05-31 15:20:50 -05:00
|
|
|
untracked!(span_debug, true);
|
2020-04-21 00:55:02 -05:00
|
|
|
untracked!(span_free_formats, true);
|
2021-04-15 22:06:32 -05:00
|
|
|
untracked!(strip, Strip::Debuginfo);
|
2020-04-21 00:55:02 -05:00
|
|
|
untracked!(terminal_width, Some(80));
|
|
|
|
untracked!(threads, 99);
|
|
|
|
untracked!(time, true);
|
|
|
|
untracked!(time_llvm_passes, true);
|
|
|
|
untracked!(time_passes, true);
|
|
|
|
untracked!(trace_macros, true);
|
2020-09-02 02:40:56 -05:00
|
|
|
untracked!(trim_diagnostic_paths, false);
|
2020-04-21 00:55:02 -05:00
|
|
|
untracked!(ui_testing, true);
|
|
|
|
untracked!(unpretty, Some("expanded".to_string()));
|
|
|
|
untracked!(unstable_options, true);
|
2020-05-23 17:55:44 -05:00
|
|
|
untracked!(validate_mir, true);
|
2020-04-21 00:55:02 -05:00
|
|
|
untracked!(verbose, true);
|
|
|
|
|
|
|
|
macro_rules! tracked {
|
|
|
|
($name: ident, $non_default_value: expr) => {
|
|
|
|
opts = reference.clone();
|
2021-04-15 22:06:32 -05:00
|
|
|
assert_ne!(opts.debugging_opts.$name, $non_default_value);
|
2020-04-21 00:55:02 -05:00
|
|
|
opts.debugging_opts.$name = $non_default_value;
|
2021-04-15 18:25:01 -05:00
|
|
|
assert_different_hash(&reference, &opts);
|
2020-04-21 00:55:02 -05:00
|
|
|
};
|
|
|
|
}
|
2019-06-05 13:16:41 -05:00
|
|
|
|
2020-04-20 19:06:13 -05:00
|
|
|
// Make sure that changing a [TRACKED] option changes the hash.
|
|
|
|
// This list is in alphabetical order.
|
2020-04-21 00:55:02 -05:00
|
|
|
tracked!(allow_features, Some(vec![String::from("lang_items")]));
|
|
|
|
tracked!(always_encode_mir, true);
|
2021-01-28 02:24:55 -06:00
|
|
|
tracked!(assume_incomplete_release, true);
|
2020-04-21 00:55:02 -05:00
|
|
|
tracked!(asm_comments, true);
|
|
|
|
tracked!(binary_dep_depinfo, true);
|
2020-03-03 10:25:03 -06:00
|
|
|
tracked!(chalk, true);
|
2020-04-21 00:55:02 -05:00
|
|
|
tracked!(codegen_backend, Some("abc".to_string()));
|
|
|
|
tracked!(crate_attr, vec!["abc".to_string()]);
|
|
|
|
tracked!(debug_macros, true);
|
|
|
|
tracked!(dep_info_omit_d_target, true);
|
|
|
|
tracked!(dual_proc_macros, true);
|
2020-11-22 18:00:00 -06:00
|
|
|
tracked!(fewer_names, Some(true));
|
2020-04-21 00:55:02 -05:00
|
|
|
tracked!(force_overflow_checks, Some(true));
|
|
|
|
tracked!(force_unstable_if_unmarked, true);
|
|
|
|
tracked!(fuel, Some(("abc".to_string(), 99)));
|
2020-10-26 14:55:07 -05:00
|
|
|
tracked!(function_sections, Some(false));
|
2020-04-21 00:55:02 -05:00
|
|
|
tracked!(human_readable_cgu_names, true);
|
|
|
|
tracked!(inline_in_all_cgus, Some(true));
|
2021-02-20 18:00:00 -06:00
|
|
|
tracked!(inline_mir, Some(true));
|
2021-02-20 18:00:00 -06:00
|
|
|
tracked!(inline_mir_threshold, Some(123));
|
|
|
|
tracked!(inline_mir_hint_threshold, Some(123));
|
coverage bug fixes and optimization support
Adjusted LLVM codegen for code compiled with `-Zinstrument-coverage` to
address multiple, somewhat related issues.
Fixed a significant flaw in prior coverage solution: Every counter
generated a new counter variable, but there should have only been one
counter variable per function. This appears to have bloated .profraw
files significantly. (For a small program, it increased the size by
about 40%. I have not tested large programs, but there is anecdotal
evidence that profraw files were way too large. This is a good fix,
regardless, but hopefully it also addresses related issues.
Fixes: #82144
Invalid LLVM coverage data produced when compiled with -C opt-level=1
Existing tests now work up to at least `opt-level=3`. This required a
detailed analysis of the LLVM IR, comparisons with Clang C++ LLVM IR
when compiled with coverage, and a lot of trial and error with codegen
adjustments.
The biggest hurdle was figuring out how to continue to support coverage
results for unused functions and generics. Rust's coverage results have
three advantages over Clang's coverage results:
1. Rust's coverage map does not include any overlapping code regions,
making coverage counting unambiguous.
2. Rust generates coverage results (showing zero counts) for all unused
functions, including generics. (Clang does not generate coverage for
uninstantiated template functions.)
3. Rust's unused functions produce minimal stubbed functions in LLVM IR,
sufficient for including in the coverage results; while Clang must
generate the complete LLVM IR for each unused function, even though
it will never be called.
This PR removes the previous hack of attempting to inject coverage into
some other existing function instance, and generates dedicated instances
for each unused function. This change, and a few other adjustments
(similar to what is required for `-C link-dead-code`, but with lower
impact), makes it possible to support LLVM optimizations.
Fixes: #79651
Coverage report: "Unexecuted instantiation:..." for a generic function
from multiple crates
Fixed by removing the aforementioned hack. Some "Unexecuted
instantiation" notices are unavoidable, as explained in the
`used_crate.rs` test, but `-Zinstrument-coverage` has new options to
back off support for either unused generics, or all unused functions,
which avoids the notice, at the cost of less coverage of unused
functions.
Fixes: #82875
Invalid LLVM coverage data produced with crate brotli_decompressor
Fixed by disabling the LLVM function attribute that forces inlining, if
`-Z instrument-coverage` is enabled. This attribute is applied to
Rust functions with `#[inline(always)], and in some cases, the forced
inlining breaks coverage instrumentation and reports.
2021-03-15 18:32:45 -05:00
|
|
|
tracked!(instrument_coverage, Some(InstrumentCoverage::All));
|
2020-04-21 00:55:02 -05:00
|
|
|
tracked!(instrument_mcount, true);
|
|
|
|
tracked!(link_only, true);
|
|
|
|
tracked!(merge_functions, Some(MergeFunctions::Disabled));
|
|
|
|
tracked!(mir_emit_retag, true);
|
2021-03-04 08:13:39 -06:00
|
|
|
tracked!(mir_opt_level, Some(4));
|
2021-03-18 16:10:36 -05:00
|
|
|
tracked!(mutable_noalias, Some(true));
|
2020-04-21 00:55:02 -05:00
|
|
|
tracked!(new_llvm_pass_manager, true);
|
|
|
|
tracked!(no_codegen, true);
|
|
|
|
tracked!(no_generate_arange_section, true);
|
|
|
|
tracked!(no_link, true);
|
|
|
|
tracked!(no_profiler_runtime, true);
|
|
|
|
tracked!(osx_rpath_install_name, true);
|
|
|
|
tracked!(panic_abort_tests, true);
|
|
|
|
tracked!(plt, Some(true));
|
2020-11-24 20:58:20 -06:00
|
|
|
tracked!(polonius, true);
|
2020-10-01 13:31:43 -05:00
|
|
|
tracked!(precise_enum_drop_elaboration, false);
|
2020-04-21 00:55:02 -05:00
|
|
|
tracked!(print_fuel, Some("abc".to_string()));
|
|
|
|
tracked!(profile, true);
|
2020-05-26 12:41:40 -05:00
|
|
|
tracked!(profile_emit, Some(PathBuf::from("abc")));
|
2020-10-26 14:55:07 -05:00
|
|
|
tracked!(relax_elf_relocations, Some(true));
|
2020-04-21 00:55:02 -05:00
|
|
|
tracked!(relro_level, Some(RelroLevel::Full));
|
|
|
|
tracked!(report_delayed_bugs, true);
|
2020-06-13 19:00:00 -05:00
|
|
|
tracked!(sanitizer, SanitizerSet::ADDRESS);
|
2020-04-21 00:55:02 -05:00
|
|
|
tracked!(sanitizer_memory_track_origins, 2);
|
2020-06-13 19:00:00 -05:00
|
|
|
tracked!(sanitizer_recover, SanitizerSet::ADDRESS);
|
2020-04-17 20:42:22 -05:00
|
|
|
tracked!(saturating_float_casts, Some(true));
|
2020-04-21 00:55:02 -05:00
|
|
|
tracked!(share_generics, Some(true));
|
|
|
|
tracked!(show_span, Some(String::from("abc")));
|
|
|
|
tracked!(src_hash_algorithm, Some(SourceFileHashAlgorithm::Sha1));
|
2020-12-14 02:25:29 -06:00
|
|
|
tracked!(symbol_mangling_version, Some(SymbolManglingVersion::V0));
|
2020-04-21 00:55:02 -05:00
|
|
|
tracked!(teach, true);
|
|
|
|
tracked!(thinlto, Some(true));
|
2020-09-17 04:39:26 -05:00
|
|
|
tracked!(tune_cpu, Some(String::from("abc")));
|
2020-04-25 13:45:21 -05:00
|
|
|
tracked!(tls_model, Some(TlsModel::GeneralDynamic));
|
2020-11-23 17:55:10 -06:00
|
|
|
tracked!(trap_unreachable, Some(false));
|
2021-02-18 05:25:45 -06:00
|
|
|
tracked!(treat_err_as_bug, NonZeroUsize::new(1));
|
2020-04-21 00:55:02 -05:00
|
|
|
tracked!(unleash_the_miri_inside_of_you, true);
|
2020-04-16 21:40:11 -05:00
|
|
|
tracked!(use_ctors_section, Some(true));
|
2020-04-21 00:55:02 -05:00
|
|
|
tracked!(verify_llvm_ir, true);
|
2020-12-12 21:38:23 -06:00
|
|
|
tracked!(wasi_exec_model, Some(WasiExecModel::Reactor));
|
2019-06-05 13:16:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_edition_parsing() {
|
|
|
|
// test default edition
|
|
|
|
let options = Options::default();
|
|
|
|
assert!(options.edition == DEFAULT_EDITION);
|
|
|
|
|
2019-12-22 16:42:04 -06:00
|
|
|
let matches = optgroups().parse(&["--edition=2018".to_string()]).unwrap();
|
2019-10-10 03:26:10 -05:00
|
|
|
let (sessopts, _) = build_session_options_and_crate_config(matches);
|
2019-06-05 13:16:41 -05:00
|
|
|
assert!(sessopts.edition == Edition::Edition2018)
|
|
|
|
}
|