Rollup merge of #121567 - Nilstrieb:less-interning, r=albertlarsan68
Avoid some interning in bootstrap This interning is pointless and only makes the code more complex. The only remaining use of interning is `TargetSelection`, for which I left a comment.
This commit is contained in:
commit
0f89faebb1
@ -8,12 +8,10 @@ use crate::core::builder::{
|
||||
self, crate_description, Alias, Builder, Kind, RunConfig, ShouldRun, Step,
|
||||
};
|
||||
use crate::core::config::TargetSelection;
|
||||
use crate::utils::cache::Interned;
|
||||
use crate::INTERNER;
|
||||
use crate::{Compiler, Mode, Subcommand};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Std {
|
||||
pub target: TargetSelection,
|
||||
/// Whether to build only a subset of crates.
|
||||
@ -21,7 +19,7 @@ pub struct Std {
|
||||
/// This shouldn't be used from other steps; see the comment on [`compile::Rustc`].
|
||||
///
|
||||
/// [`compile::Rustc`]: crate::core::build_steps::compile::Rustc
|
||||
crates: Interned<Vec<String>>,
|
||||
crates: Vec<String>,
|
||||
}
|
||||
|
||||
/// Returns args for the subcommand itself (not for cargo)
|
||||
@ -89,7 +87,7 @@ fn cargo_subcommand(kind: Kind) -> &'static str {
|
||||
|
||||
impl Std {
|
||||
pub fn new(target: TargetSelection) -> Self {
|
||||
Self { target, crates: INTERNER.intern_list(vec![]) }
|
||||
Self { target, crates: vec![] }
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,7 +202,7 @@ impl Step for Std {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Rustc {
|
||||
pub target: TargetSelection,
|
||||
/// Whether to build only a subset of crates.
|
||||
@ -212,7 +210,7 @@ pub struct Rustc {
|
||||
/// This shouldn't be used from other steps; see the comment on [`compile::Rustc`].
|
||||
///
|
||||
/// [`compile::Rustc`]: crate::core::build_steps::compile::Rustc
|
||||
crates: Interned<Vec<String>>,
|
||||
crates: Vec<String>,
|
||||
}
|
||||
|
||||
impl Rustc {
|
||||
@ -222,7 +220,7 @@ impl Rustc {
|
||||
.into_iter()
|
||||
.map(|krate| krate.name.to_string())
|
||||
.collect();
|
||||
Self { target, crates: INTERNER.intern_list(crates) }
|
||||
Self { target, crates }
|
||||
}
|
||||
}
|
||||
|
||||
@ -305,10 +303,10 @@ impl Step for Rustc {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct CodegenBackend {
|
||||
pub target: TargetSelection,
|
||||
pub backend: Interned<String>,
|
||||
pub backend: &'static str,
|
||||
}
|
||||
|
||||
impl Step for CodegenBackend {
|
||||
@ -321,14 +319,14 @@ impl Step for CodegenBackend {
|
||||
}
|
||||
|
||||
fn make_run(run: RunConfig<'_>) {
|
||||
for &backend in &[INTERNER.intern_str("cranelift"), INTERNER.intern_str("gcc")] {
|
||||
for &backend in &["cranelift", "gcc"] {
|
||||
run.builder.ensure(CodegenBackend { target: run.target, backend });
|
||||
}
|
||||
}
|
||||
|
||||
fn run(self, builder: &Builder<'_>) {
|
||||
// FIXME: remove once https://github.com/rust-lang/rust/issues/112393 is resolved
|
||||
if builder.build.config.vendor && &self.backend == "gcc" {
|
||||
if builder.build.config.vendor && self.backend == "gcc" {
|
||||
println!("Skipping checking of `rustc_codegen_gcc` with vendoring enabled.");
|
||||
return;
|
||||
}
|
||||
@ -552,7 +550,7 @@ fn codegen_backend_stamp(
|
||||
builder: &Builder<'_>,
|
||||
compiler: Compiler,
|
||||
target: TargetSelection,
|
||||
backend: Interned<String>,
|
||||
backend: &str,
|
||||
) -> PathBuf {
|
||||
builder
|
||||
.cargo_out(compiler, Mode::Codegen, target)
|
||||
|
@ -10,7 +10,6 @@ use std::io::{self, ErrorKind};
|
||||
use std::path::Path;
|
||||
|
||||
use crate::core::builder::{crate_description, Builder, RunConfig, ShouldRun, Step};
|
||||
use crate::utils::cache::Interned;
|
||||
use crate::utils::helpers::t;
|
||||
use crate::{Build, Compiler, Mode, Subcommand};
|
||||
|
||||
@ -44,10 +43,10 @@ impl Step for CleanAll {
|
||||
|
||||
macro_rules! clean_crate_tree {
|
||||
( $( $name:ident, $mode:path, $root_crate:literal);+ $(;)? ) => { $(
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct $name {
|
||||
compiler: Compiler,
|
||||
crates: Interned<Vec<String>>,
|
||||
crates: Vec<String>,
|
||||
}
|
||||
|
||||
impl Step for $name {
|
||||
|
@ -27,7 +27,6 @@ use crate::core::builder::crate_description;
|
||||
use crate::core::builder::Cargo;
|
||||
use crate::core::builder::{Builder, Kind, PathSet, RunConfig, ShouldRun, Step, TaskPath};
|
||||
use crate::core::config::{DebuginfoLevel, LlvmLibunwind, RustcLto, TargetSelection};
|
||||
use crate::utils::cache::{Interned, INTERNER};
|
||||
use crate::utils::helpers::{
|
||||
exe, get_clang_cl_resource_dir, is_debug_info, is_dylib, output, symlink_dir, t, up_to_date,
|
||||
};
|
||||
@ -35,14 +34,14 @@ use crate::LLVM_TOOLS;
|
||||
use crate::{CLang, Compiler, DependencyType, GitRepo, Mode};
|
||||
use filetime::FileTime;
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct Std {
|
||||
pub target: TargetSelection,
|
||||
pub compiler: Compiler,
|
||||
/// Whether to build only a subset of crates in the standard library.
|
||||
///
|
||||
/// This shouldn't be used from other steps; see the comment on [`Rustc`].
|
||||
crates: Interned<Vec<String>>,
|
||||
crates: Vec<String>,
|
||||
/// When using download-rustc, we need to use a new build of `std` for running unit tests of Std itself,
|
||||
/// but we need to use the downloaded copy of std for linking to rustdoc. Allow this to be overriden by `builder.ensure` from other steps.
|
||||
force_recompile: bool,
|
||||
@ -559,13 +558,13 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car
|
||||
cargo.rustdocflag("-Zcrate-attr=warn(rust_2018_idioms)");
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
struct StdLink {
|
||||
pub compiler: Compiler,
|
||||
pub target_compiler: Compiler,
|
||||
pub target: TargetSelection,
|
||||
/// Not actually used; only present to make sure the cache invalidation is correct.
|
||||
crates: Interned<Vec<String>>,
|
||||
crates: Vec<String>,
|
||||
/// See [`Std::force_recompile`].
|
||||
force_recompile: bool,
|
||||
}
|
||||
@ -612,7 +611,7 @@ impl Step for StdLink {
|
||||
});
|
||||
let libdir = sysroot.join(lib).join("rustlib").join(target.triple).join("lib");
|
||||
let hostdir = sysroot.join(lib).join("rustlib").join(compiler.host.triple).join("lib");
|
||||
(INTERNER.intern_path(libdir), INTERNER.intern_path(hostdir))
|
||||
(libdir, hostdir)
|
||||
} else {
|
||||
let libdir = builder.sysroot_libdir(target_compiler, target);
|
||||
let hostdir = builder.sysroot_libdir(target_compiler, compiler.host);
|
||||
@ -818,7 +817,7 @@ fn cp_rustc_component_to_ci_sysroot(
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialOrd, Ord, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, PartialOrd, Ord, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Rustc {
|
||||
pub target: TargetSelection,
|
||||
pub compiler: Compiler,
|
||||
@ -827,7 +826,7 @@ pub struct Rustc {
|
||||
/// This should only be requested by the user, not used within rustbuild itself.
|
||||
/// Using it within rustbuild can lead to confusing situation where lints are replayed
|
||||
/// in two different steps.
|
||||
crates: Interned<Vec<String>>,
|
||||
crates: Vec<String>,
|
||||
}
|
||||
|
||||
impl Rustc {
|
||||
@ -1220,13 +1219,13 @@ fn rustc_llvm_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelect
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
struct RustcLink {
|
||||
pub compiler: Compiler,
|
||||
pub target_compiler: Compiler,
|
||||
pub target: TargetSelection,
|
||||
/// Not actually used; only present to make sure the cache invalidation is correct.
|
||||
crates: Interned<Vec<String>>,
|
||||
crates: Vec<String>,
|
||||
}
|
||||
|
||||
impl RustcLink {
|
||||
@ -1261,11 +1260,11 @@ impl Step for RustcLink {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct CodegenBackend {
|
||||
pub target: TargetSelection,
|
||||
pub compiler: Compiler,
|
||||
pub backend: Interned<String>,
|
||||
pub backend: String,
|
||||
}
|
||||
|
||||
fn needs_codegen_config(run: &RunConfig<'_>) -> bool {
|
||||
@ -1284,7 +1283,7 @@ pub(crate) const CODEGEN_BACKEND_PREFIX: &str = "rustc_codegen_";
|
||||
fn is_codegen_cfg_needed(path: &TaskPath, run: &RunConfig<'_>) -> bool {
|
||||
if path.path.to_str().unwrap().contains(CODEGEN_BACKEND_PREFIX) {
|
||||
let mut needs_codegen_backend_config = true;
|
||||
for &backend in run.builder.config.codegen_backends(run.target) {
|
||||
for backend in run.builder.config.codegen_backends(run.target) {
|
||||
if path
|
||||
.path
|
||||
.to_str()
|
||||
@ -1321,7 +1320,7 @@ impl Step for CodegenBackend {
|
||||
return;
|
||||
}
|
||||
|
||||
for &backend in run.builder.config.codegen_backends(run.target) {
|
||||
for backend in run.builder.config.codegen_backends(run.target) {
|
||||
if backend == "llvm" {
|
||||
continue; // Already built as part of rustc
|
||||
}
|
||||
@ -1329,7 +1328,7 @@ impl Step for CodegenBackend {
|
||||
run.builder.ensure(CodegenBackend {
|
||||
target: run.target,
|
||||
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()),
|
||||
backend,
|
||||
backend: backend.clone(),
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1394,7 +1393,7 @@ impl Step for CodegenBackend {
|
||||
f.display()
|
||||
);
|
||||
}
|
||||
let stamp = codegen_backend_stamp(builder, compiler, target, backend);
|
||||
let stamp = codegen_backend_stamp(builder, compiler, target, &backend);
|
||||
let codegen_backend = codegen_backend.to_str().unwrap();
|
||||
t!(fs::write(stamp, codegen_backend));
|
||||
}
|
||||
@ -1433,7 +1432,7 @@ fn copy_codegen_backends_to_sysroot(
|
||||
continue; // Already built as part of rustc
|
||||
}
|
||||
|
||||
let stamp = codegen_backend_stamp(builder, compiler, target, *backend);
|
||||
let stamp = codegen_backend_stamp(builder, compiler, target, backend);
|
||||
let dylib = t!(fs::read_to_string(&stamp));
|
||||
let file = Path::new(&dylib);
|
||||
let filename = file.file_name().unwrap().to_str().unwrap();
|
||||
@ -1470,7 +1469,7 @@ fn codegen_backend_stamp(
|
||||
builder: &Builder<'_>,
|
||||
compiler: Compiler,
|
||||
target: TargetSelection,
|
||||
backend: Interned<String>,
|
||||
backend: &str,
|
||||
) -> PathBuf {
|
||||
builder
|
||||
.cargo_out(compiler, Mode::Codegen, target)
|
||||
@ -1508,7 +1507,7 @@ impl Sysroot {
|
||||
}
|
||||
|
||||
impl Step for Sysroot {
|
||||
type Output = Interned<PathBuf>;
|
||||
type Output = PathBuf;
|
||||
|
||||
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
||||
run.never()
|
||||
@ -1520,7 +1519,7 @@ impl Step for Sysroot {
|
||||
/// That is, the sysroot for the stage0 compiler is not what the compiler
|
||||
/// thinks it is by default, but it's the same as the default for stages
|
||||
/// 1-3.
|
||||
fn run(self, builder: &Builder<'_>) -> Interned<PathBuf> {
|
||||
fn run(self, builder: &Builder<'_>) -> PathBuf {
|
||||
let compiler = self.compiler;
|
||||
let host_dir = builder.out.join(compiler.host.triple);
|
||||
|
||||
@ -1652,7 +1651,7 @@ impl Step for Sysroot {
|
||||
);
|
||||
}
|
||||
|
||||
INTERNER.intern_path(sysroot)
|
||||
sysroot
|
||||
}
|
||||
}
|
||||
|
||||
@ -1735,7 +1734,7 @@ impl Step for Assemble {
|
||||
// to not fail while linking the artifacts.
|
||||
build_compiler.stage = actual_stage;
|
||||
|
||||
for &backend in builder.config.codegen_backends(target_compiler.host) {
|
||||
for backend in builder.config.codegen_backends(target_compiler.host) {
|
||||
if backend == "llvm" {
|
||||
continue; // Already built as part of rustc
|
||||
}
|
||||
@ -1743,7 +1742,7 @@ impl Step for Assemble {
|
||||
builder.ensure(CodegenBackend {
|
||||
compiler: build_compiler,
|
||||
target: target_compiler.host,
|
||||
backend,
|
||||
backend: backend.clone(),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,6 @@ use crate::core::build_steps::llvm;
|
||||
use crate::core::build_steps::tool::{self, Tool};
|
||||
use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
|
||||
use crate::core::config::TargetSelection;
|
||||
use crate::utils::cache::{Interned, INTERNER};
|
||||
use crate::utils::channel;
|
||||
use crate::utils::helpers::{exe, is_dylib, output, t, target_supports_cranelift_backend, timeit};
|
||||
use crate::utils::tarball::{GeneratedTarball, OverlayKind, Tarball};
|
||||
@ -489,8 +488,7 @@ impl Step for Rustc {
|
||||
}
|
||||
|
||||
// Debugger scripts
|
||||
builder
|
||||
.ensure(DebuggerScripts { sysroot: INTERNER.intern_path(image.to_owned()), host });
|
||||
builder.ensure(DebuggerScripts { sysroot: image.to_owned(), host });
|
||||
|
||||
// Misc license info
|
||||
let cp = |file: &str| {
|
||||
@ -504,9 +502,9 @@ impl Step for Rustc {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
|
||||
pub struct DebuggerScripts {
|
||||
pub sysroot: Interned<PathBuf>,
|
||||
pub sysroot: PathBuf,
|
||||
pub host: TargetSelection,
|
||||
}
|
||||
|
||||
@ -1264,10 +1262,10 @@ impl Step for Miri {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
|
||||
pub struct CodegenBackend {
|
||||
pub compiler: Compiler,
|
||||
pub backend: Interned<String>,
|
||||
pub backend: String,
|
||||
}
|
||||
|
||||
impl Step for CodegenBackend {
|
||||
@ -1280,14 +1278,14 @@ impl Step for CodegenBackend {
|
||||
}
|
||||
|
||||
fn make_run(run: RunConfig<'_>) {
|
||||
for &backend in run.builder.config.codegen_backends(run.target) {
|
||||
for backend in run.builder.config.codegen_backends(run.target) {
|
||||
if backend == "llvm" {
|
||||
continue; // Already built as part of rustc
|
||||
}
|
||||
|
||||
run.builder.ensure(CodegenBackend {
|
||||
compiler: run.builder.compiler(run.builder.top_stage, run.target),
|
||||
backend,
|
||||
backend: backend.clone(),
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1304,7 +1302,8 @@ impl Step for CodegenBackend {
|
||||
return None;
|
||||
}
|
||||
|
||||
if !builder.config.codegen_backends(self.compiler.host).contains(&self.backend) {
|
||||
if !builder.config.codegen_backends(self.compiler.host).contains(&self.backend.to_string())
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
||||
@ -1529,7 +1528,7 @@ impl Step for Extended {
|
||||
add_component!("analysis" => Analysis { compiler, target });
|
||||
add_component!("rustc-codegen-cranelift" => CodegenBackend {
|
||||
compiler: builder.compiler(stage, target),
|
||||
backend: INTERNER.intern_str("cranelift"),
|
||||
backend: "cranelift".to_string(),
|
||||
});
|
||||
|
||||
let etc = builder.src.join("src/etc/installer");
|
||||
|
@ -16,7 +16,6 @@ use crate::core::build_steps::tool::{self, prepare_tool_cargo, SourceType, Tool}
|
||||
use crate::core::builder::{self, crate_description};
|
||||
use crate::core::builder::{Alias, Builder, Compiler, Kind, RunConfig, ShouldRun, Step};
|
||||
use crate::core::config::{Config, TargetSelection};
|
||||
use crate::utils::cache::{Interned, INTERNER};
|
||||
use crate::utils::helpers::{dir_is_empty, symlink_dir, t, up_to_date};
|
||||
use crate::Mode;
|
||||
|
||||
@ -59,8 +58,8 @@ macro_rules! book {
|
||||
)?
|
||||
builder.ensure(RustbookSrc {
|
||||
target: self.target,
|
||||
name: INTERNER.intern_str($book_name),
|
||||
src: INTERNER.intern_path(builder.src.join($path)),
|
||||
name: $book_name.to_owned(),
|
||||
src: builder.src.join($path),
|
||||
parent: Some(self),
|
||||
})
|
||||
}
|
||||
@ -108,18 +107,18 @@ impl Step for UnstableBook {
|
||||
builder.ensure(UnstableBookGen { target: self.target });
|
||||
builder.ensure(RustbookSrc {
|
||||
target: self.target,
|
||||
name: INTERNER.intern_str("unstable-book"),
|
||||
src: INTERNER.intern_path(builder.md_doc_out(self.target).join("unstable-book")),
|
||||
name: "unstable-book".to_owned(),
|
||||
src: builder.md_doc_out(self.target).join("unstable-book"),
|
||||
parent: Some(self),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
|
||||
struct RustbookSrc<P: Step> {
|
||||
target: TargetSelection,
|
||||
name: Interned<String>,
|
||||
src: Interned<PathBuf>,
|
||||
name: String,
|
||||
src: PathBuf,
|
||||
parent: Option<P>,
|
||||
}
|
||||
|
||||
@ -141,7 +140,7 @@ impl<P: Step> Step for RustbookSrc<P> {
|
||||
let out = builder.doc_out(target);
|
||||
t!(fs::create_dir_all(&out));
|
||||
|
||||
let out = out.join(name);
|
||||
let out = out.join(&name);
|
||||
let index = out.join("index.html");
|
||||
let rustbook = builder.tool_exe(Tool::Rustbook);
|
||||
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
|
||||
@ -211,8 +210,8 @@ impl Step for TheBook {
|
||||
// build book
|
||||
builder.ensure(RustbookSrc {
|
||||
target,
|
||||
name: INTERNER.intern_str("book"),
|
||||
src: INTERNER.intern_path(absolute_path.clone()),
|
||||
name: "book".to_owned(),
|
||||
src: absolute_path.clone(),
|
||||
parent: Some(self),
|
||||
});
|
||||
|
||||
@ -220,8 +219,8 @@ impl Step for TheBook {
|
||||
for edition in &["first-edition", "second-edition", "2018-edition"] {
|
||||
builder.ensure(RustbookSrc {
|
||||
target,
|
||||
name: INTERNER.intern_string(format!("book/{edition}")),
|
||||
src: INTERNER.intern_path(absolute_path.join(edition)),
|
||||
name: format!("book/{edition}"),
|
||||
src: absolute_path.join(edition),
|
||||
// There should only be one book that is marked as the parent for each target, so
|
||||
// treat the other editions as not having a parent.
|
||||
parent: Option::<Self>::None,
|
||||
@ -526,12 +525,12 @@ impl Step for SharedAssets {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[derive(Debug, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct Std {
|
||||
pub stage: u32,
|
||||
pub target: TargetSelection,
|
||||
pub format: DocumentationFormat,
|
||||
crates: Interned<Vec<String>>,
|
||||
crates: Vec<String>,
|
||||
}
|
||||
|
||||
impl Std {
|
||||
@ -546,7 +545,7 @@ impl Std {
|
||||
.into_iter()
|
||||
.map(|krate| krate.name.to_string())
|
||||
.collect();
|
||||
Std { stage, target, format, crates: INTERNER.intern_list(crates) }
|
||||
Std { stage, target, format, crates }
|
||||
}
|
||||
}
|
||||
|
||||
@ -721,11 +720,11 @@ fn doc_std(
|
||||
builder.cp_r(&out_dir, out);
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
|
||||
pub struct Rustc {
|
||||
pub stage: u32,
|
||||
pub target: TargetSelection,
|
||||
crates: Interned<Vec<String>>,
|
||||
crates: Vec<String>,
|
||||
}
|
||||
|
||||
impl Rustc {
|
||||
@ -735,7 +734,7 @@ impl Rustc {
|
||||
.into_iter()
|
||||
.map(|krate| krate.name.to_string())
|
||||
.collect();
|
||||
Self { stage, target, crates: INTERNER.intern_list(crates) }
|
||||
Self { stage, target, crates }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1194,8 +1193,8 @@ impl Step for RustcBook {
|
||||
// Run rustbook/mdbook to generate the HTML pages.
|
||||
builder.ensure(RustbookSrc {
|
||||
target: self.target,
|
||||
name: INTERNER.intern_str("rustc"),
|
||||
src: INTERNER.intern_path(out_base),
|
||||
name: "rustc".to_owned(),
|
||||
src: out_base,
|
||||
parent: Some(self),
|
||||
});
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
|
||||
use crate::core::config::{Config, TargetSelection};
|
||||
use crate::utils::helpers::t;
|
||||
use crate::utils::tarball::GeneratedTarball;
|
||||
use crate::INTERNER;
|
||||
use crate::{Compiler, Kind};
|
||||
|
||||
#[cfg(target_os = "illumos")]
|
||||
@ -291,7 +290,7 @@ install!((self, builder, _config),
|
||||
RustcCodegenCranelift, alias = "rustc-codegen-cranelift", Self::should_build(_config), only_hosts: true, {
|
||||
if let Some(tarball) = builder.ensure(dist::CodegenBackend {
|
||||
compiler: self.compiler,
|
||||
backend: INTERNER.intern_str("cranelift"),
|
||||
backend: "cranelift".to_string(),
|
||||
}) {
|
||||
install_sh(builder, "rustc-codegen-cranelift", self.compiler.stage, Some(self.target), &tarball);
|
||||
} else {
|
||||
|
@ -26,7 +26,6 @@ use crate::core::builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step};
|
||||
use crate::core::config::flags::get_completion;
|
||||
use crate::core::config::flags::Subcommand;
|
||||
use crate::core::config::TargetSelection;
|
||||
use crate::utils::cache::{Interned, INTERNER};
|
||||
use crate::utils::exec::BootstrapCommand;
|
||||
use crate::utils::helpers::{
|
||||
self, add_link_lib_path, add_rustdoc_cargo_linker_args, dylib_path, dylib_path_var,
|
||||
@ -38,9 +37,9 @@ use crate::{envify, CLang, DocTests, GitRepo, Mode};
|
||||
|
||||
const ADB_TEST_DIR: &str = "/data/local/tmp/work";
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct CrateBootstrap {
|
||||
path: Interned<PathBuf>,
|
||||
path: PathBuf,
|
||||
host: TargetSelection,
|
||||
}
|
||||
|
||||
@ -58,7 +57,7 @@ impl Step for CrateBootstrap {
|
||||
|
||||
fn make_run(run: RunConfig<'_>) {
|
||||
for path in run.paths {
|
||||
let path = INTERNER.intern_path(path.assert_single_path().path.clone());
|
||||
let path = path.assert_single_path().path.clone();
|
||||
run.builder.ensure(CrateBootstrap { host: run.target, path });
|
||||
}
|
||||
}
|
||||
@ -623,7 +622,7 @@ impl Step for Miri {
|
||||
|
||||
// miri tests need to know about the stage sysroot
|
||||
cargo.env("MIRI_SYSROOT", &miri_sysroot);
|
||||
cargo.env("MIRI_HOST_SYSROOT", sysroot);
|
||||
cargo.env("MIRI_HOST_SYSROOT", &sysroot);
|
||||
cargo.env("MIRI", &miri);
|
||||
if builder.config.locked_deps {
|
||||
// enforce lockfiles
|
||||
@ -1646,8 +1645,10 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
|
||||
}
|
||||
|
||||
if suite == "debuginfo" {
|
||||
builder
|
||||
.ensure(dist::DebuggerScripts { sysroot: builder.sysroot(compiler), host: target });
|
||||
builder.ensure(dist::DebuggerScripts {
|
||||
sysroot: builder.sysroot(compiler).to_path_buf(),
|
||||
host: target,
|
||||
});
|
||||
}
|
||||
|
||||
// Also provide `rust_test_helpers` for the host.
|
||||
@ -2378,7 +2379,7 @@ impl Step for RustcGuide {
|
||||
pub struct CrateLibrustc {
|
||||
compiler: Compiler,
|
||||
target: TargetSelection,
|
||||
crates: Vec<Interned<String>>,
|
||||
crates: Vec<String>,
|
||||
}
|
||||
|
||||
impl Step for CrateLibrustc {
|
||||
@ -2394,8 +2395,11 @@ impl Step for CrateLibrustc {
|
||||
let builder = run.builder;
|
||||
let host = run.build_triple();
|
||||
let compiler = builder.compiler_for(builder.top_stage, host, host);
|
||||
let crates =
|
||||
run.paths.iter().map(|p| builder.crate_paths[&p.assert_single_path().path]).collect();
|
||||
let crates = run
|
||||
.paths
|
||||
.iter()
|
||||
.map(|p| builder.crate_paths[&p.assert_single_path().path].clone())
|
||||
.collect();
|
||||
|
||||
builder.ensure(CrateLibrustc { compiler, target: run.target, crates });
|
||||
}
|
||||
@ -2418,7 +2422,7 @@ impl Step for CrateLibrustc {
|
||||
fn run_cargo_test<'a>(
|
||||
cargo: impl Into<Command>,
|
||||
libtest_args: &[&str],
|
||||
crates: &[Interned<String>],
|
||||
crates: &[String],
|
||||
primary_crate: &str,
|
||||
description: impl Into<Option<&'a str>>,
|
||||
compiler: Compiler,
|
||||
@ -2449,7 +2453,7 @@ fn run_cargo_test<'a>(
|
||||
fn prepare_cargo_test(
|
||||
cargo: impl Into<Command>,
|
||||
libtest_args: &[&str],
|
||||
crates: &[Interned<String>],
|
||||
crates: &[String],
|
||||
primary_crate: &str,
|
||||
compiler: Compiler,
|
||||
target: TargetSelection,
|
||||
@ -2477,7 +2481,7 @@ fn prepare_cargo_test(
|
||||
DocTests::No => {
|
||||
let krate = &builder
|
||||
.crates
|
||||
.get(&INTERNER.intern_str(primary_crate))
|
||||
.get(primary_crate)
|
||||
.unwrap_or_else(|| panic!("missing crate {primary_crate}"));
|
||||
if krate.has_lib {
|
||||
cargo.arg("--lib");
|
||||
@ -2487,7 +2491,7 @@ fn prepare_cargo_test(
|
||||
DocTests::Yes => {}
|
||||
}
|
||||
|
||||
for &krate in crates {
|
||||
for krate in crates {
|
||||
cargo.arg("-p").arg(krate);
|
||||
}
|
||||
|
||||
@ -2529,7 +2533,7 @@ pub struct Crate {
|
||||
pub compiler: Compiler,
|
||||
pub target: TargetSelection,
|
||||
pub mode: Mode,
|
||||
pub crates: Vec<Interned<String>>,
|
||||
pub crates: Vec<String>,
|
||||
}
|
||||
|
||||
impl Step for Crate {
|
||||
@ -2544,8 +2548,11 @@ impl Step for Crate {
|
||||
let builder = run.builder;
|
||||
let host = run.build_triple();
|
||||
let compiler = builder.compiler_for(builder.top_stage, host, host);
|
||||
let crates =
|
||||
run.paths.iter().map(|p| builder.crate_paths[&p.assert_single_path().path]).collect();
|
||||
let crates = run
|
||||
.paths
|
||||
.iter()
|
||||
.map(|p| builder.crate_paths[&p.assert_single_path().path].clone())
|
||||
.collect();
|
||||
|
||||
builder.ensure(Crate { compiler, target: run.target, mode: Mode::Std, crates });
|
||||
}
|
||||
@ -2707,7 +2714,7 @@ impl Step for CrateRustdoc {
|
||||
run_cargo_test(
|
||||
cargo,
|
||||
&[],
|
||||
&[INTERNER.intern_str("rustdoc:0.0.0")],
|
||||
&["rustdoc:0.0.0".to_string()],
|
||||
"rustdoc",
|
||||
"rustdoc",
|
||||
compiler,
|
||||
@ -2768,7 +2775,7 @@ impl Step for CrateRustdocJsonTypes {
|
||||
run_cargo_test(
|
||||
cargo,
|
||||
libtest_args,
|
||||
&[INTERNER.intern_str("rustdoc-json-types")],
|
||||
&["rustdoc-json-types".to_string()],
|
||||
"rustdoc-json-types",
|
||||
"rustdoc-json-types",
|
||||
compiler,
|
||||
@ -3194,8 +3201,7 @@ impl Step for CodegenCranelift {
|
||||
return;
|
||||
}
|
||||
|
||||
if !builder.config.codegen_backends(run.target).contains(&INTERNER.intern_str("cranelift"))
|
||||
{
|
||||
if !builder.config.codegen_backends(run.target).contains(&"cranelift".to_owned()) {
|
||||
builder.info("cranelift not in rust.codegen-backends. skipping");
|
||||
return;
|
||||
}
|
||||
@ -3319,7 +3325,7 @@ impl Step for CodegenGCC {
|
||||
return;
|
||||
}
|
||||
|
||||
if !builder.config.codegen_backends(run.target).contains(&INTERNER.intern_str("gcc")) {
|
||||
if !builder.config.codegen_backends(run.target).contains(&"gcc".to_owned()) {
|
||||
builder.info("gcc not in rust.codegen-backends. skipping");
|
||||
return;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ use crate::core::build_steps::{check, clean, compile, dist, doc, install, run, s
|
||||
use crate::core::config::flags::{Color, Subcommand};
|
||||
use crate::core::config::{DryRun, SplitDebuginfo, TargetSelection};
|
||||
use crate::prepare_behaviour_dump_dir;
|
||||
use crate::utils::cache::{Cache, Interned, INTERNER};
|
||||
use crate::utils::cache::Cache;
|
||||
use crate::utils::helpers::{self, add_dylib_path, add_link_lib_path, exe, linker_args};
|
||||
use crate::utils::helpers::{check_cfg_arg, libdir, linker_flags, output, t, LldThreads};
|
||||
use crate::EXTRA_CHECK_CFGS;
|
||||
@ -102,7 +102,7 @@ impl RunConfig<'_> {
|
||||
|
||||
/// Return a list of crate names selected by `run.paths`.
|
||||
#[track_caller]
|
||||
pub fn cargo_crates_in_set(&self) -> Interned<Vec<String>> {
|
||||
pub fn cargo_crates_in_set(&self) -> Vec<String> {
|
||||
let mut crates = Vec::new();
|
||||
for krate in &self.paths {
|
||||
let path = krate.assert_single_path();
|
||||
@ -111,7 +111,7 @@ impl RunConfig<'_> {
|
||||
};
|
||||
crates.push(crate_name.to_string());
|
||||
}
|
||||
INTERNER.intern_list(crates)
|
||||
crates
|
||||
}
|
||||
|
||||
/// Given an `alias` selected by the `Step` and the paths passed on the command line,
|
||||
@ -120,7 +120,7 @@ impl RunConfig<'_> {
|
||||
/// Normally, people will pass *just* `library` if they pass it.
|
||||
/// But it's possible (although strange) to pass something like `library std core`.
|
||||
/// Build all crates anyway, as if they hadn't passed the other args.
|
||||
pub fn make_run_crates(&self, alias: Alias) -> Interned<Vec<String>> {
|
||||
pub fn make_run_crates(&self, alias: Alias) -> Vec<String> {
|
||||
let has_alias =
|
||||
self.paths.iter().any(|set| set.assert_single_path().path.ends_with(alias.as_str()));
|
||||
if !has_alias {
|
||||
@ -133,7 +133,7 @@ impl RunConfig<'_> {
|
||||
};
|
||||
|
||||
let crate_names = crates.into_iter().map(|krate| krate.name.to_string()).collect();
|
||||
INTERNER.intern_list(crate_names)
|
||||
crate_names
|
||||
}
|
||||
}
|
||||
|
||||
@ -1062,26 +1062,26 @@ impl<'a> Builder<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sysroot(&self, compiler: Compiler) -> Interned<PathBuf> {
|
||||
pub fn sysroot(&self, compiler: Compiler) -> PathBuf {
|
||||
self.ensure(compile::Sysroot::new(compiler))
|
||||
}
|
||||
|
||||
/// Returns the libdir where the standard library and other artifacts are
|
||||
/// found for a compiler's sysroot.
|
||||
pub fn sysroot_libdir(&self, compiler: Compiler, target: TargetSelection) -> Interned<PathBuf> {
|
||||
pub fn sysroot_libdir(&self, compiler: Compiler, target: TargetSelection) -> PathBuf {
|
||||
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
|
||||
struct Libdir {
|
||||
compiler: Compiler,
|
||||
target: TargetSelection,
|
||||
}
|
||||
impl Step for Libdir {
|
||||
type Output = Interned<PathBuf>;
|
||||
type Output = PathBuf;
|
||||
|
||||
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
||||
run.never()
|
||||
}
|
||||
|
||||
fn run(self, builder: &Builder<'_>) -> Interned<PathBuf> {
|
||||
fn run(self, builder: &Builder<'_>) -> PathBuf {
|
||||
let lib = builder.sysroot_libdir_relative(self.compiler);
|
||||
let sysroot = builder
|
||||
.sysroot(self.compiler)
|
||||
@ -1110,7 +1110,7 @@ impl<'a> Builder<'a> {
|
||||
);
|
||||
}
|
||||
|
||||
INTERNER.intern_path(sysroot)
|
||||
sysroot
|
||||
}
|
||||
}
|
||||
self.ensure(Libdir { compiler, target })
|
||||
|
@ -608,7 +608,7 @@ mod dist {
|
||||
compiler: Compiler { host, stage: 0 },
|
||||
target: host,
|
||||
mode: Mode::Std,
|
||||
crates: vec![INTERNER.intern_str("std")],
|
||||
crates: vec!["std".to_owned()],
|
||||
},]
|
||||
);
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ pub struct Config {
|
||||
pub rustc_default_linker: Option<String>,
|
||||
pub rust_optimize_tests: bool,
|
||||
pub rust_dist_src: bool,
|
||||
pub rust_codegen_backends: Vec<Interned<String>>,
|
||||
pub rust_codegen_backends: Vec<String>,
|
||||
pub rust_verify_llvm_ir: bool,
|
||||
pub rust_thin_lto_import_instr_limit: Option<u32>,
|
||||
pub rust_remap_debuginfo: bool,
|
||||
@ -458,6 +458,8 @@ impl std::str::FromStr for RustcLto {
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
// N.B.: This type is used everywhere, and the entire codebase relies on it being Copy.
|
||||
// Making !Copy is highly nontrivial!
|
||||
pub struct TargetSelection {
|
||||
pub triple: Interned<String>,
|
||||
file: Option<Interned<String>>,
|
||||
@ -580,7 +582,7 @@ pub struct Target {
|
||||
pub wasi_root: Option<PathBuf>,
|
||||
pub qemu_rootfs: Option<PathBuf>,
|
||||
pub no_std: bool,
|
||||
pub codegen_backends: Option<Vec<Interned<String>>>,
|
||||
pub codegen_backends: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
impl Target {
|
||||
@ -1163,7 +1165,7 @@ impl Config {
|
||||
channel: "dev".to_string(),
|
||||
codegen_tests: true,
|
||||
rust_dist_src: true,
|
||||
rust_codegen_backends: vec![INTERNER.intern_str("llvm")],
|
||||
rust_codegen_backends: vec!["llvm".to_owned()],
|
||||
deny_warnings: true,
|
||||
bindir: "bin".into(),
|
||||
dist_include_mingw_linker: true,
|
||||
@ -1693,7 +1695,7 @@ impl Config {
|
||||
}
|
||||
}
|
||||
|
||||
INTERNER.intern_str(s)
|
||||
s.clone()
|
||||
}).collect();
|
||||
}
|
||||
|
||||
@ -1880,7 +1882,7 @@ impl Config {
|
||||
}
|
||||
}
|
||||
|
||||
INTERNER.intern_str(s)
|
||||
s.clone()
|
||||
}).collect());
|
||||
}
|
||||
|
||||
@ -2267,7 +2269,7 @@ impl Config {
|
||||
}
|
||||
|
||||
pub fn llvm_enabled(&self, target: TargetSelection) -> bool {
|
||||
self.codegen_backends(target).contains(&INTERNER.intern_str("llvm"))
|
||||
self.codegen_backends(target).contains(&"llvm".to_owned())
|
||||
}
|
||||
|
||||
pub fn llvm_libunwind(&self, target: TargetSelection) -> LlvmLibunwind {
|
||||
@ -2286,14 +2288,14 @@ impl Config {
|
||||
self.submodules.unwrap_or(rust_info.is_managed_git_subrepository())
|
||||
}
|
||||
|
||||
pub fn codegen_backends(&self, target: TargetSelection) -> &[Interned<String>] {
|
||||
pub fn codegen_backends(&self, target: TargetSelection) -> &[String] {
|
||||
self.target_config
|
||||
.get(&target)
|
||||
.and_then(|cfg| cfg.codegen_backends.as_deref())
|
||||
.unwrap_or(&self.rust_codegen_backends)
|
||||
}
|
||||
|
||||
pub fn default_codegen_backend(&self, target: TargetSelection) -> Option<Interned<String>> {
|
||||
pub fn default_codegen_backend(&self, target: TargetSelection) -> Option<String> {
|
||||
self.codegen_backends(target).first().cloned()
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,6 @@ use std::process::Command;
|
||||
|
||||
use serde_derive::Deserialize;
|
||||
|
||||
use crate::utils::cache::INTERNER;
|
||||
use crate::utils::helpers::output;
|
||||
use crate::{t, Build, Crate};
|
||||
|
||||
@ -43,19 +42,19 @@ struct Target {
|
||||
pub fn build(build: &mut Build) {
|
||||
for package in workspace_members(build) {
|
||||
if package.source.is_none() {
|
||||
let name = INTERNER.intern_string(package.name);
|
||||
let name = package.name;
|
||||
let mut path = PathBuf::from(package.manifest_path);
|
||||
path.pop();
|
||||
let deps = package
|
||||
.dependencies
|
||||
.into_iter()
|
||||
.filter(|dep| dep.source.is_none())
|
||||
.map(|dep| INTERNER.intern_string(dep.name))
|
||||
.map(|dep| dep.name)
|
||||
.collect();
|
||||
let has_lib = package.targets.iter().any(|t| t.kind.iter().any(|k| k == "lib"));
|
||||
let krate = Crate { name, deps, path, has_lib };
|
||||
let krate = Crate { name: name.clone(), deps, path, has_lib };
|
||||
let relative_path = krate.local_path(build);
|
||||
build.crates.insert(name, krate);
|
||||
build.crates.insert(name.clone(), krate);
|
||||
let existing_path = build.crate_paths.insert(relative_path, name);
|
||||
assert!(
|
||||
existing_path.is_none(),
|
||||
|
@ -41,7 +41,6 @@ use crate::core::builder::Kind;
|
||||
use crate::core::config::{flags, LldMode};
|
||||
use crate::core::config::{DryRun, Target};
|
||||
use crate::core::config::{LlvmLibunwind, TargetSelection};
|
||||
use crate::utils::cache::{Interned, INTERNER};
|
||||
use crate::utils::exec::{BehaviorOnFailure, BootstrapCommand, OutputMode};
|
||||
use crate::utils::helpers::{self, dir_is_empty, exe, libdir, mtime, output, symlink_dir};
|
||||
|
||||
@ -191,8 +190,8 @@ pub struct Build {
|
||||
ranlib: RefCell<HashMap<TargetSelection, PathBuf>>,
|
||||
// Miscellaneous
|
||||
// allow bidirectional lookups: both name -> path and path -> name
|
||||
crates: HashMap<Interned<String>, Crate>,
|
||||
crate_paths: HashMap<PathBuf, Interned<String>>,
|
||||
crates: HashMap<String, Crate>,
|
||||
crate_paths: HashMap<PathBuf, String>,
|
||||
is_sudo: bool,
|
||||
ci_env: CiEnv,
|
||||
delayed_failures: RefCell<Vec<String>>,
|
||||
@ -204,8 +203,8 @@ pub struct Build {
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct Crate {
|
||||
name: Interned<String>,
|
||||
deps: HashSet<Interned<String>>,
|
||||
name: String,
|
||||
deps: HashSet<String>,
|
||||
path: PathBuf,
|
||||
has_lib: bool,
|
||||
}
|
||||
@ -829,8 +828,8 @@ impl Build {
|
||||
}
|
||||
|
||||
/// Output directory for some generated md crate documentation for a target (temporary)
|
||||
fn md_doc_out(&self, target: TargetSelection) -> Interned<PathBuf> {
|
||||
INTERNER.intern_path(self.out.join(&*target.triple).join("md-doc"))
|
||||
fn md_doc_out(&self, target: TargetSelection) -> PathBuf {
|
||||
self.out.join(&*target.triple).join("md-doc")
|
||||
}
|
||||
|
||||
/// Returns `true` if this is an external version of LLVM not managed by bootstrap.
|
||||
@ -1538,7 +1537,7 @@ impl Build {
|
||||
/// "local" crates (those in the local source tree, not from a registry).
|
||||
fn in_tree_crates(&self, root: &str, target: Option<TargetSelection>) -> Vec<&Crate> {
|
||||
let mut ret = Vec::new();
|
||||
let mut list = vec![INTERNER.intern_str(root)];
|
||||
let mut list = vec![root.to_owned()];
|
||||
let mut visited = HashSet::new();
|
||||
while let Some(krate) = list.pop() {
|
||||
let krate = self
|
||||
@ -1564,11 +1563,11 @@ impl Build {
|
||||
&& (dep != "rustc_codegen_llvm"
|
||||
|| self.config.hosts.iter().any(|host| self.config.llvm_enabled(*host)))
|
||||
{
|
||||
list.push(*dep);
|
||||
list.push(dep.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
ret.sort_unstable_by_key(|krate| krate.name); // reproducible order needed for tests
|
||||
ret.sort_unstable_by_key(|krate| krate.name.clone()); // reproducible order needed for tests
|
||||
ret
|
||||
}
|
||||
|
||||
|
@ -194,17 +194,6 @@ impl Interner {
|
||||
pub fn intern_str(&self, s: &str) -> Interned<String> {
|
||||
self.strs.lock().unwrap().intern_borrow(s)
|
||||
}
|
||||
pub fn intern_string(&self, s: String) -> Interned<String> {
|
||||
self.strs.lock().unwrap().intern(s)
|
||||
}
|
||||
|
||||
pub fn intern_path(&self, s: PathBuf) -> Interned<PathBuf> {
|
||||
self.paths.lock().unwrap().intern(s)
|
||||
}
|
||||
|
||||
pub fn intern_list(&self, v: Vec<String>) -> Interned<Vec<String>> {
|
||||
self.lists.lock().unwrap().intern(v)
|
||||
}
|
||||
}
|
||||
|
||||
pub static INTERNER: Lazy<Interner> = Lazy::new(Interner::default);
|
||||
|
Loading…
x
Reference in New Issue
Block a user