Permalink
Newer
100755
119 lines (83 sloc)
2.86 KB
1
#! /bin/bash
2
3
PKG=rustc
4
VERSION=1.84.0
5
BUILD=0
6
7
PREFIX=/pkg/$PKG-$VERSION-$BUILD
8
9
set -xe
10
umask 022
11
12
TEMPFILES=/scratch/local2
13
if $(env | grep MXQ_SERVERID >/dev/null); then TEMPFILES=$TMPDIR ; fi
14
15
if [ -n "$TESTING" ]; then PREFIX=${TEMPFILES}/$PKG-$VERSION-$BUILD ; fi
16
17
BUILD_TMPDIR=${TEMPFILES}/$PKG-$VERSION-$BUILD.build.tmp
18
test -d $BUILD_TMPDIR && rm -rf $BUILD_TMPDIR
19
mkdir -p $BUILD_TMPDIR/home
20
export TMPDIR=$BUILD_TMPDIR
21
export HOME=$BUILD_TMPDIR/home
22
23
exec </dev/null
24
25
mkdir -p $PREFIX
26
cat >$PREFIX/profile <<-EOF
27
PATH=$PREFIX/bin:\$PATH
28
LD_LIBRARY_PATH=$PREFIX/lib:\$LD_LIBRARY_PATH
29
export PATH LD_LIBRARY_PATH
30
if [ -d /pkg/${PKG}-${VERSION}-${BUILD}/.compatlibs ]; then LD_LIBRARY_PATH=${PREFIX}/.compatlibs\${LD_LIBRARY_PATH:+:\$LD_LIBRARY_PATH} ; fi
31
EOF
32
. $PREFIX/profile
33
. /pkg/llvm-17.0.6-0/profile
34
35
export MAKEFLAGS="-j $(nproc)"
36
37
BUILDDIR=$PREFIX/build
38
39
mkdir -p $BUILDDIR
40
cd $BUILDDIR
41
42
test -e $PKG-$VERSION-src.tar.gz || wget https://static.rust-lang.org/dist/$PKG-$VERSION-src.tar.gz
43
test -d $PKG-$VERSION-src || tar xvf $PKG-$VERSION-src.tar.gz
44
cd $PKG-$VERSION-src
45
46
cat << EOF > config.toml
47
# see config.toml.example for more possible options
48
# https://github.com/rust-lang/rust/issues/135358
49
profile = "dist"
50
51
change-id = 133207
52
53
[llvm]
54
link-shared=true
55
56
# Do not download pre-built LLVM, instead either use the system
57
# LLVM or build LLVM from the shipped source.
58
download-ci-llvm = false
59
60
# use ninja
61
ninja = true
62
63
targets = "X86"
64
# When compiling LLVM, the experimental targets (WebAssembly
65
# and RISCV) are built by default - omit them
66
experimental-targets = ""
67
68
[build]
69
# omit HTML docs to save time and space (comment this to build them)
70
docs = false
71
72
# install cargo as well as rust
73
extended = true
74
75
# Use the source code shipped in the tarball for the dependencies.
76
# The combination of this and the "locked-deps" entry avoids downloading
77
# many crates from Internet, and makes the Rustc build more stable.
78
vendor = true
79
80
[install]
81
# Adjust the prefix for the desired destination
82
prefix = "$PREFIX"
83
sysconfdir = "etc"
84
85
# docdir is used even if the full awesome docs are not installed
86
docdir = "share/doc/rustc-${VERSION}"
87
88
[rust]
89
channel = "stable"
90
rpath = false
91
92
# Enable the same optimizations as the official upstream build.
93
codegen-units = 1
94
EOF
95
96
sed '/MirOpt/d' -i src/bootstrap/src/core/builder/mod.rs
97
98
export RUST_BACKTRACE=full
99
export RUSTFLAGS="$RUSTFLAGS -C link-args=-lffi" &&
100
python3 ./x.py build
101
102
python3 ./x.py install
103
104
cd ${BUILDDIR}
105
106
BINDGENVERS=0.28.0
107
108
test -e ${BUILDDIR}/cbindgen-${BINDGENVERS}.tar.gz || wget https://github.com/eqrion/cbindgen/archive/v${BINDGENVERS}/cbindgen-${BINDGENVERS}.tar.gz -O ${BUILDDIR}/cbindgen-${BINDGENVERS}.tar.gz
109
test -d cbindgen-${BINDGENVERS} || tar xvf ${BUILDDIR}/cbindgen-${BINDGENVERS}.tar.gz
110
111
cd cbindgen-${BINDGENVERS}
112
113
source ${PREFIX}/profile
114
115
cargo build --release
116
install -Dm755 target/release/cbindgen $PREFIX/bin
117
118
119
exit