diff --git a/build_sysroot/Cargo.lock b/build_sysroot/Cargo.lock index 934665a0537..1dde9e54d7e 100644 --- a/build_sysroot/Cargo.lock +++ b/build_sysroot/Cargo.lock @@ -30,8 +30,26 @@ version = "0.0.0" dependencies = [ "compiler_builtins", "core", + "rand", + "rand_xorshift", ] +[[package]] +name = "auxv" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e50430f9beb8effb02399fa81c76eeaa26b05e4f03b09285cad8d079c1af5a3d" +dependencies = [ + "byteorder", + "gcc", +] + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + [[package]] name = "cc" version = "1.0.79" @@ -54,12 +72,27 @@ version = "0.1.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76630810d973ecea3dbf611e1b7aecfb1012751ef1ff8de3998f89014a166781" dependencies = [ + "cc", "rustc-std-workspace-core", ] [[package]] name = "core" version = "0.0.0" +dependencies = [ + "rand", + "rand_xorshift", +] + +[[package]] +name = "cupid" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bad352a84b567cc38a5854e3aa8ee903cb8519a25d0b799b739bafffd1f91a1" +dependencies = [ + "gcc", + "rustc_version", +] [[package]] name = "dlmalloc" @@ -82,6 +115,12 @@ dependencies = [ "rustc-std-workspace-core", ] +[[package]] +name = "gcc" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" + [[package]] name = "getopts" version = "0.2.21" @@ -200,6 +239,39 @@ dependencies = [ "std", ] +[[package]] +name = "profiler_builtins" +version = "0.0.0" +dependencies = [ + "cc", + "compiler_builtins", + "core", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" + +[[package]] +name = "rand_xorshift" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" +dependencies = [ + "rand_core", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -231,6 +303,30 @@ dependencies = [ "std", ] +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver", +] + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + [[package]] name = "std" version = "0.0.0" @@ -249,6 +345,9 @@ dependencies = [ "object", "panic_abort", "panic_unwind", + "profiler_builtins", + "rand", + "rand_xorshift", "rustc-demangle", "std_detect", "unwind", @@ -259,8 +358,11 @@ dependencies = [ name = "std_detect" version = "0.1.5" dependencies = [ + "auxv", "cfg-if", "compiler_builtins", + "cupid", + "libc", "rustc-std-workspace-alloc", "rustc-std-workspace-core", ] @@ -269,8 +371,6 @@ dependencies = [ name = "sysroot" version = "0.0.0" dependencies = [ - "alloc", - "core", "proc_macro", "std", "test", diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml index 194a5f27275..3e5d0c159f2 100644 --- a/build_sysroot/Cargo.toml +++ b/build_sysroot/Cargo.toml @@ -1,18 +1,10 @@ -[package] -name = "sysroot" -version = "0.0.0" - -[dependencies] -core = { path = "./sysroot_src/library/core" } -alloc = { path = "./sysroot_src/library/alloc" } -std = { path = "./sysroot_src/library/std", features = ["panic_unwind", "backtrace"] } -test = { path = "./sysroot_src/library/test" } -proc_macro = { path = "./sysroot_src/library/proc_macro" } +[workspace] +members = ["./library/sysroot"] [patch.crates-io] -rustc-std-workspace-core = { path = "./sysroot_src/library/rustc-std-workspace-core" } -rustc-std-workspace-alloc = { path = "./sysroot_src/library/rustc-std-workspace-alloc" } -rustc-std-workspace-std = { path = "./sysroot_src/library/rustc-std-workspace-std" } +rustc-std-workspace-core = { path = "./library/rustc-std-workspace-core" } +rustc-std-workspace-alloc = { path = "./library/rustc-std-workspace-alloc" } +rustc-std-workspace-std = { path = "./library/rustc-std-workspace-std" } [profile.dev] lto = "off" diff --git a/build_sysroot/src/lib.rs b/build_sysroot/src/lib.rs deleted file mode 100644 index 8b137891791..00000000000 --- a/build_sysroot/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/build_system/build_sysroot.rs b/build_system/build_sysroot.rs index 5c1e30d4eef..09dc43b8136 100644 --- a/build_system/build_sysroot.rs +++ b/build_system/build_sysroot.rs @@ -156,11 +156,10 @@ fn install_into_sysroot(&self, sysroot: &Path) { } pub(crate) static ORIG_BUILD_SYSROOT: RelPath = RelPath::SOURCE.join("build_sysroot"); -pub(crate) static BUILD_SYSROOT: RelPath = RelPath::BUILD.join("sysroot"); -pub(crate) static SYSROOT_RUSTC_VERSION: RelPath = BUILD_SYSROOT.join("rustc_version"); -pub(crate) static SYSROOT_SRC: RelPath = BUILD_SYSROOT.join("sysroot_src"); +pub(crate) static STDLIB_SRC: RelPath = RelPath::BUILD.join("stdlib"); +pub(crate) static SYSROOT_RUSTC_VERSION: RelPath = STDLIB_SRC.join("rustc_version"); pub(crate) static STANDARD_LIBRARY: CargoProject = - CargoProject::new(&BUILD_SYSROOT, "build_sysroot"); + CargoProject::new(&STDLIB_SRC.join("library/sysroot"), "stdlib_target"); pub(crate) static RTSTARTUP_SYSROOT: RelPath = RelPath::BUILD.join("rtstartup"); #[must_use] @@ -277,7 +276,7 @@ fn build_clif_sysroot_for_triple( if channel == "release" { build_cmd.arg("--release"); } - build_cmd.arg("--features").arg("std/compiler-builtins-no-asm"); + build_cmd.arg("--features").arg("compiler-builtins-no-asm backtrace panic-unwind"); build_cmd.arg("--locked"); build_cmd.env("__CARGO_DEFAULT_LIB_METADATA", "cg_clif"); if compiler.triple.contains("apple") { @@ -307,7 +306,7 @@ fn build_rtstartup(dirs: &Dirs, compiler: &Compiler) -> Option { RTSTARTUP_SYSROOT.ensure_fresh(dirs); - let rtstartup_src = SYSROOT_SRC.to_path(dirs).join("library").join("rtstartup"); + let rtstartup_src = STDLIB_SRC.to_path(dirs).join("library").join("rtstartup"); let mut target_libs = SysrootTarget { triple: compiler.triple.clone(), libs: vec![] }; for file in ["rsbegin", "rsend"] { diff --git a/build_system/prepare.rs b/build_system/prepare.rs index 8cf51db1770..bc249f4cdab 100644 --- a/build_system/prepare.rs +++ b/build_system/prepare.rs @@ -3,7 +3,7 @@ use std::path::{Path, PathBuf}; use std::process::Command; -use super::build_sysroot::{BUILD_SYSROOT, ORIG_BUILD_SYSROOT, SYSROOT_RUSTC_VERSION, SYSROOT_SRC}; +use super::build_sysroot::{ORIG_BUILD_SYSROOT, STDLIB_SRC, SYSROOT_RUSTC_VERSION}; use super::path::{Dirs, RelPath}; use super::rustc_info::{get_default_sysroot, get_rustc_version}; use super::utils::{ @@ -28,15 +28,10 @@ fn prepare_stdlib(dirs: &Dirs, rustc: &Path) { let sysroot_src_orig = get_default_sysroot(rustc).join("lib/rustlib/src/rust"); assert!(sysroot_src_orig.exists()); - eprintln!("[COPY] stdlib src"); + apply_patches(dirs, "stdlib", &sysroot_src_orig, &STDLIB_SRC.to_path(dirs)); // FIXME ensure builds error out or update the copy if any of the files copied here change - BUILD_SYSROOT.ensure_fresh(dirs); - copy_dir_recursively(&ORIG_BUILD_SYSROOT.to_path(dirs), &BUILD_SYSROOT.to_path(dirs)); - - fs::create_dir_all(SYSROOT_SRC.to_path(dirs).join("library")).unwrap(); - - apply_patches(dirs, "stdlib", &sysroot_src_orig, &SYSROOT_SRC.to_path(dirs)); + copy_dir_recursively(&ORIG_BUILD_SYSROOT.to_path(dirs), &STDLIB_SRC.to_path(dirs)); let rustc_version = get_rustc_version(rustc); fs::write(SYSROOT_RUSTC_VERSION.to_path(dirs), &rustc_version).unwrap(); @@ -251,6 +246,8 @@ fn get_patches(dirs: &Dirs, crate_name: &str) -> Vec { pub(crate) fn apply_patches(dirs: &Dirs, crate_name: &str, source_dir: &Path, target_dir: &Path) { // FIXME avoid copy and patch if src, patches and target are unchanged + eprintln!("[COPY] {crate_name} source"); + remove_dir_if_exists(target_dir); fs::create_dir_all(target_dir).unwrap(); copy_dir_recursively(source_dir, target_dir);