Skip to content

Commit cf3aa64

Browse files
committed
Better build dir layout
It now matches the layout used by rustc itself
1 parent df45a06 commit cf3aa64

File tree

6 files changed

+17
-13
lines changed

6 files changed

+17
-13
lines changed

Readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ This should build and run your project with rustc_codegen_cranelift instead of t
5151
> You should prefer using the Cargo method.
5252
5353
```bash
54-
$ $cg_clif_dir/build/cg_clif my_crate.rs
54+
$ $cg_clif_dir/build/bin/cg_clif my_crate.rs
5555
```
5656

5757
### Jit mode
@@ -68,7 +68,7 @@ $ $cg_clif_dir/build/cargo.sh jit
6868
or
6969

7070
```bash
71-
$ $cg_clif_dir/build/cg_clif --jit my_crate.rs
71+
$ $cg_clif_dir/build/bin/cg_clif --jit my_crate.rs
7272
```
7373

7474
### Shell
@@ -77,7 +77,7 @@ These are a few functions that allow you to easily run rust code from the shell
7777

7878
```bash
7979
function jit_naked() {
80-
echo "$@" | $cg_clif_dir/build/cg_clif - --jit
80+
echo "$@" | $cg_clif_dir/build/bin/cg_clif - --jit
8181
}
8282

8383
function jit() {

build.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ fi
3636

3737
rm -rf "$target_dir"
3838
mkdir "$target_dir"
39-
cp -a target/$CHANNEL/cg_clif{,_build_sysroot} target/$CHANNEL/*rustc_codegen_cranelift* "$target_dir/"
39+
mkdir "$target_dir"/bin "$target_dir"/lib
40+
cp -a target/$CHANNEL/cg_clif{,_build_sysroot} "$target_dir"/bin
41+
cp -a target/$CHANNEL/*rustc_codegen_cranelift* "$target_dir"/lib
4042
cp -a rust-toolchain scripts/config.sh scripts/cargo.sh "$target_dir"
4143

4244
if [[ "$build_sysroot" == "1" ]]; then

build_sysroot/build_sysroot.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dir=$(pwd)
1010

1111
# Use rustc with cg_clif as hotpluggable backend instead of the custom cg_clif driver so that
1212
# build scripts are still compiled using cg_llvm.
13-
export RUSTC=$dir"/cg_clif_build_sysroot"
13+
export RUSTC=$dir"/bin/cg_clif_build_sysroot"
1414
export RUSTFLAGS=$RUSTFLAGS" --clif"
1515

1616
cd "$(dirname "$0")"
@@ -35,6 +35,6 @@ else
3535
fi
3636

3737
# Copy files to sysroot
38-
mkdir -p "$dir/sysroot/lib/rustlib/$TARGET_TRIPLE/lib/"
39-
cp -a "target/$TARGET_TRIPLE/$sysroot_channel/deps/"* "$dir/sysroot/lib/rustlib/$TARGET_TRIPLE/lib/"
40-
rm "$dir/sysroot/lib/rustlib/$TARGET_TRIPLE/lib/"*.{rmeta,d}
38+
mkdir -p "$dir/lib/rustlib/$TARGET_TRIPLE/lib/"
39+
cp -a "target/$TARGET_TRIPLE/$sysroot_channel/deps/"* "$dir/lib/rustlib/$TARGET_TRIPLE/lib/"
40+
rm "$dir/lib/rustlib/$TARGET_TRIPLE/lib/"*.{rmeta,d}

scripts/config.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ fi
4343

4444
dir=$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)
4545

46-
export RUSTC=$dir"/cg_clif"
46+
export RUSTC=$dir"/bin/cg_clif"
4747
export RUSTFLAGS=$linker" "$RUSTFLAGS
4848
export RUSTDOCFLAGS=$linker' -Cpanic=abort -Zpanic-abort-tests '\
49-
'-Zcodegen-backend='$dir'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$dir'/sysroot'
49+
'-Zcodegen-backend='$dir'/lib/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$dir
5050

5151
# FIXME remove once the atomic shim is gone
5252
if [[ $(uname) == 'Darwin' ]]; then
5353
export RUSTFLAGS="$RUSTFLAGS -Clink-arg=-undefined -Clink-arg=dynamic_lookup"
5454
fi
5555

56-
export LD_LIBRARY_PATH="$dir:$(rustc --print sysroot)/lib:$dir/target/out:$dir/sysroot/lib/rustlib/$TARGET_TRIPLE/lib"
56+
export LD_LIBRARY_PATH="$dir/lib:$(rustc --print sysroot)/lib:$dir/target/out:$dir/sysroot/lib/rustlib/$TARGET_TRIPLE/lib"
5757
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
5858

5959
export CG_CLIF_DISPLAY_CG_TIME=1

scripts/test_bootstrap.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ cat > config.toml <<EOF
4848
ninja = false
4949
5050
[build]
51-
rustc = "$(pwd)/../build/cg_clif"
51+
rustc = "$(pwd)/../build/bin/cg_clif"
5252
cargo = "$(rustup which cargo)"
5353
full-bootstrap = true
5454
local-rebuild = true

src/bin/cg_clif.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ impl rustc_driver::Callbacks for CraneliftPassesCallbacks {
3232
.unwrap()
3333
.parent()
3434
.unwrap()
35-
.join("sysroot"),
35+
.parent()
36+
.unwrap()
37+
.to_owned(),
3638
),
3739
);
3840
}

0 commit comments

Comments
 (0)