//! Contains infrastructure for configuring the compiler, including parsing
//! command-line options.
-use crate::lint;
-use crate::middle::cstore;
+use rustc_session::lint;
+use rustc_session::utils::NativeLibraryKind;
use crate::session::{early_error, early_warn, Session};
use crate::session::search_paths::SearchPath;
use rustc_data_structures::fx::FxHashSet;
+use rustc_feature::UnstableFeatures;
use rustc_target::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, RelroLevel};
use rustc_target::spec::{Target, TargetTriple};
-use syntax;
-use syntax::ast::{self, IntTy, UintTy};
+use syntax::ast::CrateConfig;
use syntax::source_map::{FileName, FilePathMapping};
use syntax::edition::{Edition, EDITION_NAME_LIST, DEFAULT_EDITION};
use syntax::symbol::{sym, Symbol};
-use syntax::feature_gate::UnstableFeatures;
use errors::emitter::HumanReadableErrorType;
use errors::{ColorConfig, FatalError, Handler};
pub struct Config {
pub target: Target,
- pub isize_ty: IntTy,
- pub usize_ty: UintTy,
+ pub ptr_width: u32,
}
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
Thread,
}
+impl fmt::Display for Sanitizer {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ match *self {
+ Sanitizer::Address => "address".fmt(f),
+ Sanitizer::Leak => "leak".fmt(f),
+ Sanitizer::Memory => "memory".fmt(f),
+ Sanitizer::Thread => "thread".fmt(f),
+ }
+ }
+}
+
impl FromStr for Sanitizer {
type Err = ();
fn from_str(s: &str) -> Result<Sanitizer, ()> {
describe_lints: bool [UNTRACKED],
output_types: OutputTypes [TRACKED],
search_paths: Vec<SearchPath> [UNTRACKED],
- libs: Vec<(String, Option<String>, Option<cstore::NativeLibraryKind>)> [TRACKED],
+ libs: Vec<(String, Option<String>, Option<NativeLibraryKind>)> [TRACKED],
maybe_sysroot: Option<PathBuf> [UNTRACKED],
target_triple: TargetTriple [TRACKED],
"enable queries of the dependency graph for regression testing"),
no_analysis: bool = (false, parse_bool, [UNTRACKED],
"parse and expand the source, but run no analysis"),
- extra_plugins: Vec<String> = (Vec::new(), parse_list, [TRACKED],
- "load extra plugins"),
unstable_options: bool = (false, parse_bool, [UNTRACKED],
"adds unstable command line options to rustc interface"),
force_overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
CrateType::Rlib
}
-pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
+pub fn default_configuration(sess: &Session) -> CrateConfig {
let end = &sess.target.target.target_endian;
let arch = &sess.target.target.arch;
let wordsz = &sess.target.target.target_pointer_width;
}
}
}
+ if let Some(s) = &sess.opts.debugging_opts.sanitizer {
+ let symbol = Symbol::intern(&s.to_string());
+ ret.insert((sym::sanitize, Some(symbol)));
+ }
if sess.opts.debug_assertions {
ret.insert((Symbol::intern("debug_assertions"), None));
}
/// Converts the crate `cfg!` configuration from `String` to `Symbol`.
/// `rustc_interface::interface::Config` accepts this in the compiler configuration,
/// but the symbol interner is not yet set up then, so we must convert it later.
-pub fn to_crate_config(cfg: FxHashSet<(String, Option<String>)>) -> ast::CrateConfig {
+pub fn to_crate_config(cfg: FxHashSet<(String, Option<String>)>) -> CrateConfig {
cfg.into_iter()
.map(|(a, b)| (Symbol::intern(&a), b.map(|b| Symbol::intern(&b))))
.collect()
}
-pub fn build_configuration(sess: &Session, mut user_cfg: ast::CrateConfig) -> ast::CrateConfig {
+pub fn build_configuration(sess: &Session, mut user_cfg: CrateConfig) -> CrateConfig {
// Combine the configuration requested by the session (command line) with
// some default and generated configuration items.
let default_cfg = default_configuration(sess);
FatalError.raise();
});
- let (isize_ty, usize_ty) = match &target.target_pointer_width[..] {
- "16" => (ast::IntTy::I16, ast::UintTy::U16),
- "32" => (ast::IntTy::I32, ast::UintTy::U32),
- "64" => (ast::IntTy::I64, ast::UintTy::U64),
+ let ptr_width = match &target.target_pointer_width[..] {
+ "16" => 16,
+ "32" => 32,
+ "64" => 64,
w => sp.fatal(&format!(
"target specification was invalid: \
unrecognized target-pointer-width {}",
Config {
target,
- isize_ty,
- usize_ty,
+ ptr_width,
}
}
fn parse_libs(
matches: &getopts::Matches,
error_format: ErrorOutputType,
-) -> Vec<(String, Option<String>, Option<cstore::NativeLibraryKind>)> {
+) -> Vec<(String, Option<String>, Option<NativeLibraryKind>)> {
matches
.opt_strs("l")
.into_iter()
let kind = parts.next().unwrap();
let (name, kind) = match (parts.next(), kind) {
(None, name) => (name, None),
- (Some(name), "dylib") => (name, Some(cstore::NativeUnknown)),
- (Some(name), "framework") => (name, Some(cstore::NativeFramework)),
- (Some(name), "static") => (name, Some(cstore::NativeStatic)),
- (Some(name), "static-nobundle") => (name, Some(cstore::NativeStaticNobundle)),
+ (Some(name), "dylib") => (name, Some(NativeLibraryKind::NativeUnknown)),
+ (Some(name), "framework") => (name, Some(NativeLibraryKind::NativeFramework)),
+ (Some(name), "static") => (name, Some(NativeLibraryKind::NativeStatic)),
+ (Some(name), "static-nobundle") => {
+ (name, Some(NativeLibraryKind::NativeStaticNobundle))
+ }
(_, s) => {
early_error(
error_format,
);
}
};
- if kind == Some(cstore::NativeStaticNobundle) && !nightly_options::is_nightly_build() {
+ if kind == Some(NativeLibraryKind::NativeStaticNobundle) &&
+ !nightly_options::is_nightly_build() {
early_error(
error_format,
&format!(
pub mod nightly_options {
use getopts;
- use syntax::feature_gate::UnstableFeatures;
+ use rustc_feature::UnstableFeatures;
use super::{ErrorOutputType, OptionStability, RustcOptGroup};
use crate::session::early_error;
/// we have an opt-in scheme here, so one is hopefully forced to think about
/// how the hash should be calculated when adding a new command-line argument.
mod dep_tracking {
- use crate::lint;
- use crate::middle::cstore;
+ use rustc_session::lint;
+ use rustc_session::utils::NativeLibraryKind;
use std::collections::BTreeMap;
use std::hash::Hash;
use std::path::PathBuf;
use super::{CrateType, DebugInfo, ErrorOutputType, OptLevel, OutputTypes,
Passes, Sanitizer, LtoCli, LinkerPluginLto, SwitchWithOptPath,
SymbolManglingVersion};
+ use rustc_feature::UnstableFeatures;
use rustc_target::spec::{MergeFunctions, PanicStrategy, RelroLevel, TargetTriple};
use syntax::edition::Edition;
- use syntax::feature_gate::UnstableFeatures;
pub trait DepTrackingHash {
fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType);
impl_dep_tracking_hash_via_hash!(Option<RelroLevel>);
impl_dep_tracking_hash_via_hash!(Option<lint::Level>);
impl_dep_tracking_hash_via_hash!(Option<PathBuf>);
- impl_dep_tracking_hash_via_hash!(Option<cstore::NativeLibraryKind>);
+ impl_dep_tracking_hash_via_hash!(Option<NativeLibraryKind>);
impl_dep_tracking_hash_via_hash!(CrateType);
impl_dep_tracking_hash_via_hash!(MergeFunctions);
impl_dep_tracking_hash_via_hash!(PanicStrategy);
impl_dep_tracking_hash_via_hash!(DebugInfo);
impl_dep_tracking_hash_via_hash!(UnstableFeatures);
impl_dep_tracking_hash_via_hash!(OutputTypes);
- impl_dep_tracking_hash_via_hash!(cstore::NativeLibraryKind);
+ impl_dep_tracking_hash_via_hash!(NativeLibraryKind);
impl_dep_tracking_hash_via_hash!(Sanitizer);
impl_dep_tracking_hash_via_hash!(Option<Sanitizer>);
impl_dep_tracking_hash_via_hash!(TargetTriple);
impl_dep_tracking_hash_for_sortable_vec_of!((
String,
Option<String>,
- Option<cstore::NativeLibraryKind>
+ Option<NativeLibraryKind>
));
impl_dep_tracking_hash_for_sortable_vec_of!((String, u64));
impl_dep_tracking_hash_for_sortable_vec_of!(Sanitizer);