Move build_sysroot
folder into build_system
This commit is contained in:
parent
ab1ea400a8
commit
cde105a651
12 changed files with 73 additions and 37 deletions
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
|
@ -62,12 +62,12 @@ jobs:
|
||||||
git config --global user.email "user@example.com"
|
git config --global user.email "user@example.com"
|
||||||
git config --global user.name "User"
|
git config --global user.name "User"
|
||||||
./y.sh prepare
|
./y.sh prepare
|
||||||
# FIXME(antoyo): we cannot enable LTO for stdarch tests currently because of some failing LTO tests using proc-macros.
|
|
||||||
echo -n 'lto = "fat"' >> build_sysroot/Cargo.toml
|
|
||||||
|
|
||||||
- name: Add more failing tests because of undefined symbol errors (FIXME)
|
- name: Add more failing tests because of undefined symbol errors (FIXME)
|
||||||
run: cat tests/failing-lto-tests.txt >> tests/failing-ui-tests.txt
|
run: cat tests/failing-lto-tests.txt >> tests/failing-ui-tests.txt
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: |
|
run: |
|
||||||
|
# FIXME(antoyo): we cannot enable LTO for stdarch tests currently because of some failing LTO tests using proc-macros.
|
||||||
|
echo -n 'lto = "fat"' >> build_system/build_sysroot/Cargo.toml
|
||||||
EMBED_LTO_BITCODE=1 ./y.sh test --release --clean --release-sysroot --build-sysroot ${{ matrix.commands }}
|
EMBED_LTO_BITCODE=1 ./y.sh test --release --clean --release-sysroot --build-sysroot ${{ matrix.commands }}
|
||||||
|
|
8
.github/workflows/stdarch.yml
vendored
8
.github/workflows/stdarch.yml
vendored
|
@ -89,12 +89,12 @@ jobs:
|
||||||
- name: Run stdarch tests
|
- name: Run stdarch tests
|
||||||
if: ${{ !matrix.cargo_runner }}
|
if: ${{ !matrix.cargo_runner }}
|
||||||
run: |
|
run: |
|
||||||
cd build_sysroot/sysroot_src/library/stdarch/
|
cd build/build_sysroot/sysroot_src/library/stdarch/
|
||||||
CHANNEL=release TARGET=x86_64-unknown-linux-gnu CG_RUSTFLAGS="-Ainternal_features" ../../../../y.sh cargo test
|
CHANNEL=release TARGET=x86_64-unknown-linux-gnu CG_RUSTFLAGS="-Ainternal_features" ../../../../../y.sh cargo test
|
||||||
|
|
||||||
- name: Run stdarch tests
|
- name: Run stdarch tests
|
||||||
if: ${{ matrix.cargo_runner }}
|
if: ${{ matrix.cargo_runner }}
|
||||||
run: |
|
run: |
|
||||||
cd build_sysroot/sysroot_src/library/stdarch/
|
cd build/build_sysroot/sysroot_src/library/stdarch/
|
||||||
# FIXME: these tests fail when the sysroot is compiled with LTO because of a missing symbol in proc-macro.
|
# FIXME: these tests fail when the sysroot is compiled with LTO because of a missing symbol in proc-macro.
|
||||||
STDARCH_TEST_EVERYTHING=1 CHANNEL=release CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="${{ matrix.cargo_runner }}" TARGET=x86_64-unknown-linux-gnu CG_RUSTFLAGS="-Ainternal_features" ../../../../y.sh cargo test -- --skip rtm --skip tbm --skip sse4a
|
STDARCH_TEST_EVERYTHING=1 CHANNEL=release CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="${{ matrix.cargo_runner }}" TARGET=x86_64-unknown-linux-gnu CG_RUSTFLAGS="-Ainternal_features" ../../../../../y.sh cargo test -- --skip rtm --skip tbm --skip sse4a
|
||||||
|
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -6,10 +6,6 @@ perf.data
|
||||||
perf.data.old
|
perf.data.old
|
||||||
*.events
|
*.events
|
||||||
*.string*
|
*.string*
|
||||||
/build_sysroot/sysroot
|
|
||||||
/build_sysroot/sysroot_src
|
|
||||||
/build_sysroot/Cargo.lock
|
|
||||||
/build_sysroot/test_target/Cargo.lock
|
|
||||||
gimple*
|
gimple*
|
||||||
*asm
|
*asm
|
||||||
res
|
res
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
authors = ["bjorn3 <bjorn3@users.noreply.github.com>"]
|
authors = ["rustc_codegen_gcc devs"]
|
||||||
name = "sysroot"
|
name = "sysroot"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
resolver = "2"
|
resolver = "2"
|
|
@ -1,5 +1,7 @@
|
||||||
use crate::config::{Channel, ConfigInfo};
|
use crate::config::{Channel, ConfigInfo};
|
||||||
use crate::utils::{create_dir, run_command, run_command_with_output_and_env, walk_dir};
|
use crate::utils::{
|
||||||
|
copy_file, create_dir, get_sysroot_dir, run_command, run_command_with_output_and_env, walk_dir,
|
||||||
|
};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
@ -101,10 +103,24 @@ fn cleanup_sysroot_previous_build(start_dir: &Path) {
|
||||||
let _ = fs::remove_dir_all(start_dir.join("sysroot"));
|
let _ = fs::remove_dir_all(start_dir.join("sysroot"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn create_build_sysroot_content(start_dir: &Path) -> Result<(), String> {
|
||||||
|
if !start_dir.is_dir() {
|
||||||
|
create_dir(start_dir)?;
|
||||||
|
}
|
||||||
|
copy_file("build_system/build_sysroot/Cargo.toml", &start_dir.join("Cargo.toml"))?;
|
||||||
|
|
||||||
|
let src_dir = start_dir.join("src");
|
||||||
|
if !src_dir.is_dir() {
|
||||||
|
create_dir(&src_dir)?;
|
||||||
|
}
|
||||||
|
copy_file("build_system/build_sysroot/lib.rs", &start_dir.join("src/lib.rs"))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn build_sysroot(env: &HashMap<String, String>, config: &ConfigInfo) -> Result<(), String> {
|
pub fn build_sysroot(env: &HashMap<String, String>, config: &ConfigInfo) -> Result<(), String> {
|
||||||
let start_dir = Path::new("build_sysroot");
|
let start_dir = get_sysroot_dir();
|
||||||
|
|
||||||
cleanup_sysroot_previous_build(&start_dir);
|
cleanup_sysroot_previous_build(&start_dir);
|
||||||
|
create_build_sysroot_content(&start_dir)?;
|
||||||
|
|
||||||
// Builds libs
|
// Builds libs
|
||||||
let mut rustflags = env.get("RUSTFLAGS").cloned().unwrap_or_default();
|
let mut rustflags = env.get("RUSTFLAGS").cloned().unwrap_or_default();
|
||||||
|
@ -115,7 +131,6 @@ pub fn build_sysroot(env: &HashMap<String, String>, config: &ConfigInfo) -> Resu
|
||||||
if config.no_default_features {
|
if config.no_default_features {
|
||||||
rustflags.push_str(" -Csymbol-mangling-version=v0");
|
rustflags.push_str(" -Csymbol-mangling-version=v0");
|
||||||
}
|
}
|
||||||
let mut env = env.clone();
|
|
||||||
|
|
||||||
let mut args: Vec<&dyn AsRef<OsStr>> = vec![&"cargo", &"build", &"--target", &config.target];
|
let mut args: Vec<&dyn AsRef<OsStr>> = vec![&"cargo", &"build", &"--target", &config.target];
|
||||||
|
|
||||||
|
@ -132,8 +147,9 @@ pub fn build_sysroot(env: &HashMap<String, String>, config: &ConfigInfo) -> Resu
|
||||||
"debug"
|
"debug"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let mut env = env.clone();
|
||||||
env.insert("RUSTFLAGS".to_string(), rustflags);
|
env.insert("RUSTFLAGS".to_string(), rustflags);
|
||||||
run_command_with_output_and_env(&args, Some(start_dir), Some(&env))?;
|
run_command_with_output_and_env(&args, Some(&start_dir), Some(&env))?;
|
||||||
|
|
||||||
// Copy files to sysroot
|
// Copy files to sysroot
|
||||||
let sysroot_path = start_dir.join(format!("sysroot/lib/rustlib/{}/lib/", config.target_triple));
|
let sysroot_path = start_dir.join(format!("sysroot/lib/rustlib/{}/lib/", config.target_triple));
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::utils::{remove_file, run_command};
|
use crate::utils::{get_sysroot_dir, remove_file, run_command};
|
||||||
|
|
||||||
use std::fs::remove_dir_all;
|
use std::fs::remove_dir_all;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
@ -42,8 +42,13 @@ fn usage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clean_all() -> Result<(), String> {
|
fn clean_all() -> Result<(), String> {
|
||||||
let dirs_to_remove =
|
let build_sysroot = get_sysroot_dir();
|
||||||
["target", "build_sysroot/sysroot", "build_sysroot/sysroot_src", "build_sysroot/target"];
|
let dirs_to_remove = [
|
||||||
|
"target".into(),
|
||||||
|
build_sysroot.join("sysroot"),
|
||||||
|
build_sysroot.join("sysroot_src"),
|
||||||
|
build_sysroot.join("target"),
|
||||||
|
];
|
||||||
for dir in dirs_to_remove {
|
for dir in dirs_to_remove {
|
||||||
let _ = remove_dir_all(dir);
|
let _ = remove_dir_all(dir);
|
||||||
}
|
}
|
||||||
|
@ -52,10 +57,11 @@ fn clean_all() -> Result<(), String> {
|
||||||
let _ = remove_dir_all(Path::new(crate::BUILD_DIR).join(dir));
|
let _ = remove_dir_all(Path::new(crate::BUILD_DIR).join(dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
let files_to_remove = ["build_sysroot/Cargo.lock", "perf.data", "perf.data.old"];
|
let files_to_remove =
|
||||||
|
[build_sysroot.join("Cargo.lock"), "perf.data".into(), "perf.data.old".into()];
|
||||||
|
|
||||||
for file in files_to_remove {
|
for file in files_to_remove {
|
||||||
let _ = remove_file(file);
|
let _ = remove_file(&file);
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Successfully ran `clean all`");
|
println!("Successfully ran `clean all`");
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::utils::{
|
use crate::utils::{
|
||||||
create_dir, create_symlink, get_os_name, run_command_with_output, rustc_version_info,
|
create_dir, create_symlink, get_os_name, get_sysroot_dir, run_command_with_output,
|
||||||
split_args,
|
rustc_version_info, split_args,
|
||||||
};
|
};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::env as std_env;
|
use std::env as std_env;
|
||||||
|
@ -363,7 +363,8 @@ impl ConfigInfo {
|
||||||
.join(&format!("librustc_codegen_gcc.{}", self.dylib_ext))
|
.join(&format!("librustc_codegen_gcc.{}", self.dylib_ext))
|
||||||
.display()
|
.display()
|
||||||
.to_string();
|
.to_string();
|
||||||
self.sysroot_path = current_dir.join("build_sysroot/sysroot").display().to_string();
|
self.sysroot_path =
|
||||||
|
current_dir.join(&get_sysroot_dir()).join("sysroot").display().to_string();
|
||||||
if let Some(backend) = &self.backend {
|
if let Some(backend) = &self.backend {
|
||||||
// This option is only used in the rust compiler testsuite. The sysroot is handled
|
// This option is only used in the rust compiler testsuite. The sysroot is handled
|
||||||
// by its build system directly so no need to set it ourselves.
|
// by its build system directly so no need to set it ourselves.
|
||||||
|
@ -392,8 +393,6 @@ impl ConfigInfo {
|
||||||
rustflags.push("-Csymbol-mangling-version=v0".to_string());
|
rustflags.push("-Csymbol-mangling-version=v0".to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Since we don't support ThinLTO, disable LTO completely when not trying to do LTO.
|
// Since we don't support ThinLTO, disable LTO completely when not trying to do LTO.
|
||||||
// TODO(antoyo): remove when we can handle ThinLTO.
|
// TODO(antoyo): remove when we can handle ThinLTO.
|
||||||
if !env.contains_key(&"FAT_LTO".to_string()) {
|
if !env.contains_key(&"FAT_LTO".to_string()) {
|
||||||
|
@ -411,7 +410,8 @@ impl ConfigInfo {
|
||||||
env.insert("RUSTC_LOG".to_string(), "warn".to_string());
|
env.insert("RUSTC_LOG".to_string(), "warn".to_string());
|
||||||
|
|
||||||
let sysroot = current_dir
|
let sysroot = current_dir
|
||||||
.join(&format!("build_sysroot/sysroot/lib/rustlib/{}/lib", self.target_triple,));
|
.join(&get_sysroot_dir())
|
||||||
|
.join(&format!("sysroot/lib/rustlib/{}/lib", self.target_triple));
|
||||||
let ld_library_path = format!(
|
let ld_library_path = format!(
|
||||||
"{target}:{sysroot}:{gcc_path}",
|
"{target}:{sysroot}:{gcc_path}",
|
||||||
target = self.cargo_target_dir,
|
target = self.cargo_target_dir,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::rustc_info::get_rustc_path;
|
use crate::rustc_info::get_rustc_path;
|
||||||
use crate::utils::{
|
use crate::utils::{
|
||||||
cargo_install, create_dir, git_clone_root_dir, remove_file, run_command,
|
cargo_install, create_dir, get_sysroot_dir, git_clone_root_dir, remove_file, run_command,
|
||||||
run_command_with_output, walk_dir,
|
run_command_with_output, walk_dir,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ fn prepare_libcore(
|
||||||
patches.sort();
|
patches.sort();
|
||||||
for file_path in patches {
|
for file_path in patches {
|
||||||
println!("[GIT] apply `{}`", file_path.display());
|
println!("[GIT] apply `{}`", file_path.display());
|
||||||
let path = Path::new("../..").join(file_path);
|
let path = Path::new("../../..").join(file_path);
|
||||||
run_command_with_output(&[&"git", &"apply", &path], Some(&sysroot_dir))?;
|
run_command_with_output(&[&"git", &"apply", &path], Some(&sysroot_dir))?;
|
||||||
run_command_with_output(&[&"git", &"add", &"-A"], Some(&sysroot_dir))?;
|
run_command_with_output(&[&"git", &"add", &"-A"], Some(&sysroot_dir))?;
|
||||||
run_command_with_output(
|
run_command_with_output(
|
||||||
|
@ -192,8 +192,8 @@ pub fn run() -> Result<(), String> {
|
||||||
Some(a) => a,
|
Some(a) => a,
|
||||||
None => return Ok(()),
|
None => return Ok(()),
|
||||||
};
|
};
|
||||||
let sysroot_path = Path::new("build_sysroot");
|
let sysroot_path = get_sysroot_dir();
|
||||||
prepare_libcore(sysroot_path, args.libgccjit12_patches, args.cross_compile)?;
|
prepare_libcore(&sysroot_path, args.libgccjit12_patches, args.cross_compile)?;
|
||||||
|
|
||||||
if !args.only_libcore {
|
if !args.only_libcore {
|
||||||
cargo_install("hyperfine")?;
|
cargo_install("hyperfine")?;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use crate::build;
|
use crate::build;
|
||||||
use crate::config::{Channel, ConfigInfo};
|
use crate::config::{Channel, ConfigInfo};
|
||||||
use crate::utils::{
|
use crate::utils::{
|
||||||
create_dir, get_toolchain, git_clone, git_clone_root_dir, remove_file, run_command,
|
create_dir, get_sysroot_dir, get_toolchain, git_clone, git_clone_root_dir, remove_file,
|
||||||
run_command_with_env, run_command_with_output_and_env, rustc_version_info, split_args,
|
run_command, run_command_with_env, run_command_with_output_and_env, rustc_version_info,
|
||||||
walk_dir,
|
split_args, walk_dir,
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::collections::{BTreeSet, HashMap};
|
use std::collections::{BTreeSet, HashMap};
|
||||||
|
@ -535,12 +535,13 @@ fn asm_tests(env: &Env, args: &TestArg) -> Result<(), String> {
|
||||||
let rustc_args = &format!(
|
let rustc_args = &format!(
|
||||||
r#"-Zpanic-abort-tests \
|
r#"-Zpanic-abort-tests \
|
||||||
-Zcodegen-backend="{pwd}/target/{channel}/librustc_codegen_gcc.{dylib_ext}" \
|
-Zcodegen-backend="{pwd}/target/{channel}/librustc_codegen_gcc.{dylib_ext}" \
|
||||||
--sysroot "{pwd}/build_sysroot/sysroot" -Cpanic=abort{extra}"#,
|
--sysroot "{pwd}/{sysroot_dir}" -Cpanic=abort{extra}"#,
|
||||||
pwd = std::env::current_dir()
|
pwd = std::env::current_dir()
|
||||||
.map_err(|error| format!("`current_dir` failed: {:?}", error))?
|
.map_err(|error| format!("`current_dir` failed: {:?}", error))?
|
||||||
.display(),
|
.display(),
|
||||||
channel = args.config_info.channel.as_str(),
|
channel = args.config_info.channel.as_str(),
|
||||||
dylib_ext = args.config_info.dylib_ext,
|
dylib_ext = args.config_info.dylib_ext,
|
||||||
|
sysroot_dir = args.config_info.sysroot_path,
|
||||||
extra = extra,
|
extra = extra,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -671,9 +672,9 @@ fn test_projects(env: &Env, args: &TestArg) -> Result<(), String> {
|
||||||
fn test_libcore(env: &Env, args: &TestArg) -> Result<(), String> {
|
fn test_libcore(env: &Env, args: &TestArg) -> Result<(), String> {
|
||||||
// FIXME: create a function "display_if_not_quiet" or something along the line.
|
// FIXME: create a function "display_if_not_quiet" or something along the line.
|
||||||
println!("[TEST] libcore");
|
println!("[TEST] libcore");
|
||||||
let path = Path::new("build_sysroot/sysroot_src/library/core/tests");
|
let path = get_sysroot_dir().join("sysroot_src/library/core/tests");
|
||||||
let _ = remove_dir_all(path.join("target"));
|
let _ = remove_dir_all(path.join("target"));
|
||||||
run_cargo_command(&[&"test"], Some(path), env, args)?;
|
run_cargo_command(&[&"test"], Some(&path), env, args)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -296,6 +296,19 @@ pub fn create_dir<P: AsRef<Path>>(path: P) -> Result<(), String> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn copy_file<F: AsRef<Path>, T: AsRef<Path>>(from: F, to: T) -> Result<(), String> {
|
||||||
|
fs::copy(&from, &to)
|
||||||
|
.map_err(|error| {
|
||||||
|
format!(
|
||||||
|
"Failed to copy file `{}` into `{}`: {:?}",
|
||||||
|
from.as_ref().display(),
|
||||||
|
to.as_ref().display(),
|
||||||
|
error
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.map(|_| ())
|
||||||
|
}
|
||||||
|
|
||||||
/// This function differs from `git_clone` in how it handles *where* the repository will be cloned.
|
/// This function differs from `git_clone` in how it handles *where* the repository will be cloned.
|
||||||
/// In `git_clone`, it is cloned in the provided path. In this function, the path you provide is
|
/// In `git_clone`, it is cloned in the provided path. In this function, the path you provide is
|
||||||
/// the parent folder. So if you pass "a" as folder and try to clone "b.git", it will be cloned into
|
/// the parent folder. So if you pass "a" as folder and try to clone "b.git", it will be cloned into
|
||||||
|
@ -403,6 +416,10 @@ pub fn create_symlink<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> R
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_sysroot_dir() -> PathBuf {
|
||||||
|
Path::new(crate::BUILD_DIR).join("build_sysroot")
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -79,7 +79,7 @@ pub fn main_inner(profile: Profile) {
|
||||||
compiler.args([
|
compiler.args([
|
||||||
&format!("-Zcodegen-backend={}/target/debug/librustc_codegen_gcc.so", current_dir),
|
&format!("-Zcodegen-backend={}/target/debug/librustc_codegen_gcc.so", current_dir),
|
||||||
"--sysroot",
|
"--sysroot",
|
||||||
&format!("{}/build_sysroot/sysroot/", current_dir),
|
&format!("{}/build/build_sysroot/sysroot/", current_dir),
|
||||||
"-Zno-parallel-llvm",
|
"-Zno-parallel-llvm",
|
||||||
"-C",
|
"-C",
|
||||||
"link-arg=-lc",
|
"link-arg=-lc",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue