Skip to content

Commit

Permalink
Better build dir layout
Browse files Browse the repository at this point in the history
It now matches the layout used by rustc itself
  • Loading branch information
bjorn3 committed Nov 8, 2020
1 parent df45a06 commit cf3aa64
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
6 changes: 3 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ This should build and run your project with rustc_codegen_cranelift instead of t
> You should prefer using the Cargo method.
```bash
$ $cg_clif_dir/build/cg_clif my_crate.rs
$ $cg_clif_dir/build/bin/cg_clif my_crate.rs
```

### Jit mode
Expand All @@ -68,7 +68,7 @@ $ $cg_clif_dir/build/cargo.sh jit
or

```bash
$ $cg_clif_dir/build/cg_clif --jit my_crate.rs
$ $cg_clif_dir/build/bin/cg_clif --jit my_crate.rs
```

### Shell
Expand All @@ -77,7 +77,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/cg_clif - --jit
echo "$@" | $cg_clif_dir/build/bin/cg_clif - --jit
}

function jit() {
Expand Down
4 changes: 3 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ fi

rm -rf "$target_dir"
mkdir "$target_dir"
cp -a target/$CHANNEL/cg_clif{,_build_sysroot} target/$CHANNEL/*rustc_codegen_cranelift* "$target_dir/"
mkdir "$target_dir"/bin "$target_dir"/lib
cp -a target/$CHANNEL/cg_clif{,_build_sysroot} "$target_dir"/bin
cp -a target/$CHANNEL/*rustc_codegen_cranelift* "$target_dir"/lib
cp -a rust-toolchain scripts/config.sh scripts/cargo.sh "$target_dir"

if [[ "$build_sysroot" == "1" ]]; then
Expand Down
8 changes: 4 additions & 4 deletions build_sysroot/build_sysroot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dir=$(pwd)

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

cd "$(dirname "$0")"
Expand All @@ -35,6 +35,6 @@ else
fi

# Copy files to sysroot
mkdir -p "$dir/sysroot/lib/rustlib/$TARGET_TRIPLE/lib/"
cp -a "target/$TARGET_TRIPLE/$sysroot_channel/deps/"* "$dir/sysroot/lib/rustlib/$TARGET_TRIPLE/lib/"
rm "$dir/sysroot/lib/rustlib/$TARGET_TRIPLE/lib/"*.{rmeta,d}
mkdir -p "$dir/lib/rustlib/$TARGET_TRIPLE/lib/"
cp -a "target/$TARGET_TRIPLE/$sysroot_channel/deps/"* "$dir/lib/rustlib/$TARGET_TRIPLE/lib/"
rm "$dir/lib/rustlib/$TARGET_TRIPLE/lib/"*.{rmeta,d}
6 changes: 3 additions & 3 deletions scripts/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ fi

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

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

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

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

export CG_CLIF_DISPLAY_CG_TIME=1
2 changes: 1 addition & 1 deletion scripts/test_bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ cat > config.toml <<EOF
ninja = false
[build]
rustc = "$(pwd)/../build/cg_clif"
rustc = "$(pwd)/../build/bin/cg_clif"
cargo = "$(rustup which cargo)"
full-bootstrap = true
local-rebuild = true
Expand Down
4 changes: 3 additions & 1 deletion src/bin/cg_clif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ impl rustc_driver::Callbacks for CraneliftPassesCallbacks {
.unwrap()
.parent()
.unwrap()
.join("sysroot"),
.parent()
.unwrap()
.to_owned(),
),
);
}
Expand Down

0 comments on commit cf3aa64

Please sign in to comment.