Skip to content

Commit

Permalink
Inline prepare_stdlib into the sysroot build code
Browse files Browse the repository at this point in the history
Also reduce visibility of a couple of statics
  • Loading branch information
bjorn3 committed Sep 12, 2024
1 parent ade0e38 commit 45be990
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
2 changes: 1 addition & 1 deletion build_system/build_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::rustc_info::get_file_name;
use crate::shared_utils::{rustflags_from_env, rustflags_to_cmd_env};
use crate::utils::{CargoProject, Compiler, LogGroup};

pub(crate) static CG_CLIF: CargoProject = CargoProject::new(&RelPath::SOURCE, "cg_clif");
static CG_CLIF: CargoProject = CargoProject::new(&RelPath::SOURCE, "cg_clif");

pub(crate) fn build_backend(
dirs: &Dirs,
Expand Down
14 changes: 9 additions & 5 deletions build_system/build_sysroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use std::process::Command;
use std::{env, fs};

use crate::path::{Dirs, RelPath};
use crate::rustc_info::get_file_name;
use crate::prepare::apply_patches;
use crate::rustc_info::{get_default_sysroot, get_file_name};
use crate::utils::{
remove_dir_if_exists, spawn_and_wait, try_hard_link, CargoProject, Compiler, LogGroup,
};
Expand Down Expand Up @@ -157,10 +158,10 @@ impl SysrootTarget {
}
}

pub(crate) static STDLIB_SRC: RelPath = RelPath::BUILD.join("stdlib");
pub(crate) static STANDARD_LIBRARY: CargoProject =
static STDLIB_SRC: RelPath = RelPath::BUILD.join("stdlib");
static STANDARD_LIBRARY: CargoProject =
CargoProject::new(&STDLIB_SRC.join("library/sysroot"), "stdlib_target");
pub(crate) static RTSTARTUP_SYSROOT: RelPath = RelPath::BUILD.join("rtstartup");
static RTSTARTUP_SYSROOT: RelPath = RelPath::BUILD.join("rtstartup");

fn build_sysroot_for_triple(
dirs: &Dirs,
Expand Down Expand Up @@ -285,7 +286,10 @@ fn build_clif_sysroot_for_triple(

fn build_rtstartup(dirs: &Dirs, compiler: &Compiler) -> Option<SysrootTarget> {
if !config::get_bool("keep_sysroot") {
crate::prepare::prepare_stdlib(dirs, &compiler.rustc);
let sysroot_src_orig = get_default_sysroot(&compiler.rustc).join("lib/rustlib/src/rust");
assert!(sysroot_src_orig.exists());

apply_patches(dirs, "stdlib", &sysroot_src_orig, &STDLIB_SRC.to_path(dirs));
}

if !compiler.triple.ends_with("windows-gnu") {
Expand Down
9 changes: 0 additions & 9 deletions build_system/prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ use std::hash::{Hash, Hasher};
use std::path::{Path, PathBuf};
use std::process::Command;

use crate::build_sysroot::STDLIB_SRC;
use crate::path::{Dirs, RelPath};
use crate::rustc_info::get_default_sysroot;
use crate::utils::{
copy_dir_recursively, remove_dir_if_exists, retry_spawn_and_wait, spawn_and_wait,
};
Expand All @@ -17,13 +15,6 @@ pub(crate) fn prepare(dirs: &Dirs) {
crate::tests::REGEX_REPO.fetch(dirs);
}

pub(crate) 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());

apply_patches(dirs, "stdlib", &sysroot_src_orig, &STDLIB_SRC.to_path(dirs));
}

pub(crate) struct GitRepo {
url: GitRepoUrl,
rev: &'static str,
Expand Down
9 changes: 4 additions & 5 deletions build_system/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub(crate) static RAND_REPO: GitRepo = GitRepo::github(
"rand",
);

pub(crate) static RAND: CargoProject = CargoProject::new(&RAND_REPO.source_dir(), "rand_target");
static RAND: CargoProject = CargoProject::new(&RAND_REPO.source_dir(), "rand_target");

pub(crate) static REGEX_REPO: GitRepo = GitRepo::github(
"rust-lang",
Expand All @@ -127,12 +127,11 @@ pub(crate) static REGEX_REPO: GitRepo = GitRepo::github(
"regex",
);

pub(crate) static REGEX: CargoProject = CargoProject::new(&REGEX_REPO.source_dir(), "regex_target");
static REGEX: CargoProject = CargoProject::new(&REGEX_REPO.source_dir(), "regex_target");

pub(crate) static PORTABLE_SIMD_SRC: RelPath = RelPath::BUILD.join("portable-simd");
static PORTABLE_SIMD_SRC: RelPath = RelPath::BUILD.join("portable-simd");

pub(crate) static PORTABLE_SIMD: CargoProject =
CargoProject::new(&PORTABLE_SIMD_SRC, "portable-simd_target");
static PORTABLE_SIMD: CargoProject = CargoProject::new(&PORTABLE_SIMD_SRC, "portable-simd_target");

static LIBCORE_TESTS_SRC: RelPath = RelPath::BUILD.join("coretests");

Expand Down

0 comments on commit 45be990

Please sign in to comment.