From 26d48c9a378f20f817e779328affc6c2643a3505 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Mon, 28 Nov 2022 13:01:49 +0000 Subject: [PATCH 1/3] Rename the build/ directory to dist/ This will allow putting all temporary build artifacts in build/ in the future, keeping all the build output artifacts in dist/ --- .github/workflows/main.yml | 4 ++-- .gitignore | 1 + Readme.md | 2 +- build_system/mod.rs | 2 +- build_system/tests.rs | 6 +++--- clean_all.sh | 4 ++-- docs/usage.md | 12 ++++++------ scripts/filter_profile.rs | 2 +- scripts/setup_rust_fork.sh | 2 +- scripts/test_rustc_tests.sh | 2 +- 10 files changed, 19 insertions(+), 18 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e6d75177b2796..de3c89f3383da 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -111,7 +111,7 @@ jobs: ./y.rs test - name: Package prebuilt cg_clif - run: tar cvfJ cg_clif.tar.xz build + run: tar cvfJ cg_clif.tar.xz dist - name: Upload prebuilt cg_clif if: matrix.env.TARGET_TRIPLE != 'x86_64-pc-windows-gnu' @@ -213,7 +213,7 @@ jobs: - name: Package prebuilt cg_clif # don't use compression as xzip isn't supported by tar on windows and bzip2 hangs - run: tar cvf cg_clif.tar build + run: tar cvf cg_clif.tar dist - name: Upload prebuilt cg_clif uses: actions/upload-artifact@v3 diff --git a/.gitignore b/.gitignore index fae09592c6ac0..b443fd58a1b98 100644 --- a/.gitignore +++ b/.gitignore @@ -14,5 +14,6 @@ perf.data.old /build_sysroot/sysroot_src /build_sysroot/compiler-builtins /build_sysroot/rustc_version +/dist /rust /download diff --git a/Readme.md b/Readme.md index 1e84c7fa3657b..0e9c77244d4cc 100644 --- a/Readme.md +++ b/Readme.md @@ -37,7 +37,7 @@ Assuming `$cg_clif_dir` is the directory you cloned this repo into and you follo In the directory with your project (where you can do the usual `cargo build`), run: ```bash -$ $cg_clif_dir/build/cargo-clif build +$ $cg_clif_dir/dist/cargo-clif build ``` This will build your project with rustc_codegen_cranelift instead of the usual LLVM backend. diff --git a/build_system/mod.rs b/build_system/mod.rs index b25270d832ceb..b246a70e89f18 100644 --- a/build_system/mod.rs +++ b/build_system/mod.rs @@ -75,7 +75,7 @@ pub fn main() { } }; - let mut target_dir = PathBuf::from("build"); + let mut target_dir = PathBuf::from("dist"); let mut channel = "release"; let mut sysroot_kind = SysrootKind::Clif; let mut use_unstable_features = true; diff --git a/build_system/tests.rs b/build_system/tests.rs index b1c5c64883990..174b77206fba6 100644 --- a/build_system/tests.rs +++ b/build_system/tests.rs @@ -274,7 +274,7 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[ eprintln!("[BENCH COMPILE] ebobby/simple-raytracer"); let cargo_clif = env::current_dir() .unwrap() - .join("build") + .join("dist") .join(get_wrapper_file_name("cargo-clif", "bin")); let source_dir = SIMPLE_RAYTRACER.source_dir(); let manifest_path = SIMPLE_RAYTRACER.manifest_path(); @@ -503,11 +503,11 @@ impl TestRunner { target_triple.contains("x86_64") && is_native && !host_triple.contains("windows"); let mut rustc_clif = root_dir.clone(); - rustc_clif.push("build"); + rustc_clif.push("dist"); rustc_clif.push(get_wrapper_file_name("rustc-clif", "bin")); let mut rustdoc_clif = root_dir.clone(); - rustdoc_clif.push("build"); + rustdoc_clif.push("dist"); rustdoc_clif.push(get_wrapper_file_name("rustdoc-clif", "bin")); let mut rustflags = env::var("RUSTFLAGS").ok().unwrap_or("".to_string()); diff --git a/clean_all.sh b/clean_all.sh index fedab2433aa05..cd20f3ea3f1e7 100755 --- a/clean_all.sh +++ b/clean_all.sh @@ -2,9 +2,9 @@ set -e rm -rf build_sysroot/{sysroot_src/,target/,compiler-builtins/,rustc_version} -rm -rf target/ build/ perf.data{,.old} y.bin +rm -rf target/ dist/ perf.data{,.old} y.bin rm -rf download/ # 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 rand/ regex/ simple-raytracer/ portable-simd/ abi-checker/ abi-cafe/ build/ diff --git a/docs/usage.md b/docs/usage.md index 33f146e7ba27a..4c2b0fa170498 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -9,7 +9,7 @@ Assuming `$cg_clif_dir` is the directory you cloned this repo into and you follo In the directory with your project (where you can do the usual `cargo build`), run: ```bash -$ $cg_clif_dir/build/cargo-clif build +$ $cg_clif_dir/dist/cargo-clif build ``` This will build your project with rustc_codegen_cranelift instead of the usual LLVM backend. @@ -19,7 +19,7 @@ This will build your project with rustc_codegen_cranelift instead of the usual L > You should prefer using the Cargo method. ```bash -$ $cg_clif_dir/build/rustc-clif my_crate.rs +$ $cg_clif_dir/dist/rustc-clif my_crate.rs ``` ## Jit mode @@ -32,20 +32,20 @@ In jit mode cg_clif will immediately execute your code without creating an execu > The jit mode will probably need cargo integration to make this possible. ```bash -$ $cg_clif_dir/build/cargo-clif jit +$ $cg_clif_dir/dist/cargo-clif jit ``` or ```bash -$ $cg_clif_dir/build/rustc-clif -Zunstable-features -Cllvm-args=mode=jit -Cprefer-dynamic my_crate.rs +$ $cg_clif_dir/dist/rustc-clif -Zunstable-features -Cllvm-args=mode=jit -Cprefer-dynamic my_crate.rs ``` There is also an experimental lazy jit mode. In this mode functions are only compiled once they are first called. ```bash -$ $cg_clif_dir/build/cargo-clif lazy-jit +$ $cg_clif_dir/dist/cargo-clif lazy-jit ``` ## Shell @@ -54,7 +54,7 @@ These are a few functions that allow you to easily run rust code from the shell ```bash function jit_naked() { - echo "$@" | $cg_clif_dir/build/rustc-clif - -Zunstable-features -Cllvm-args=mode=jit -Cprefer-dynamic + echo "$@" | $cg_clif_dir/dist/rustc-clif - -Zunstable-features -Cllvm-args=mode=jit -Cprefer-dynamic } function jit() { diff --git a/scripts/filter_profile.rs b/scripts/filter_profile.rs index e6f60d1c0cb23..f782671fe36f9 100755 --- a/scripts/filter_profile.rs +++ b/scripts/filter_profile.rs @@ -2,7 +2,7 @@ #![forbid(unsafe_code)]/* This line is ignored by bash # This block is ignored by rustc pushd $(dirname "$0")/../ -RUSTC="$(pwd)/build/rustc-clif" +RUSTC="$(pwd)/dist/rustc-clif" popd PROFILE=$1 OUTPUT=$2 exec $RUSTC -Zunstable-options -Cllvm-args=mode=jit -Cprefer-dynamic $0 #*/ diff --git a/scripts/setup_rust_fork.sh b/scripts/setup_rust_fork.sh index 5a73cb0e2c22d..6c64b7de7daa1 100644 --- a/scripts/setup_rust_fork.sh +++ b/scripts/setup_rust_fork.sh @@ -36,7 +36,7 @@ changelog-seen = 2 ninja = false [build] -rustc = "$(pwd)/../build/rustc-clif" +rustc = "$(pwd)/../dist/rustc-clif" cargo = "$(rustup which cargo)" full-bootstrap = true local-rebuild = true diff --git a/scripts/test_rustc_tests.sh b/scripts/test_rustc_tests.sh index 74a99802b1027..d2656f783ad86 100755 --- a/scripts/test_rustc_tests.sh +++ b/scripts/test_rustc_tests.sh @@ -89,7 +89,7 @@ rm src/test/ui/consts/issue-33537.rs # same # doesn't work due to the way the rustc test suite is invoked. # should work when using ./x.py test the way it is intended # ============================================================ -rm -r src/test/run-make/emit-shared-files # requires the rustdoc executable in build/bin/ +rm -r src/test/run-make/emit-shared-files # requires the rustdoc executable in dist/bin/ rm -r src/test/run-make/unstable-flag-required # same rm -r src/test/run-make/rustdoc-* # same rm -r src/test/run-make/issue-88756-default-output # same From 052d5ccf5dc83db14917f4a52329a3bf2465af74 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Mon, 28 Nov 2022 13:03:47 +0000 Subject: [PATCH 2/3] Implement __isb for AArch64 This is necessary for the mutex implementation of libstd when there is contention. Seems like I hadn't hit this before by sheer luck. --- src/intrinsics/llvm_aarch64.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/intrinsics/llvm_aarch64.rs b/src/intrinsics/llvm_aarch64.rs index 7959176ac85df..b431158d2690f 100644 --- a/src/intrinsics/llvm_aarch64.rs +++ b/src/intrinsics/llvm_aarch64.rs @@ -16,6 +16,10 @@ pub(crate) fn codegen_aarch64_llvm_intrinsic_call<'tcx>( // llvm.aarch64.neon.sqshl.v*i* match intrinsic { + "llvm.aarch64.isb" => { + fx.bcx.ins().fence(); + } + _ if intrinsic.starts_with("llvm.aarch64.neon.abs.v") => { intrinsic_args!(fx, args => (a); intrinsic); From 9c21990283e55c9de4ad90d6923f64a45bff2b27 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Mon, 28 Nov 2022 15:02:08 +0000 Subject: [PATCH 3/3] Rename target_dir to dist_dir in a couple of places --- build_system/abi_cafe.rs | 4 ++-- build_system/build_sysroot.rs | 28 ++++++++++++++-------------- build_system/mod.rs | 20 ++++++++++---------- build_system/tests.rs | 6 +++--- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build_system/abi_cafe.rs b/build_system/abi_cafe.rs index 8949f9f7e7d9a..bff5b8f41020a 100644 --- a/build_system/abi_cafe.rs +++ b/build_system/abi_cafe.rs @@ -14,7 +14,7 @@ static ABI_CAFE: CargoProject = CargoProject::git(&ABI_CAFE_REPO, "."); pub(crate) fn run( channel: &str, sysroot_kind: SysrootKind, - target_dir: &Path, + dist_dir: &Path, cg_clif_dylib: &Path, host_triple: &str, target_triple: &str, @@ -33,7 +33,7 @@ pub(crate) fn run( build_sysroot::build_sysroot( channel, sysroot_kind, - target_dir, + dist_dir, cg_clif_dylib, host_triple, target_triple, diff --git a/build_system/build_sysroot.rs b/build_system/build_sysroot.rs index 731b94472ab5f..4b21df85f5fbf 100644 --- a/build_system/build_sysroot.rs +++ b/build_system/build_sysroot.rs @@ -9,21 +9,21 @@ use super::SysrootKind; pub(crate) fn build_sysroot( channel: &str, sysroot_kind: SysrootKind, - target_dir: &Path, + dist_dir: &Path, cg_clif_dylib_src: &Path, host_triple: &str, target_triple: &str, ) { eprintln!("[BUILD] sysroot {:?}", sysroot_kind); - if target_dir.exists() { - fs::remove_dir_all(target_dir).unwrap(); + if dist_dir.exists() { + fs::remove_dir_all(dist_dir).unwrap(); } - fs::create_dir_all(target_dir.join("bin")).unwrap(); - fs::create_dir_all(target_dir.join("lib")).unwrap(); + fs::create_dir_all(dist_dir.join("bin")).unwrap(); + fs::create_dir_all(dist_dir.join("lib")).unwrap(); // Copy the backend - let cg_clif_dylib_path = target_dir + let cg_clif_dylib_path = dist_dir .join(if cfg!(windows) { // Windows doesn't have rpath support, so the cg_clif dylib needs to be next to the // binaries. @@ -42,14 +42,14 @@ pub(crate) fn build_sysroot( build_cargo_wrapper_cmd .arg(PathBuf::from("scripts").join(format!("{wrapper}.rs"))) .arg("-o") - .arg(target_dir.join(wrapper_name)) + .arg(dist_dir.join(wrapper_name)) .arg("-g"); spawn_and_wait(build_cargo_wrapper_cmd); } let default_sysroot = super::rustc_info::get_default_sysroot(); - let rustlib = target_dir.join("lib").join("rustlib"); + let rustlib = dist_dir.join("lib").join("rustlib"); let host_rustlib_lib = rustlib.join(host_triple).join("lib"); let target_rustlib_lib = rustlib.join(target_triple).join("lib"); fs::create_dir_all(&host_rustlib_lib).unwrap(); @@ -114,7 +114,7 @@ pub(crate) fn build_sysroot( SysrootKind::Clif => { build_clif_sysroot_for_triple( channel, - target_dir, + dist_dir, host_triple, &cg_clif_dylib_path, None, @@ -129,7 +129,7 @@ pub(crate) fn build_sysroot( }; build_clif_sysroot_for_triple( channel, - target_dir, + dist_dir, target_triple, &cg_clif_dylib_path, linker, @@ -142,7 +142,7 @@ pub(crate) fn build_sysroot( let file = file.unwrap().path(); let filename = file.file_name().unwrap().to_str().unwrap(); if filename.contains("std-") && !filename.contains(".rlib") { - try_hard_link(&file, target_dir.join("lib").join(file.file_name().unwrap())); + try_hard_link(&file, dist_dir.join("lib").join(file.file_name().unwrap())); } } } @@ -153,7 +153,7 @@ static STANDARD_LIBRARY: CargoProject = CargoProject::local("build_sysroot"); fn build_clif_sysroot_for_triple( channel: &str, - target_dir: &Path, + dist_dir: &Path, triple: &str, cg_clif_dylib_path: &Path, linker: Option<&str>, @@ -189,7 +189,7 @@ fn build_clif_sysroot_for_triple( // Build sysroot let mut rustflags = "-Zforce-unstable-if-unmarked -Cpanic=abort".to_string(); rustflags.push_str(&format!(" -Zcodegen-backend={}", cg_clif_dylib_path.to_str().unwrap())); - rustflags.push_str(&format!(" --sysroot={}", target_dir.to_str().unwrap())); + rustflags.push_str(&format!(" --sysroot={}", dist_dir.to_str().unwrap())); if channel == "release" { rustflags.push_str(" -Zmir-opt-level=3"); } @@ -221,7 +221,7 @@ fn build_clif_sysroot_for_triple( }; try_hard_link( entry.path(), - target_dir.join("lib").join("rustlib").join(triple).join("lib").join(entry.file_name()), + dist_dir.join("lib").join("rustlib").join(triple).join("lib").join(entry.file_name()), ); } } diff --git a/build_system/mod.rs b/build_system/mod.rs index b246a70e89f18..531f42cf87300 100644 --- a/build_system/mod.rs +++ b/build_system/mod.rs @@ -17,10 +17,10 @@ fn usage() { eprintln!("Usage:"); eprintln!(" ./y.rs prepare"); eprintln!( - " ./y.rs build [--debug] [--sysroot none|clif|llvm] [--target-dir DIR] [--no-unstable-features]" + " ./y.rs build [--debug] [--sysroot none|clif|llvm] [--dist-dir DIR] [--no-unstable-features]" ); eprintln!( - " ./y.rs test [--debug] [--sysroot none|clif|llvm] [--target-dir DIR] [--no-unstable-features]" + " ./y.rs test [--debug] [--sysroot none|clif|llvm] [--dist-dir DIR] [--no-unstable-features]" ); } @@ -75,15 +75,15 @@ pub fn main() { } }; - let mut target_dir = PathBuf::from("dist"); + let mut dist_dir = PathBuf::from("dist"); let mut channel = "release"; let mut sysroot_kind = SysrootKind::Clif; let mut use_unstable_features = true; while let Some(arg) = args.next().as_deref() { match arg { - "--target-dir" => { - target_dir = PathBuf::from(args.next().unwrap_or_else(|| { - arg_error!("--target-dir requires argument"); + "--dist-dir" => { + dist_dir = PathBuf::from(args.next().unwrap_or_else(|| { + arg_error!("--dist-dir requires argument"); })) } "--debug" => channel = "debug", @@ -101,7 +101,7 @@ pub fn main() { arg => arg_error!("Unexpected argument {}", arg), } } - target_dir = std::env::current_dir().unwrap().join(target_dir); + dist_dir = std::env::current_dir().unwrap().join(dist_dir); let host_triple = if let Ok(host_triple) = std::env::var("HOST_TRIPLE") { host_triple @@ -128,7 +128,7 @@ pub fn main() { tests::run_tests( channel, sysroot_kind, - &target_dir, + &dist_dir, &cg_clif_dylib, &host_triple, &target_triple, @@ -137,7 +137,7 @@ pub fn main() { abi_cafe::run( channel, sysroot_kind, - &target_dir, + &dist_dir, &cg_clif_dylib, &host_triple, &target_triple, @@ -147,7 +147,7 @@ pub fn main() { build_sysroot::build_sysroot( channel, sysroot_kind, - &target_dir, + &dist_dir, &cg_clif_dylib, &host_triple, &target_triple, diff --git a/build_system/tests.rs b/build_system/tests.rs index 174b77206fba6..aa46cd0a250e7 100644 --- a/build_system/tests.rs +++ b/build_system/tests.rs @@ -432,7 +432,7 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[ pub(crate) fn run_tests( channel: &str, sysroot_kind: SysrootKind, - target_dir: &Path, + dist_dir: &Path, cg_clif_dylib: &Path, host_triple: &str, target_triple: &str, @@ -443,7 +443,7 @@ pub(crate) fn run_tests( build_sysroot::build_sysroot( channel, SysrootKind::None, - &target_dir, + &dist_dir, cg_clif_dylib, &host_triple, &target_triple, @@ -462,7 +462,7 @@ pub(crate) fn run_tests( build_sysroot::build_sysroot( channel, sysroot_kind, - &target_dir, + &dist_dir, cg_clif_dylib, &host_triple, &target_triple,