Skip to content

Commit

Permalink
Merge pull request rust-lang#1300 from bjorn3/rename_build_to_dist
Browse files Browse the repository at this point in the history
Rename the build/ directory to dist/
  • Loading branch information
bjorn3 committed Nov 29, 2022
2 parents a00c7a0 + 9c21990 commit 70ba23b
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 46 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ perf.data.old
/build_sysroot/sysroot_src
/build_sysroot/compiler-builtins
/build_sysroot/rustc_version
/dist
/rust
/download
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions build_system/abi_cafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
28 changes: 14 additions & 14 deletions build_system/build_sysroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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();
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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()));
}
}
}
Expand All @@ -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>,
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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()),
);
}
}
20 changes: 10 additions & 10 deletions build_system/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
);
}

Expand Down Expand Up @@ -75,15 +75,15 @@ pub fn main() {
}
};

let mut target_dir = PathBuf::from("build");
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",
Expand All @@ -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
Expand All @@ -128,7 +128,7 @@ pub fn main() {
tests::run_tests(
channel,
sysroot_kind,
&target_dir,
&dist_dir,
&cg_clif_dylib,
&host_triple,
&target_triple,
Expand All @@ -137,7 +137,7 @@ pub fn main() {
abi_cafe::run(
channel,
sysroot_kind,
&target_dir,
&dist_dir,
&cg_clif_dylib,
&host_triple,
&target_triple,
Expand All @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions build_system/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions clean_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/
12 changes: 6 additions & 6 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion scripts/filter_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
#*/
Expand Down
2 changes: 1 addition & 1 deletion scripts/setup_rust_fork.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/test_rustc_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/intrinsics/llvm_aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 70ba23b

Please sign in to comment.