mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 18:23:49 +00:00
Merge commit '09ce29d0591a21e1abae22eac4d41ffd32993af8' into subtree-update_cg_gcc_2023-10-25
This commit is contained in:
parent
9f4f90b19a
commit
ff57d7007f
2
cargo.sh
2
cargo.sh
@ -12,7 +12,7 @@ TOOLCHAIN=$(cat rust-toolchain | grep channel | sed 's/channel = "\(.*\)"/\1/')
|
|||||||
|
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
|
|
||||||
if [[ $(rustc -V) != $(rustc +${TOOLCHAIN} -V) ]]; then
|
if [[ $(${RUSTC} -V) != $(${RUSTC} +${TOOLCHAIN} -V) ]]; then
|
||||||
echo "rustc_codegen_gcc is build for $(rustc +${TOOLCHAIN} -V) but the default rustc version is $(rustc -V)."
|
echo "rustc_codegen_gcc is build for $(rustc +${TOOLCHAIN} -V) but the default rustc version is $(rustc -V)."
|
||||||
echo "Using $(rustc +${TOOLCHAIN} -V)."
|
echo "Using $(rustc +${TOOLCHAIN} -V)."
|
||||||
fi
|
fi
|
||||||
|
35
config.sh
35
config.sh
@ -4,19 +4,25 @@ export CARGO_INCREMENTAL=0
|
|||||||
|
|
||||||
if [ -f ./gcc_path ]; then
|
if [ -f ./gcc_path ]; then
|
||||||
export GCC_PATH=$(cat gcc_path)
|
export GCC_PATH=$(cat gcc_path)
|
||||||
|
elif (( $use_system_gcc == 1 )); then
|
||||||
|
echo 'Using system GCC'
|
||||||
else
|
else
|
||||||
echo 'Please put the path to your custom build of libgccjit in the file `gcc_path`, see Readme.md for details'
|
echo 'Please put the path to your custom build of libgccjit in the file `gcc_path`, see Readme.md for details'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$RUSTC" ]]; then
|
||||||
|
export RUSTC="rustc"
|
||||||
|
fi
|
||||||
|
|
||||||
unamestr=`uname`
|
unamestr=`uname`
|
||||||
if [[ "$unamestr" == 'Linux' ]]; then
|
if [[ "$unamestr" == 'Linux' ]]; then
|
||||||
dylib_ext='so'
|
dylib_ext='so'
|
||||||
elif [[ "$unamestr" == 'Darwin' ]]; then
|
elif [[ "$unamestr" == 'Darwin' ]]; then
|
||||||
dylib_ext='dylib'
|
dylib_ext='dylib'
|
||||||
else
|
else
|
||||||
echo "Unsupported os"
|
echo "Unsupported os"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
HOST_TRIPLE=$(rustc -vV | grep host | cut -d: -f2 | tr -d " ")
|
HOST_TRIPLE=$(rustc -vV | grep host | cut -d: -f2 | tr -d " ")
|
||||||
@ -44,17 +50,30 @@ if [[ ! -v FAT_LTO ]]; then
|
|||||||
disable_lto_flags='-Clto=off'
|
disable_lto_flags='-Clto=off'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export RUSTFLAGS="$CG_RUSTFLAGS $linker -Csymbol-mangling-version=v0 -Cdebuginfo=2 $disable_lto_flags -Zcodegen-backend=$(pwd)/target/${CHANNEL:-debug}/librustc_codegen_gcc.$dylib_ext --sysroot $(pwd)/build_sysroot/sysroot $TEST_FLAGS"
|
if [[ -z "$BUILTIN_BACKEND" ]]; then
|
||||||
|
export RUSTFLAGS="$CG_RUSTFLAGS $linker -Csymbol-mangling-version=v0 -Cdebuginfo=2 $disable_lto_flags -Zcodegen-backend=$(pwd)/target/${CHANNEL:-debug}/librustc_codegen_gcc.$dylib_ext --sysroot $(pwd)/build_sysroot/sysroot $TEST_FLAGS"
|
||||||
|
else
|
||||||
|
export RUSTFLAGS="$CG_RUSTFLAGS $linker -Csymbol-mangling-version=v0 -Cdebuginfo=2 $disable_lto_flags -Zcodegen-backend=gcc $TEST_FLAGS -Cpanic=abort"
|
||||||
|
fi
|
||||||
|
|
||||||
# FIXME(antoyo): remove once the atomic shim is gone
|
# FIXME(antoyo): remove once the atomic shim is gone
|
||||||
if [[ unamestr == 'Darwin' ]]; then
|
if [[ unamestr == 'Darwin' ]]; then
|
||||||
export RUSTFLAGS="$RUSTFLAGS -Clink-arg=-undefined -Clink-arg=dynamic_lookup"
|
export RUSTFLAGS="$RUSTFLAGS -Clink-arg=-undefined -Clink-arg=dynamic_lookup"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out"
|
if [[ -z "$cargo_target_dir" ]]; then
|
||||||
|
RUST_CMD="$RUSTC $RUSTFLAGS -L crate=target/out --out-dir target/out"
|
||||||
|
cargo_target_dir="target/out"
|
||||||
|
else
|
||||||
|
RUST_CMD="$RUSTC $RUSTFLAGS -L crate=$cargo_target_dir --out-dir $cargo_target_dir"
|
||||||
|
fi
|
||||||
export RUSTC_LOG=warn # display metadata load errors
|
export RUSTC_LOG=warn # display metadata load errors
|
||||||
|
|
||||||
export LD_LIBRARY_PATH="$(pwd)/target/out:$(pwd)/build_sysroot/sysroot/lib/rustlib/$TARGET_TRIPLE/lib:$GCC_PATH"
|
export LD_LIBRARY_PATH="$(pwd)/target/out:$(pwd)/build_sysroot/sysroot/lib/rustlib/$TARGET_TRIPLE/lib"
|
||||||
|
if [[ ! -z "$:$GCC_PATH" ]]; then
|
||||||
|
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$GCC_PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
|
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
|
||||||
# NOTE: To avoid the -fno-inline errors, use /opt/gcc/bin/gcc instead of cc.
|
# NOTE: To avoid the -fno-inline errors, use /opt/gcc/bin/gcc instead of cc.
|
||||||
# To do so, add a symlink for cc to /opt/gcc/bin/gcc in our PATH.
|
# To do so, add a symlink for cc to /opt/gcc/bin/gcc in our PATH.
|
||||||
|
114
test.sh
114
test.sh
@ -5,16 +5,6 @@
|
|||||||
set -e
|
set -e
|
||||||
#set -x
|
#set -x
|
||||||
|
|
||||||
if [ -f ./gcc_path ]; then
|
|
||||||
export GCC_PATH=$(cat gcc_path)
|
|
||||||
else
|
|
||||||
echo 'Please put the path to your custom build of libgccjit in the file `gcc_path`, see Readme.md for details'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
export LD_LIBRARY_PATH="$GCC_PATH"
|
|
||||||
export LIBRARY_PATH="$GCC_PATH"
|
|
||||||
|
|
||||||
flags=
|
flags=
|
||||||
gcc_master_branch=1
|
gcc_master_branch=1
|
||||||
channel="debug"
|
channel="debug"
|
||||||
@ -22,12 +12,18 @@ funcs=()
|
|||||||
build_only=0
|
build_only=0
|
||||||
nb_parts=0
|
nb_parts=0
|
||||||
current_part=0
|
current_part=0
|
||||||
|
use_system_gcc=0
|
||||||
|
use_backend=0
|
||||||
|
cargo_target_dir=""
|
||||||
|
|
||||||
|
export CHANNEL='debug'
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
--release)
|
--release)
|
||||||
codegen_channel=release
|
codegen_channel=release
|
||||||
channel="release"
|
channel="release"
|
||||||
|
export CHANNEL='release'
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--release-sysroot)
|
--release-sysroot)
|
||||||
@ -111,6 +107,22 @@ while [[ $# -gt 0 ]]; do
|
|||||||
build_only=1
|
build_only=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
"--use-system-gcc")
|
||||||
|
use_system_gcc=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
"--use-backend")
|
||||||
|
use_backend=1
|
||||||
|
shift
|
||||||
|
export BUILTIN_BACKEND=$1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
"--out-dir")
|
||||||
|
shift
|
||||||
|
export CARGO_TARGET_DIR=$1
|
||||||
|
cargo_target_dir=$1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
"--nb-parts")
|
"--nb-parts")
|
||||||
shift
|
shift
|
||||||
nb_parts=$1
|
nb_parts=$1
|
||||||
@ -128,13 +140,25 @@ while [[ $# -gt 0 ]]; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ $channel == "release" ]]; then
|
if [ -f ./gcc_path ]; then
|
||||||
export CHANNEL='release'
|
export GCC_PATH=$(cat gcc_path)
|
||||||
CARGO_INCREMENTAL=1 cargo rustc --release $flags
|
elif (( $use_system_gcc == 1 )); then
|
||||||
|
echo 'Using system GCC'
|
||||||
else
|
else
|
||||||
echo $LD_LIBRARY_PATH
|
echo 'Please put the path to your custom build of libgccjit in the file `gcc_path`, see Readme.md for details'
|
||||||
export CHANNEL='debug'
|
exit 1
|
||||||
cargo rustc $flags
|
fi
|
||||||
|
|
||||||
|
export LD_LIBRARY_PATH="$GCC_PATH"
|
||||||
|
export LIBRARY_PATH="$GCC_PATH"
|
||||||
|
|
||||||
|
if [[ $use_backend == 0 ]]; then
|
||||||
|
if [[ $channel == "release" ]]; then
|
||||||
|
CARGO_INCREMENTAL=1 cargo rustc --release $flags
|
||||||
|
else
|
||||||
|
echo $LD_LIBRARY_PATH
|
||||||
|
cargo rustc $flags
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (( $build_only == 1 )); then
|
if (( $build_only == 1 )); then
|
||||||
@ -145,24 +169,26 @@ fi
|
|||||||
source config.sh
|
source config.sh
|
||||||
|
|
||||||
function clean() {
|
function clean() {
|
||||||
rm -r target/out || true
|
rm -r $cargo_target_dir || true
|
||||||
mkdir -p target/out/gccjit
|
mkdir -p $cargo_target_dir/gccjit
|
||||||
}
|
}
|
||||||
|
|
||||||
function mini_tests() {
|
function mini_tests() {
|
||||||
echo "[BUILD] mini_core"
|
echo "[BUILD] mini_core"
|
||||||
crate_types="lib,dylib"
|
crate_types="lib,dylib"
|
||||||
|
|
||||||
if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then
|
if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then
|
||||||
crate_types="lib"
|
crate_types="lib"
|
||||||
fi
|
fi
|
||||||
$RUSTC example/mini_core.rs --crate-name mini_core --crate-type $crate_types --target $TARGET_TRIPLE
|
|
||||||
|
$RUST_CMD example/mini_core.rs --crate-name mini_core --crate-type $crate_types --target $TARGET_TRIPLE
|
||||||
|
|
||||||
echo "[BUILD] example"
|
echo "[BUILD] example"
|
||||||
$RUSTC example/example.rs --crate-type lib --target $TARGET_TRIPLE
|
$RUST_CMD example/example.rs --crate-type lib --target $TARGET_TRIPLE
|
||||||
|
|
||||||
echo "[AOT] mini_core_hello_world"
|
echo "[AOT] mini_core_hello_world"
|
||||||
$RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target $TARGET_TRIPLE
|
$RUST_CMD example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target $TARGET_TRIPLE
|
||||||
$RUN_WRAPPER ./target/out/mini_core_hello_world abc bcd
|
$RUN_WRAPPER $cargo_target_dir/mini_core_hello_world abc bcd
|
||||||
}
|
}
|
||||||
|
|
||||||
function build_sysroot() {
|
function build_sysroot() {
|
||||||
@ -189,42 +215,42 @@ function run_in_vm() {
|
|||||||
|
|
||||||
function std_tests() {
|
function std_tests() {
|
||||||
echo "[AOT] arbitrary_self_types_pointers_and_wrappers"
|
echo "[AOT] arbitrary_self_types_pointers_and_wrappers"
|
||||||
$RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target $TARGET_TRIPLE
|
$RUST_CMD example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target $TARGET_TRIPLE
|
||||||
$RUN_WRAPPER ./target/out/arbitrary_self_types_pointers_and_wrappers
|
$RUN_WRAPPER $cargo_target_dir/arbitrary_self_types_pointers_and_wrappers
|
||||||
|
|
||||||
echo "[AOT] alloc_system"
|
echo "[AOT] alloc_system"
|
||||||
$RUSTC example/alloc_system.rs --crate-type lib --target "$TARGET_TRIPLE"
|
$RUST_CMD example/alloc_system.rs --crate-type lib --target "$TARGET_TRIPLE"
|
||||||
|
|
||||||
# FIXME: doesn't work on m68k.
|
# FIXME: doesn't work on m68k.
|
||||||
if [[ "$HOST_TRIPLE" == "$TARGET_TRIPLE" ]]; then
|
if [[ "$HOST_TRIPLE" == "$TARGET_TRIPLE" ]]; then
|
||||||
echo "[AOT] alloc_example"
|
echo "[AOT] alloc_example"
|
||||||
$RUSTC example/alloc_example.rs --crate-type bin --target $TARGET_TRIPLE
|
$RUST_CMD example/alloc_example.rs --crate-type bin --target $TARGET_TRIPLE
|
||||||
$RUN_WRAPPER ./target/out/alloc_example
|
$RUN_WRAPPER $cargo_target_dir/alloc_example
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[AOT] dst_field_align"
|
echo "[AOT] dst_field_align"
|
||||||
# FIXME(antoyo): Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed.
|
# FIXME(antoyo): Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed.
|
||||||
$RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target $TARGET_TRIPLE
|
$RUST_CMD example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target $TARGET_TRIPLE
|
||||||
$RUN_WRAPPER ./target/out/dst_field_align || (echo $?; false)
|
$RUN_WRAPPER $cargo_target_dir/dst_field_align || (echo $?; false)
|
||||||
|
|
||||||
echo "[AOT] std_example"
|
echo "[AOT] std_example"
|
||||||
std_flags="--cfg feature=\"master\""
|
std_flags="--cfg feature=\"master\""
|
||||||
if (( $gcc_master_branch == 0 )); then
|
if (( $gcc_master_branch == 0 )); then
|
||||||
std_flags=""
|
std_flags=""
|
||||||
fi
|
fi
|
||||||
$RUSTC example/std_example.rs --crate-type bin --target $TARGET_TRIPLE $std_flags
|
$RUST_CMD example/std_example.rs --crate-type bin --target $TARGET_TRIPLE $std_flags
|
||||||
$RUN_WRAPPER ./target/out/std_example --target $TARGET_TRIPLE
|
$RUN_WRAPPER $cargo_target_dir/std_example --target $TARGET_TRIPLE
|
||||||
|
|
||||||
echo "[AOT] subslice-patterns-const-eval"
|
echo "[AOT] subslice-patterns-const-eval"
|
||||||
$RUSTC example/subslice-patterns-const-eval.rs --crate-type bin $TEST_FLAGS --target $TARGET_TRIPLE
|
$RUST_CMD example/subslice-patterns-const-eval.rs --crate-type bin $TEST_FLAGS --target $TARGET_TRIPLE
|
||||||
$RUN_WRAPPER ./target/out/subslice-patterns-const-eval
|
$RUN_WRAPPER $cargo_target_dir/subslice-patterns-const-eval
|
||||||
|
|
||||||
echo "[AOT] track-caller-attribute"
|
echo "[AOT] track-caller-attribute"
|
||||||
$RUSTC example/track-caller-attribute.rs --crate-type bin $TEST_FLAGS --target $TARGET_TRIPLE
|
$RUST_CMD example/track-caller-attribute.rs --crate-type bin $TEST_FLAGS --target $TARGET_TRIPLE
|
||||||
$RUN_WRAPPER ./target/out/track-caller-attribute
|
$RUN_WRAPPER $cargo_target_dir/track-caller-attribute
|
||||||
|
|
||||||
echo "[BUILD] mod_bench"
|
echo "[BUILD] mod_bench"
|
||||||
$RUSTC example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE
|
$RUST_CMD example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_rustc() {
|
function setup_rustc() {
|
||||||
@ -233,7 +259,7 @@ function setup_rustc() {
|
|||||||
git clone https://github.com/rust-lang/rust.git || true
|
git clone https://github.com/rust-lang/rust.git || true
|
||||||
cd rust
|
cd rust
|
||||||
git fetch
|
git fetch
|
||||||
git checkout $(rustc -V | cut -d' ' -f3 | tr -d '(')
|
git checkout $($RUSTC -V | cut -d' ' -f3 | tr -d '(')
|
||||||
export RUSTFLAGS=
|
export RUSTFLAGS=
|
||||||
|
|
||||||
rm config.toml || true
|
rm config.toml || true
|
||||||
@ -258,8 +284,8 @@ llvm-filecheck = "`which FileCheck-10 || which FileCheck-11 || which FileCheck-1
|
|||||||
download-ci-llvm = false
|
download-ci-llvm = false
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
rustc -V | cut -d' ' -f3 | tr -d '('
|
$RUSTC -V | cut -d' ' -f3 | tr -d '('
|
||||||
git checkout $(rustc -V | cut -d' ' -f3 | tr -d '(') tests
|
git checkout $($RUSTC -V | cut -d' ' -f3 | tr -d '(') tests
|
||||||
}
|
}
|
||||||
|
|
||||||
function asm_tests() {
|
function asm_tests() {
|
||||||
@ -286,17 +312,17 @@ function test_libcore() {
|
|||||||
#echo "[BENCH COMPILE] mod_bench"
|
#echo "[BENCH COMPILE] mod_bench"
|
||||||
|
|
||||||
#COMPILE_MOD_BENCH_INLINE="$RUSTC example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -O --crate-name mod_bench_inline"
|
#COMPILE_MOD_BENCH_INLINE="$RUSTC example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -O --crate-name mod_bench_inline"
|
||||||
#COMPILE_MOD_BENCH_LLVM_0="rustc example/mod_bench.rs --crate-type bin -Copt-level=0 -o target/out/mod_bench_llvm_0 -Cpanic=abort"
|
#COMPILE_MOD_BENCH_LLVM_0="rustc example/mod_bench.rs --crate-type bin -Copt-level=0 -o $cargo_target_dir/mod_bench_llvm_0 -Cpanic=abort"
|
||||||
#COMPILE_MOD_BENCH_LLVM_1="rustc example/mod_bench.rs --crate-type bin -Copt-level=1 -o target/out/mod_bench_llvm_1 -Cpanic=abort"
|
#COMPILE_MOD_BENCH_LLVM_1="rustc example/mod_bench.rs --crate-type bin -Copt-level=1 -o $cargo_target_dir/mod_bench_llvm_1 -Cpanic=abort"
|
||||||
#COMPILE_MOD_BENCH_LLVM_2="rustc example/mod_bench.rs --crate-type bin -Copt-level=2 -o target/out/mod_bench_llvm_2 -Cpanic=abort"
|
#COMPILE_MOD_BENCH_LLVM_2="rustc example/mod_bench.rs --crate-type bin -Copt-level=2 -o $cargo_target_dir/mod_bench_llvm_2 -Cpanic=abort"
|
||||||
#COMPILE_MOD_BENCH_LLVM_3="rustc example/mod_bench.rs --crate-type bin -Copt-level=3 -o target/out/mod_bench_llvm_3 -Cpanic=abort"
|
#COMPILE_MOD_BENCH_LLVM_3="rustc example/mod_bench.rs --crate-type bin -Copt-level=3 -o $cargo_target_dir/mod_bench_llvm_3 -Cpanic=abort"
|
||||||
|
|
||||||
## Use 100 runs, because a single compilations doesn't take more than ~150ms, so it isn't very slow
|
## Use 100 runs, because a single compilations doesn't take more than ~150ms, so it isn't very slow
|
||||||
#hyperfine --runs ${COMPILE_RUNS:-100} "$COMPILE_MOD_BENCH_INLINE" "$COMPILE_MOD_BENCH_LLVM_0" "$COMPILE_MOD_BENCH_LLVM_1" "$COMPILE_MOD_BENCH_LLVM_2" "$COMPILE_MOD_BENCH_LLVM_3"
|
#hyperfine --runs ${COMPILE_RUNS:-100} "$COMPILE_MOD_BENCH_INLINE" "$COMPILE_MOD_BENCH_LLVM_0" "$COMPILE_MOD_BENCH_LLVM_1" "$COMPILE_MOD_BENCH_LLVM_2" "$COMPILE_MOD_BENCH_LLVM_3"
|
||||||
|
|
||||||
#echo
|
#echo
|
||||||
#echo "[BENCH RUN] mod_bench"
|
#echo "[BENCH RUN] mod_bench"
|
||||||
#hyperfine --runs ${RUN_RUNS:-10} ./target/out/mod_bench{,_inline} ./target/out/mod_bench_llvm_*
|
#hyperfine --runs ${RUN_RUNS:-10} $cargo_target_dir/mod_bench{,_inline} $cargo_target_dir/mod_bench_llvm_*
|
||||||
|
|
||||||
function extended_rand_tests() {
|
function extended_rand_tests() {
|
||||||
if (( $gcc_master_branch == 0 )); then
|
if (( $gcc_master_branch == 0 )); then
|
||||||
|
Loading…
Reference in New Issue
Block a user