diff --git a/.gitignore b/.gitignore index b443fd58a1b..8012e93f6a9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -target +/target **/*.rs.bk *.rlib *.o @@ -11,9 +11,6 @@ perf.data.old /y.exe /y.pdb /build -/build_sysroot/sysroot_src -/build_sysroot/compiler-builtins -/build_sysroot/rustc_version /dist /rust /download diff --git a/build_system/build_sysroot.rs b/build_system/build_sysroot.rs index cbbf09b9b97..711d4ccc55b 100644 --- a/build_system/build_sysroot.rs +++ b/build_system/build_sysroot.rs @@ -146,10 +146,11 @@ pub(crate) fn build_sysroot( } } -// FIXME move to download/ or dist/ -pub(crate) static SYSROOT_RUSTC_VERSION: RelPath = RelPath::BUILD_SYSROOT.join("rustc_version"); -pub(crate) static SYSROOT_SRC: RelPath = RelPath::BUILD_SYSROOT.join("sysroot_src"); -static STANDARD_LIBRARY: CargoProject = CargoProject::new(&RelPath::BUILD_SYSROOT, "build_sysroot"); +pub(crate) static ORIG_BUILD_SYSROOT: RelPath = RelPath::SOURCE.join("build_sysroot"); +pub(crate) static BUILD_SYSROOT: RelPath = RelPath::DOWNLOAD.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"); +static STANDARD_LIBRARY: CargoProject = CargoProject::new(&BUILD_SYSROOT, "build_sysroot"); fn build_clif_sysroot_for_triple( dirs: &Dirs, diff --git a/build_system/path.rs b/build_system/path.rs index e93981f1d64..35ab6f111fe 100644 --- a/build_system/path.rs +++ b/build_system/path.rs @@ -42,7 +42,6 @@ impl RelPath { pub(crate) const DIST: RelPath = RelPath::Base(PathBase::Dist); pub(crate) const SCRIPTS: RelPath = RelPath::SOURCE.join("scripts"); - pub(crate) const BUILD_SYSROOT: RelPath = RelPath::SOURCE.join("build_sysroot"); pub(crate) const PATCHES: RelPath = RelPath::SOURCE.join("patches"); pub(crate) const fn join(&'static self, suffix: &'static str) -> RelPath { diff --git a/build_system/prepare.rs b/build_system/prepare.rs index 8ac67e8f942..f9ef29849eb 100644 --- a/build_system/prepare.rs +++ b/build_system/prepare.rs @@ -3,9 +3,11 @@ use std::path::{Path, PathBuf}; use std::process::Command; -use super::build_sysroot::{SYSROOT_RUSTC_VERSION, SYSROOT_SRC}; +use crate::build_system::rustc_info::get_default_sysroot; + +use super::build_sysroot::{BUILD_SYSROOT, ORIG_BUILD_SYSROOT, SYSROOT_RUSTC_VERSION, SYSROOT_SRC}; use super::path::{Dirs, RelPath}; -use super::rustc_info::{get_file_name, get_rustc_path, get_rustc_version}; +use super::rustc_info::{get_file_name, get_rustc_version}; use super::utils::{copy_dir_recursively, spawn_and_wait, Compiler}; pub(crate) fn prepare(dirs: &Dirs) { @@ -49,27 +51,27 @@ pub(crate) fn prepare(dirs: &Dirs) { } fn prepare_sysroot(dirs: &Dirs) { - let rustc_path = get_rustc_path(); - let sysroot_src_orig = rustc_path.parent().unwrap().join("../lib/rustlib/src/rust"); - let sysroot_src = SYSROOT_SRC; - + let sysroot_src_orig = get_default_sysroot().join("lib/rustlib/src/rust"); assert!(sysroot_src_orig.exists()); - sysroot_src.ensure_fresh(dirs); - fs::create_dir_all(sysroot_src.to_path(dirs).join("library")).unwrap(); eprintln!("[COPY] sysroot src"); + + 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(); copy_dir_recursively( &sysroot_src_orig.join("library"), - &sysroot_src.to_path(dirs).join("library"), + &SYSROOT_SRC.to_path(dirs).join("library"), ); let rustc_version = get_rustc_version(); fs::write(SYSROOT_RUSTC_VERSION.to_path(dirs), &rustc_version).unwrap(); eprintln!("[GIT] init"); - init_git_repo(&sysroot_src.to_path(dirs)); + init_git_repo(&SYSROOT_SRC.to_path(dirs)); - apply_patches(dirs, "sysroot", &sysroot_src.to_path(dirs)); + apply_patches(dirs, "sysroot", &SYSROOT_SRC.to_path(dirs)); } pub(crate) struct GitRepo { diff --git a/build_system/tests.rs b/build_system/tests.rs index 37c35106af6..bc112910ce6 100644 --- a/build_system/tests.rs +++ b/build_system/tests.rs @@ -1,3 +1,5 @@ +use crate::build_system::build_sysroot::SYSROOT_SRC; + use super::build_sysroot; use super::config; use super::path::{Dirs, RelPath}; @@ -262,7 +264,7 @@ const fn new(config: &'static str, func: &'static dyn Fn(&TestRunner)) -> Self { CargoProject::new(&SIMPLE_RAYTRACER_REPO.source_dir(), "simple_raytracer"); static LIBCORE_TESTS: CargoProject = - CargoProject::new(&RelPath::BUILD_SYSROOT.join("sysroot_src/library/core/tests"), "core_tests"); + CargoProject::new(&SYSROOT_SRC.join("library/core/tests"), "core_tests"); const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[ TestCase::new("test.rust-random/rand", &|runner| { diff --git a/clean_all.sh b/clean_all.sh index 1760e5836ec..34cb081e375 100755 --- a/clean_all.sh +++ b/clean_all.sh @@ -1,10 +1,9 @@ #!/usr/bin/env bash set -e -rm -rf build_sysroot/{sysroot_src/,target/,compiler-builtins/,rustc_version} -rm -rf target/ build/ dist/ perf.data{,.old} y.bin -rm -rf download/ +rm -rf target/ download/ build/ dist/ y.bin y.exe # Kept for now in case someone updates their checkout of cg_clif before running clean_all.sh # FIXME remove at some point in the future rm -rf rand/ regex/ simple-raytracer/ portable-simd/ abi-checker/ abi-cafe/ +rm -rf build_sysroot/{sysroot_src/,target/,compiler-builtins/,rustc_version} diff --git a/scripts/rustup.sh b/scripts/rustup.sh index bc4c06ed7d2..6111c205444 100755 --- a/scripts/rustup.sh +++ b/scripts/rustup.sh @@ -17,10 +17,10 @@ case $1 in done ./clean_all.sh - ./y.rs prepare (cd build_sysroot && cargo update) + ./y.rs prepare ;; "commit") git add rust-toolchain build_sysroot/Cargo.lock diff --git a/scripts/setup_rust_fork.sh b/scripts/setup_rust_fork.sh index 6c64b7de7da..88bc6445503 100644 --- a/scripts/setup_rust_fork.sh +++ b/scripts/setup_rust_fork.sh @@ -51,7 +51,7 @@ popd # FIXME remove once inline asm is fully supported export RUSTFLAGS="$RUSTFLAGS --cfg=rustix_use_libc" -export CFG_VIRTUAL_RUST_SOURCE_BASE_DIR="$(cd build_sysroot/sysroot_src; pwd)" +export CFG_VIRTUAL_RUST_SOURCE_BASE_DIR="$(cd download/sysroot/sysroot_src; pwd)" # Allow the testsuite to use llvm tools host_triple=$(rustc -vV | grep host | cut -d: -f2 | tr -d " ")