]> git.lizzy.rs Git - rust.git/blob - src/ci/docker/scripts/musl-toolchain.sh
musl: update LLVM to 7
[rust.git] / src / ci / docker / scripts / musl-toolchain.sh
1 # Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 # file at the top-level directory of this distribution and at
3 # http://rust-lang.org/COPYRIGHT.
4 #
5 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 # option. This file may not be copied, modified, or distributed
9 # except according to those terms.
10
11 set -ex
12
13 hide_output() {
14   set +x
15   on_err="
16 echo ERROR: An error was encountered with the build.
17 cat /tmp/build.log
18 exit 1
19 "
20   trap "$on_err" ERR
21   bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
22   PING_LOOP_PID=$!
23   $@ &> /tmp/build.log
24   trap - ERR
25   kill $PING_LOOP_PID
26   rm /tmp/build.log
27   set -x
28 }
29
30 TARGET=$1
31 #ARCH=$1
32 #TARGET=linux-musl-$ARCH
33 ARCH=x86_64
34
35 OUTPUT=/usr/local
36 shift
37
38 git clone https://github.com/richfelker/musl-cross-make -b v0.9.7
39 cd musl-cross-make
40
41 hide_output make -j$(nproc) TARGET=$TARGET
42 hide_output make install TARGET=$TARGET OUTPUT=$OUTPUT
43
44 cd -
45
46 # Make musl binaries executable
47
48 ln -s $OUTPUT/$TARGET/lib/libc.so /lib/ld-musl-$ARCH.so.1
49 echo $OUTPUT/$TARGET/lib >> /etc/ld-musl-$ARCH.path
50
51
52 export CC=$TARGET-gcc
53 export CXX=$TARGET-g++
54
55 LLVM=70
56
57 # may have been downloaded in a previous run
58 if [ ! -d libunwind-release_$LLVM ]; then
59   curl -L https://github.com/llvm-mirror/llvm/archive/release_$LLVM.tar.gz | tar xzf -
60   curl -L https://github.com/llvm-mirror/libunwind/archive/release_$LLVM.tar.gz | tar xzf -
61 fi
62
63 mkdir libunwind-build
64 cd libunwind-build
65 cmake ../libunwind-release_$LLVM \
66           -DLLVM_PATH=/build/llvm-release_$LLVM \
67           -DLIBUNWIND_ENABLE_SHARED=0 \
68           -DCMAKE_C_COMPILER=$CC \
69           -DCMAKE_CXX_COMPILER=$CXX \
70           -DCMAKE_C_FLAGS="$CFLAGS" \
71           -DCMAKE_CXX_FLAGS="$CXXFLAGS"
72
73 hide_output make -j$(nproc)
74 cp lib/libunwind.a $OUTPUT/$TARGET/lib
75 cd - && rm -rf libunwind-build
76