From 9164653c10b7aa7cfea2b0556ca7c332e6df4a0b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 31 Jan 2021 13:08:07 +0100 Subject: [PATCH] Split config.sh and add support for copying the mingw runtime objects --- build.sh | 7 +++++++ build_sysroot/build_sysroot.sh | 1 - scripts/config.sh | 29 +---------------------------- scripts/ext_config.sh | 26 ++++++++++++++++++++++++++ test.sh | 2 +- 5 files changed, 35 insertions(+), 30 deletions(-) create mode 100644 scripts/ext_config.sh diff --git a/build.sh b/build.sh index 344e4295636..d688d365f16 100755 --- a/build.sh +++ b/build.sh @@ -48,6 +48,8 @@ else cargo build $oldbe fi +source scripts/ext_config.sh + rm -rf "$target_dir" mkdir "$target_dir" mkdir "$target_dir"/bin "$target_dir"/lib @@ -55,6 +57,11 @@ ln target/$CHANNEL/cg_clif{,_build_sysroot} "$target_dir"/bin ln target/$CHANNEL/*rustc_codegen_cranelift* "$target_dir"/lib ln rust-toolchain scripts/config.sh scripts/cargo.sh "$target_dir" +mkdir -p "$target_dir/lib/rustlib/$TARGET_TRIPLE/lib/" +if [[ "$TARGET_TRIPLE" == "x86_64-pc-windows-gnu" ]]; then + cp $(rustc --print sysroot)/lib/rustlib/$TARGET_TRIPLE/lib/*.o "$target_dir/lib/rustlib/$TARGET_TRIPLE/lib/" +fi + if [[ "$build_sysroot" == "1" ]]; then echo "[BUILD] sysroot" export CG_CLIF_INCR_CACHE_DISABLED=1 diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index ad2796f2e37..2785a289d95 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -36,6 +36,5 @@ else fi # Copy files to sysroot -mkdir -p "$dir/lib/rustlib/$TARGET_TRIPLE/lib/" ln "target/$TARGET_TRIPLE/$sysroot_channel/deps/"* "$dir/lib/rustlib/$TARGET_TRIPLE/lib/" rm "$dir/lib/rustlib/$TARGET_TRIPLE/lib/"*.{rmeta,d} diff --git a/scripts/config.sh b/scripts/config.sh index e2914b9bee8..834708aa9a6 100644 --- a/scripts/config.sh +++ b/scripts/config.sh @@ -12,28 +12,6 @@ else exit 1 fi -HOST_TRIPLE=$(rustc -vV | grep host | cut -d: -f2 | tr -d " ") -TARGET_TRIPLE=$HOST_TRIPLE -#TARGET_TRIPLE="x86_64-pc-windows-gnu" -#TARGET_TRIPLE="aarch64-unknown-linux-gnu" - -linker='' -RUN_WRAPPER='' -export JIT_SUPPORTED=1 -if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then - export JIT_SUPPORTED=0 - if [[ "$TARGET_TRIPLE" == "aarch64-unknown-linux-gnu" ]]; then - # We are cross-compiling for aarch64. Use the correct linker and run tests in qemu. - linker='-Clinker=aarch64-linux-gnu-gcc' - RUN_WRAPPER='qemu-aarch64 -L /usr/aarch64-linux-gnu' - elif [[ "$TARGET_TRIPLE" == "x86_64-pc-windows-gnu" ]]; then - # We are cross-compiling for Windows. Run tests in wine. - RUN_WRAPPER='wine' - else - echo "Unknown non-native platform" - fi -fi - if echo "$RUSTC_WRAPPER" | grep sccache; then echo echo -e "\x1b[1;93m=== Warning: Unset RUSTC_WRAPPER to prevent interference with sccache ===\x1b[0m" @@ -45,18 +23,13 @@ dir=$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd) export RUSTC=$dir"/bin/cg_clif" -if [ ! -z $linker ]; then - export RUSTFLAGS=$linker" "$RUSTFLAGS -fi - export RUSTDOCFLAGS=$linker' -Cpanic=abort -Zpanic-abort-tests '\ '-Zcodegen-backend='$dir'/lib/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$dir # FIXME remove once the atomic shim is gone -if [[ $(uname) == 'Darwin' ]]; then +if [[ "$unamestr" == 'Darwin' ]]; then export RUSTFLAGS="$RUSTFLAGS -Clink-arg=-undefined -Clink-arg=dynamic_lookup" fi export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib:"$dir"/lib" export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH - diff --git a/scripts/ext_config.sh b/scripts/ext_config.sh new file mode 100644 index 00000000000..eab41631e2b --- /dev/null +++ b/scripts/ext_config.sh @@ -0,0 +1,26 @@ +# Note to people running shellcheck: this file should only be sourced, not executed directly. + +# Various env vars that should only be set for the build system but not for cargo.sh + +set -e + +export CG_CLIF_DISPLAY_CG_TIME=1 + +export HOST_TRIPLE=$(rustc -vV | grep host | cut -d: -f2 | tr -d " ") +export TARGET_TRIPLE=${TARGET_TRIPLE:-$HOST_TRIPLE} + +export RUN_WRAPPER='' +export JIT_SUPPORTED=1 +if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then + export JIT_SUPPORTED=0 + if [[ "$TARGET_TRIPLE" == "aarch64-unknown-linux-gnu" ]]; then + # We are cross-compiling for aarch64. Use the correct linker and run tests in qemu. + export RUSTFLAGS='-Clinker=aarch64-linux-gnu-gcc '$RUSTFLAGS + export RUN_WRAPPER='qemu-aarch64 -L /usr/aarch64-linux-gnu' + elif [[ "$TARGET_TRIPLE" == "x86_64-pc-windows-gnu" ]]; then + # We are cross-compiling for Windows. Run tests in wine. + export RUN_WRAPPER='wine' + else + echo "Unknown non-native platform" + fi +fi diff --git a/test.sh b/test.sh index ffd795b83ef..4f3be076528 100755 --- a/test.sh +++ b/test.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -export CG_CLIF_DISPLAY_CG_TIME=1 +source scripts/ext_config.sh ./build.sh --without-sysroot "$@"