diff --git a/src/bootstrap/src/core/build_steps/check.rs b/src/bootstrap/src/core/build_steps/check.rs index f6f4253a36435..a90139a070ac2 100644 --- a/src/bootstrap/src/core/build_steps/check.rs +++ b/src/bootstrap/src/core/build_steps/check.rs @@ -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>, + crates: Vec, } /// 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>, + crates: Vec, } 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, + 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, + backend: &str, ) -> PathBuf { builder .cargo_out(compiler, Mode::Codegen, target) diff --git a/src/bootstrap/src/core/build_steps/clean.rs b/src/bootstrap/src/core/build_steps/clean.rs index 17ca92f25a928..9e103a350e654 100644 --- a/src/bootstrap/src/core/build_steps/clean.rs +++ b/src/bootstrap/src/core/build_steps/clean.rs @@ -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>, + crates: Vec, } impl Step for $name { diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 4bf50e19c3fd0..6a2bff5970f36 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -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>, + crates: Vec, /// 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>, + crates: Vec, /// 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>, + crates: Vec, } 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>, + crates: Vec, } 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, + 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, + backend: &str, ) -> PathBuf { builder .cargo_out(compiler, Mode::Codegen, target) @@ -1508,7 +1507,7 @@ impl Sysroot { } impl Step for Sysroot { - type Output = Interned; + 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 { + 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(), }); } diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 1090edc9c927e..613c58252d3bd 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -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, + 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, + 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"); diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index c4235755ba865..c23cd9374a6ba 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -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 { target: TargetSelection, - name: Interned, - src: Interned, + name: String, + src: PathBuf, parent: Option

, } @@ -141,7 +140,7 @@ impl Step for RustbookSrc

{ 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::::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>, + crates: Vec, } 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>, + crates: Vec, } 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), }); } diff --git a/src/bootstrap/src/core/build_steps/install.rs b/src/bootstrap/src/core/build_steps/install.rs index 6726671ddd9b3..41920fabaa974 100644 --- a/src/bootstrap/src/core/build_steps/install.rs +++ b/src/bootstrap/src/core/build_steps/install.rs @@ -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 { diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index c8b659903ebbb..58bc379136978 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -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, + 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>, + crates: Vec, } 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, libtest_args: &[&str], - crates: &[Interned], + crates: &[String], primary_crate: &str, description: impl Into>, compiler: Compiler, @@ -2449,7 +2453,7 @@ fn run_cargo_test<'a>( fn prepare_cargo_test( cargo: impl Into, libtest_args: &[&str], - crates: &[Interned], + 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>, + pub crates: Vec, } 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; } diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs index 8223a80c93107..4927c83760808 100644 --- a/src/bootstrap/src/core/builder.rs +++ b/src/bootstrap/src/core/builder.rs @@ -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> { + pub fn cargo_crates_in_set(&self) -> Vec { 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> { + pub fn make_run_crates(&self, alias: Alias) -> Vec { 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 { + 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 { + 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; + type Output = PathBuf; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.never() } - fn run(self, builder: &Builder<'_>) -> Interned { + 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 }) diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs index 2cbebbcf4e2af..6a1dde51603be 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -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()], },] ); } diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 47b13c26711b6..4766f9d426c30 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -264,7 +264,7 @@ pub struct Config { pub rustc_default_linker: Option, pub rust_optimize_tests: bool, pub rust_dist_src: bool, - pub rust_codegen_backends: Vec>, + pub rust_codegen_backends: Vec, pub rust_verify_llvm_ir: bool, pub rust_thin_lto_import_instr_limit: Option, 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, file: Option>, @@ -580,7 +582,7 @@ pub struct Target { pub wasi_root: Option, pub qemu_rootfs: Option, pub no_std: bool, - pub codegen_backends: Option>>, + pub codegen_backends: Option>, } 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] { + 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> { + pub fn default_codegen_backend(&self, target: TargetSelection) -> Option { self.codegen_backends(target).first().cloned() } diff --git a/src/bootstrap/src/core/metadata.rs b/src/bootstrap/src/core/metadata.rs index 5802082326a88..08a96407a6917 100644 --- a/src/bootstrap/src/core/metadata.rs +++ b/src/bootstrap/src/core/metadata.rs @@ -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(), diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index ab8f3c0d9e497..a252aaac97d74 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -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>, // Miscellaneous // allow bidirectional lookups: both name -> path and path -> name - crates: HashMap, Crate>, - crate_paths: HashMap>, + crates: HashMap, + crate_paths: HashMap, is_sudo: bool, ci_env: CiEnv, delayed_failures: RefCell>, @@ -204,8 +203,8 @@ pub struct Build { #[derive(Debug, Clone)] struct Crate { - name: Interned, - deps: HashSet>, + name: String, + deps: HashSet, 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 { - 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) -> 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 } diff --git a/src/bootstrap/src/utils/cache.rs b/src/bootstrap/src/utils/cache.rs index 2b86585a9d3c0..e18dcbb47bea0 100644 --- a/src/bootstrap/src/utils/cache.rs +++ b/src/bootstrap/src/utils/cache.rs @@ -194,17 +194,6 @@ impl Interner { pub fn intern_str(&self, s: &str) -> Interned { self.strs.lock().unwrap().intern_borrow(s) } - pub fn intern_string(&self, s: String) -> Interned { - self.strs.lock().unwrap().intern(s) - } - - pub fn intern_path(&self, s: PathBuf) -> Interned { - self.paths.lock().unwrap().intern(s) - } - - pub fn intern_list(&self, v: Vec) -> Interned> { - self.lists.lock().unwrap().intern(v) - } } pub static INTERNER: Lazy = Lazy::new(Interner::default);