forked from mneumann/rust-cross-dragonfly
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstage2-linux.sh
68 lines (52 loc) · 2 KB
/
stage2-linux.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh
if [ `uname -s` != "Linux" ]; then
echo "You have to run this on Linux!"
exit 1
fi
if [ ! -e "stage1-linux" ]; then
echo "stage1-linux does not exist!"
exit 1
fi
if [ ! -e "stage1-linux/install" ]; then
echo "stage1-linux/install does not exist!"
exit 1
fi
if [ ! -e "stage1-openbsd/libs" ]; then
echo "need stage1-openbsd/libs!"
exit 1
fi
TOP=`pwd`
RUST_PREFIX=${TOP}/stage1-linux/install
RUST_SRC=${TOP}/stage2-linux/rust
RUSTC=${RUST_PREFIX}/bin/rustc
TARGET=x86_64-unknown-openbsd
DF_LIB_DIR=${TOP}/stage1-openbsd/libs
RS_LIB_DIR=${TOP}/stage2-linux/rust-libs
export LD_LIBRARY_PATH=${RUST_PREFIX}/lib
mkdir -p ${TOP}/stage2-linux
mkdir -p ${TOP}/stage2-linux/rust-libs
if [ ! -e ${TOP}/stage2-linux/rust ]; then
cd stage2-linux
git clone --reference ${TOP}/stage1-linux/rust https://github.com/rust-lang/rust.git
cd ${TOP}
fi
cp ${TOP}/stage1-openbsd/llvmdeps.rs ${TOP}/stage2-linux/rust/src/librustc_llvm/
# XXX
export CFG_VERSION="0.12.0-pre-nightly"
export CFG_RELEASE="openbsd-cross"
export CFG_VER_HASH="hash"
export CFG_VER_DATE="`date`"
export CFG_COMPILER_HOST_TRIPLE="x86_64-unknown-openbsd"
export CFG_PREFIX="/usr/local"
RUST_LIBS="core libc alloc unicode collections rustrt rand sync std native arena rustuv debug log fmt_macros serialize term syntax flate time url uuid getopts regex test coretest glob graphviz num rustc_back semver rustc_llvm rbml rustc fourcc hexfloat regex_macros green rustdoc"
# compile rust libraries
for lib in $RUST_LIBS; do
if [ -e ${RS_LIB_DIR}/lib${lib}.rlib ]; then
echo "skipping $lib"
else
echo "compiling $lib"
${RUSTC} --target ${TARGET} ${RUST_FLAGS} --crate-type lib -L${DF_LIB_DIR} -L${DF_LIB_DIR}/llvm -L${RS_LIB_DIR} ${RUST_SRC}/src/lib${lib}/lib.rs -o ${RS_LIB_DIR}/lib${lib}.rlib
fi
done
${RUSTC} ${RUST_FLAGS} --emit obj -o ${TOP}/stage2-linux/driver.o --target ${TARGET} -L${DF_LIB_DIR} -L${RS_LIB_DIR} --cfg rustc ${RUST_SRC}/src/driver/driver.rs
tar cvzf ${TOP}/stage2-linux.tgz stage2-linux/*.o stage2-linux/rust-libs