Remove rustc_session::config::Config
The wrapper type led to tons of target.target across the compiler. Its ptr_width field isn't required any more, as target_pointer_width is already present in parsed form.
This commit is contained in:
parent
4fa5578774
commit
d683e3ac23
@ -174,7 +174,6 @@ pub fn llvm_target_features(sess: &Session) -> impl Iterator<Item = &str> {
|
|||||||
.split(',')
|
.split(',')
|
||||||
.filter(|f| !RUSTC_SPECIFIC_FEATURES.iter().any(|s| f.contains(s)));
|
.filter(|f| !RUSTC_SPECIFIC_FEATURES.iter().any(|s| f.contains(s)));
|
||||||
sess.target
|
sess.target
|
||||||
.target
|
|
||||||
.options
|
.options
|
||||||
.features
|
.features
|
||||||
.split(',')
|
.split(',')
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
use rustc_target::spec::crt_objects::{CrtObjects, CrtObjectsFallback};
|
use rustc_target::spec::crt_objects::{CrtObjects, CrtObjectsFallback};
|
||||||
use rustc_target::spec::{LinkOutputKind, LinkerFlavor, LldFlavor};
|
use rustc_target::spec::{LinkOutputKind, LinkerFlavor, LldFlavor};
|
||||||
use rustc_target::spec::{PanicStrategy, RelocModel, RelroLevel};
|
use rustc_target::spec::{PanicStrategy, RelocModel, RelroLevel, Target};
|
||||||
|
|
||||||
use super::archive::ArchiveBuilder;
|
use super::archive::ArchiveBuilder;
|
||||||
use super::command::Command;
|
use super::command::Command;
|
||||||
@ -1842,12 +1842,8 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Converts a library file-stem into a cc -l argument
|
// Converts a library file-stem into a cc -l argument
|
||||||
fn unlib<'a>(config: &config::Config, stem: &'a str) -> &'a str {
|
fn unlib<'a>(target: &Target, stem: &'a str) -> &'a str {
|
||||||
if stem.starts_with("lib") && !config.target.options.is_like_windows {
|
if stem.starts_with("lib") && !target.options.is_like_windows { &stem[3..] } else { stem }
|
||||||
&stem[3..]
|
|
||||||
} else {
|
|
||||||
stem
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adds the static "rlib" versions of all crates to the command line.
|
// Adds the static "rlib" versions of all crates to the command line.
|
||||||
|
@ -34,11 +34,6 @@
|
|||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::str::{self, FromStr};
|
use std::str::{self, FromStr};
|
||||||
|
|
||||||
pub struct Config {
|
|
||||||
pub target: Target,
|
|
||||||
pub ptr_width: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
bitflags! {
|
bitflags! {
|
||||||
#[derive(Default, Encodable, Decodable)]
|
#[derive(Default, Encodable, Decodable)]
|
||||||
pub struct SanitizerSet: u8 {
|
pub struct SanitizerSet: u8 {
|
||||||
@ -831,7 +826,7 @@ pub fn build_configuration(sess: &Session, mut user_cfg: CrateConfig) -> CrateCo
|
|||||||
user_cfg
|
user_cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_target_config(opts: &Options, target_override: Option<Target>) -> Config {
|
pub fn build_target_config(opts: &Options, target_override: Option<Target>) -> Target {
|
||||||
let target_result = target_override.map_or_else(|| Target::search(&opts.target_triple), Ok);
|
let target_result = target_override.map_or_else(|| Target::search(&opts.target_triple), Ok);
|
||||||
let target = target_result.unwrap_or_else(|e| {
|
let target = target_result.unwrap_or_else(|e| {
|
||||||
early_error(
|
early_error(
|
||||||
@ -855,9 +850,7 @@ pub fn build_target_config(opts: &Options, target_override: Option<Target>) -> C
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
let ptr_width = target.pointer_width;
|
target
|
||||||
|
|
||||||
Config { target, ptr_width }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||||
|
@ -102,7 +102,7 @@ fn mul(self, rhs: usize) -> Self::Output {
|
|||||||
/// Represents the data associated with a compilation
|
/// Represents the data associated with a compilation
|
||||||
/// session for a single crate.
|
/// session for a single crate.
|
||||||
pub struct Session {
|
pub struct Session {
|
||||||
pub target: config::Config,
|
pub target: Target,
|
||||||
pub host: Target,
|
pub host: Target,
|
||||||
pub opts: config::Options,
|
pub opts: config::Options,
|
||||||
pub host_tlib_path: SearchPath,
|
pub host_tlib_path: SearchPath,
|
||||||
@ -1258,7 +1258,7 @@ pub fn build_session(
|
|||||||
|
|
||||||
let loader = file_loader.unwrap_or(Box::new(RealFileLoader));
|
let loader = file_loader.unwrap_or(Box::new(RealFileLoader));
|
||||||
let hash_kind = sopts.debugging_opts.src_hash_algorithm.unwrap_or_else(|| {
|
let hash_kind = sopts.debugging_opts.src_hash_algorithm.unwrap_or_else(|| {
|
||||||
if target_cfg.target.options.is_like_msvc {
|
if target_cfg.options.is_like_msvc {
|
||||||
SourceFileHashAlgorithm::Sha1
|
SourceFileHashAlgorithm::Sha1
|
||||||
} else {
|
} else {
|
||||||
SourceFileHashAlgorithm::Md5
|
SourceFileHashAlgorithm::Md5
|
||||||
@ -1368,8 +1368,8 @@ pub fn build_session(
|
|||||||
if candidate.join("library/std/src/lib.rs").is_file() { Some(candidate) } else { None }
|
if candidate.join("library/std/src/lib.rs").is_file() { Some(candidate) } else { None }
|
||||||
};
|
};
|
||||||
|
|
||||||
let asm_arch = if target_cfg.target.options.allow_asm {
|
let asm_arch = if target_cfg.options.allow_asm {
|
||||||
InlineAsmArch::from_str(&target_cfg.target.arch).ok()
|
InlineAsmArch::from_str(&target_cfg.arch).ok()
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
@ -9,10 +9,10 @@
|
|||||||
use rustc_hir::{Body, FnDecl, HirId, ItemKind, MutTy, Mutability, Node};
|
use rustc_hir::{Body, FnDecl, HirId, ItemKind, MutTy, Mutability, Node};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_middle::ty;
|
use rustc_middle::ty;
|
||||||
use rustc_session::config::Config as SessionConfig;
|
|
||||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use rustc_target::abi::LayoutOf;
|
use rustc_target::abi::LayoutOf;
|
||||||
|
use rustc_target::spec::Target;
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_target::spec::abi::Abi;
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
@ -60,9 +60,9 @@ pub struct TriviallyCopyPassByRef {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> TriviallyCopyPassByRef {
|
impl<'tcx> TriviallyCopyPassByRef {
|
||||||
pub fn new(limit: Option<u64>, target: &SessionConfig) -> Self {
|
pub fn new(limit: Option<u64>, target: &Target) -> Self {
|
||||||
let limit = limit.unwrap_or_else(|| {
|
let limit = limit.unwrap_or_else(|| {
|
||||||
let bit_width = u64::from(target.ptr_width);
|
let bit_width = u64::from(target.pointer_width);
|
||||||
// Cap the calculated bit width at 32-bits to reduce
|
// Cap the calculated bit width at 32-bits to reduce
|
||||||
// portability problems between 32 and 64-bit targets
|
// portability problems between 32 and 64-bit targets
|
||||||
let bit_width = cmp::min(bit_width, 32);
|
let bit_width = cmp::min(bit_width, 32);
|
||||||
|
Loading…
Reference in New Issue
Block a user