Skip to content

Commit 9164653

Browse files
committed
Split config.sh and add support for copying the mingw runtime objects
1 parent 9384af4 commit 9164653

File tree

5 files changed

+35
-30
lines changed

5 files changed

+35
-30
lines changed

build.sh

+7
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,20 @@ else
4848
cargo build $oldbe
4949
fi
5050

51+
source scripts/ext_config.sh
52+
5153
rm -rf "$target_dir"
5254
mkdir "$target_dir"
5355
mkdir "$target_dir"/bin "$target_dir"/lib
5456
ln target/$CHANNEL/cg_clif{,_build_sysroot} "$target_dir"/bin
5557
ln target/$CHANNEL/*rustc_codegen_cranelift* "$target_dir"/lib
5658
ln rust-toolchain scripts/config.sh scripts/cargo.sh "$target_dir"
5759

60+
mkdir -p "$target_dir/lib/rustlib/$TARGET_TRIPLE/lib/"
61+
if [[ "$TARGET_TRIPLE" == "x86_64-pc-windows-gnu" ]]; then
62+
cp $(rustc --print sysroot)/lib/rustlib/$TARGET_TRIPLE/lib/*.o "$target_dir/lib/rustlib/$TARGET_TRIPLE/lib/"
63+
fi
64+
5865
if [[ "$build_sysroot" == "1" ]]; then
5966
echo "[BUILD] sysroot"
6067
export CG_CLIF_INCR_CACHE_DISABLED=1

build_sysroot/build_sysroot.sh

-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,5 @@ else
3636
fi
3737

3838
# Copy files to sysroot
39-
mkdir -p "$dir/lib/rustlib/$TARGET_TRIPLE/lib/"
4039
ln "target/$TARGET_TRIPLE/$sysroot_channel/deps/"* "$dir/lib/rustlib/$TARGET_TRIPLE/lib/"
4140
rm "$dir/lib/rustlib/$TARGET_TRIPLE/lib/"*.{rmeta,d}

scripts/config.sh

+1-28
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,6 @@ else
1212
exit 1
1313
fi
1414

15-
HOST_TRIPLE=$(rustc -vV | grep host | cut -d: -f2 | tr -d " ")
16-
TARGET_TRIPLE=$HOST_TRIPLE
17-
#TARGET_TRIPLE="x86_64-pc-windows-gnu"
18-
#TARGET_TRIPLE="aarch64-unknown-linux-gnu"
19-
20-
linker=''
21-
RUN_WRAPPER=''
22-
export JIT_SUPPORTED=1
23-
if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then
24-
export JIT_SUPPORTED=0
25-
if [[ "$TARGET_TRIPLE" == "aarch64-unknown-linux-gnu" ]]; then
26-
# We are cross-compiling for aarch64. Use the correct linker and run tests in qemu.
27-
linker='-Clinker=aarch64-linux-gnu-gcc'
28-
RUN_WRAPPER='qemu-aarch64 -L /usr/aarch64-linux-gnu'
29-
elif [[ "$TARGET_TRIPLE" == "x86_64-pc-windows-gnu" ]]; then
30-
# We are cross-compiling for Windows. Run tests in wine.
31-
RUN_WRAPPER='wine'
32-
else
33-
echo "Unknown non-native platform"
34-
fi
35-
fi
36-
3715
if echo "$RUSTC_WRAPPER" | grep sccache; then
3816
echo
3917
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)
4523

4624
export RUSTC=$dir"/bin/cg_clif"
4725

48-
if [ ! -z $linker ]; then
49-
export RUSTFLAGS=$linker" "$RUSTFLAGS
50-
fi
51-
5226
export RUSTDOCFLAGS=$linker' -Cpanic=abort -Zpanic-abort-tests '\
5327
'-Zcodegen-backend='$dir'/lib/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$dir
5428

5529
# FIXME remove once the atomic shim is gone
56-
if [[ $(uname) == 'Darwin' ]]; then
30+
if [[ "$unamestr" == 'Darwin' ]]; then
5731
export RUSTFLAGS="$RUSTFLAGS -Clink-arg=-undefined -Clink-arg=dynamic_lookup"
5832
fi
5933

6034
export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib:"$dir"/lib"
6135
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
62-

scripts/ext_config.sh

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Note to people running shellcheck: this file should only be sourced, not executed directly.
2+
3+
# Various env vars that should only be set for the build system but not for cargo.sh
4+
5+
set -e
6+
7+
export CG_CLIF_DISPLAY_CG_TIME=1
8+
9+
export HOST_TRIPLE=$(rustc -vV | grep host | cut -d: -f2 | tr -d " ")
10+
export TARGET_TRIPLE=${TARGET_TRIPLE:-$HOST_TRIPLE}
11+
12+
export RUN_WRAPPER=''
13+
export JIT_SUPPORTED=1
14+
if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then
15+
export JIT_SUPPORTED=0
16+
if [[ "$TARGET_TRIPLE" == "aarch64-unknown-linux-gnu" ]]; then
17+
# We are cross-compiling for aarch64. Use the correct linker and run tests in qemu.
18+
export RUSTFLAGS='-Clinker=aarch64-linux-gnu-gcc '$RUSTFLAGS
19+
export RUN_WRAPPER='qemu-aarch64 -L /usr/aarch64-linux-gnu'
20+
elif [[ "$TARGET_TRIPLE" == "x86_64-pc-windows-gnu" ]]; then
21+
# We are cross-compiling for Windows. Run tests in wine.
22+
export RUN_WRAPPER='wine'
23+
else
24+
echo "Unknown non-native platform"
25+
fi
26+
fi

test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -e
33

4-
export CG_CLIF_DISPLAY_CG_TIME=1
4+
source scripts/ext_config.sh
55

66
./build.sh --without-sysroot "$@"
77

0 commit comments

Comments
 (0)