diff options
author | bjorn3 <bjorn3@users.noreply.github.com> | 2021-02-02 19:45:17 +0100 |
---|---|---|
committer | Erin Power <erin.power@embark-studios.com> | 2021-04-30 15:37:42 +0200 |
commit | 35fd1a6c05e70507987a4b0abac46473a5b4e1e4 (patch) | |
tree | 633f97d845f310b73f01e9be5ea9cdac36c341a3 | |
parent | 9d07b92990401da49e99aebd815ccd0bd343a0da (diff) | |
download | rust-35fd1a6c05e70507987a4b0abac46473a5b4e1e4.tar.gz |
[WIP] Distribute cg_clif as a rustup component
-rw-r--r-- | src/bootstrap/dist.rs | 89 | ||||
-rw-r--r-- | src/bootstrap/lib.rs | 4 | ||||
-rw-r--r-- | src/bootstrap/tarball.rs | 9 | ||||
-rw-r--r-- | src/tools/build-manifest/src/main.rs | 6 | ||||
-rw-r--r-- | src/tools/build-manifest/src/versions.rs | 5 |
5 files changed, 99 insertions, 14 deletions
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index aee3c8324bc..cb591f29a42 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -374,19 +374,6 @@ impl Step for Rustc { } } - // Copy over the codegen backends - let backends_src = builder.sysroot_codegen_backends(compiler); - let backends_rel = backends_src - .strip_prefix(&src) - .unwrap() - .strip_prefix(builder.sysroot_libdir_relative(compiler)) - .unwrap(); - // Don't use custom libdir here because ^lib/ will be resolved again with installer - let backends_dst = image.join("lib").join(&backends_rel); - - t!(fs::create_dir_all(&backends_dst)); - builder.cp_r(&backends_src, &backends_dst); - // Copy libLLVM.so to the lib dir as well, if needed. While not // technically needed by rustc itself it's needed by lots of other // components like the llvm tools and LLD. LLD is included below and @@ -1195,6 +1182,80 @@ impl Step for Miri { } #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +pub struct CodegenBackend { + pub compiler: Compiler, + pub target: TargetSelection, + pub backend: Interned<String>, +} + +impl Step for CodegenBackend { + type Output = GeneratedTarball; + const ONLY_HOSTS: bool = true; + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.path("compiler/rustc_codegen_cranelift") + } + + fn make_run(run: RunConfig<'_>) { + for &backend in &run.builder.config.rust_codegen_backends { + if backend == "llvm" { + continue; // Already built as part of rustc + } + + run.builder.ensure(CodegenBackend { + compiler: run.builder.compiler_for( + run.builder.top_stage, + run.builder.config.build, + run.target, + ), + target: run.target, + backend, + }); + } + } + + fn run(self, builder: &Builder<'_>) -> GeneratedTarball { + let compiler = self.compiler; + let target = self.target; + let backend = self.backend; + assert!(builder.config.extended); + + builder.ensure(compile::CodegenBackend { compiler, target, backend }); + + let mut tarball = Tarball::new(builder, &format!("rustc-codegen-{}", backend), &target.triple); + if backend == "cranelift" { + tarball.set_overlay(OverlayKind::RustcCodegenCranelift); + } else { + panic!("Unknown overlay kind for rustc_codegen_{}", backend); + } + tarball.is_preview(true); + tarball.add_legal_and_readme_to(format!("share/doc/rustc_codegen_{}", backend)); + + + let src = builder.sysroot(compiler); + let backends_src = builder.sysroot_codegen_backends(compiler); + let backends_rel = backends_src + .strip_prefix(&src) + .unwrap() + .strip_prefix(builder.sysroot_libdir_relative(compiler)) + .unwrap(); + // Don't use custom libdir here because ^lib/ will be resolved again with installer + let backends_dst = tarball.image_dir().join("lib").join(&backends_rel); + + t!(fs::create_dir_all(&backends_dst)); + let backend_name = format!("rustc_codegen_{}", backend); + for backend in fs::read_dir(&backends_src).unwrap() { + let file_name = backend.unwrap().file_name(); + if file_name.to_str().unwrap().contains(&backend_name) { + tarball.add_file(backends_src.join(file_name), backends_rel, 0o644); + } + } + + tarball.generate() + } +} + +#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] pub struct Rustfmt { pub compiler: Compiler, pub target: TargetSelection, @@ -1523,6 +1584,8 @@ impl Step for Extended { "rust-demangler-preview".to_string() } else if name == "miri" { "miri-preview".to_string() + } else if name == "rustc-codegen-cranelift" { + "rustc-codegen-cranelift-preview".to_string() } else { name.to_string() }; diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 24da44b933a..1261fc2a69b 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -240,6 +240,7 @@ pub struct Build { clippy_info: channel::GitInfo, miri_info: channel::GitInfo, rustfmt_info: channel::GitInfo, + rustc_codegen_cranelift_info: channel::GitInfo, in_tree_llvm_info: channel::GitInfo, local_rebuild: bool, fail_fast: bool, @@ -367,6 +368,8 @@ impl Build { let clippy_info = channel::GitInfo::new(ignore_git, &src.join("src/tools/clippy")); let miri_info = channel::GitInfo::new(ignore_git, &src.join("src/tools/miri")); let rustfmt_info = channel::GitInfo::new(ignore_git, &src.join("src/tools/rustfmt")); + let rustc_codegen_cranelift_info = + channel::GitInfo::new(ignore_git, &src.join("compiler/rustc_codegen_cranelift")); // we always try to use git for LLVM builds let in_tree_llvm_info = channel::GitInfo::new(false, &src.join("src/llvm-project")); @@ -429,6 +432,7 @@ impl Build { clippy_info, miri_info, rustfmt_info, + rustc_codegen_cranelift_info, in_tree_llvm_info, cc: HashMap::new(), cxx: HashMap::new(), diff --git a/src/bootstrap/tarball.rs b/src/bootstrap/tarball.rs index 9ff5c2327e0..583126138d3 100644 --- a/src/bootstrap/tarball.rs +++ b/src/bootstrap/tarball.rs @@ -18,6 +18,7 @@ pub(crate) enum OverlayKind { RustDemangler, RLS, RustAnalyzer, + RustcCodegenCranelift, } impl OverlayKind { @@ -61,6 +62,11 @@ impl OverlayKind { "src/tools/rust-analyzer/LICENSE-APACHE", "src/tools/rust-analyzer/LICENSE-MIT", ], + OverlayKind::RustcCodegenCranelift => &[ + "compiler/rustc_codegen_cranelift/Readme.md", + "compiler/rustc_codegen_cranelift/LICENSE-APACHE", + "compiler/rustc_codegen_cranelift/LICENSE-MIT", + ] } } @@ -83,6 +89,9 @@ impl OverlayKind { OverlayKind::RustAnalyzer => builder .rust_analyzer_info .version(builder, &builder.release_num("rust-analyzer/crates/rust-analyzer")), + OverlayKind::RustcCodegenCranelift => builder + .rustc_codegen_cranelift_info + .version(builder, &builder.release_num("rustc_codegen_cranelift")), } } } diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 4e605caafe2..cd98a21256d 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -176,7 +176,8 @@ static PKG_INSTALLERS: &[&str] = &["x86_64-apple-darwin", "aarch64-apple-darwin" static MINGW: &[&str] = &["i686-pc-windows-gnu", "x86_64-pc-windows-gnu"]; -static NIGHTLY_ONLY_COMPONENTS: &[&str] = &["miri-preview", "rust-analyzer-preview"]; +static NIGHTLY_ONLY_COMPONENTS: &[&str] = + &["miri-preview", "rust-analyzer-preview", "rustc-codegen-cranelift-preview"]; macro_rules! t { ($e:expr) => { @@ -312,6 +313,7 @@ impl Builder { package("clippy-preview", HOSTS); package("miri-preview", HOSTS); package("rustfmt-preview", HOSTS); + package("rustc-codegen-cranelift-preview", HOSTS); package("rust-analysis", TARGETS); package("llvm-tools-preview", TARGETS); } @@ -388,6 +390,7 @@ impl Builder { rename("rustfmt", "rustfmt-preview"); rename("clippy", "clippy-preview"); rename("miri", "miri-preview"); + rename("rustc-codegen-cranelift", "rustc-codegen-cranelift-preview"); } fn rust_package(&mut self, manifest: &Manifest) -> Package { @@ -443,6 +446,7 @@ impl Builder { host_component("rustfmt-preview"), host_component("llvm-tools-preview"), host_component("rust-analysis"), + host_component("rustc-codegen-cranelift-preview"), ]); extensions.extend( diff --git a/src/tools/build-manifest/src/versions.rs b/src/tools/build-manifest/src/versions.rs index 11575139adc..14ada99604f 100644 --- a/src/tools/build-manifest/src/versions.rs +++ b/src/tools/build-manifest/src/versions.rs @@ -20,6 +20,7 @@ pub(crate) enum PkgType { Rustfmt, LlvmTools, Miri, + RustcCodegenCranelift, Other(String), } @@ -36,6 +37,8 @@ impl PkgType { "rustfmt" | "rustfmt-preview" => PkgType::Rustfmt, "llvm-tools" | "llvm-tools-preview" => PkgType::LlvmTools, "miri" | "miri-preview" => PkgType::Miri, + "rustc-codegen-cranelift" + | "rustc-codegen-cranelift-preview" => PkgType::RustcCodegenCranelift, other => PkgType::Other(other.into()), } } @@ -53,6 +56,7 @@ impl PkgType { PkgType::Rustfmt => "rustfmt", PkgType::LlvmTools => "llvm-tools", PkgType::Miri => "miri", + PkgType::RustcCodegenCranelift => "rustc-codegen-cranelift", PkgType::Other(component) => component, } } @@ -68,6 +72,7 @@ impl PkgType { PkgType::Rustfmt => false, PkgType::LlvmTools => false, PkgType::Miri => false, + PkgType::RustcCodegenCranelift => false, PkgType::Rust => true, PkgType::RustSrc => true, |