]> git.proxmox.com Git - rustc.git/blob - src/ci/docker/scripts/musl.sh
New upstream version 1.29.0+dfsg1
[rustc.git] / src / ci / docker / scripts / musl.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 TAG=$1
31 shift
32
33 export CFLAGS="-fPIC $CFLAGS"
34
35 # FIXME: remove the patch when upate to 1.1.20
36 MUSL=musl-1.1.19
37
38 # may have been downloaded in a previous run
39 if [ ! -d $MUSL ]; then
40 curl https://www.musl-libc.org/releases/$MUSL.tar.gz | tar xzf -
41 # Patch to fix https://github.com/rust-lang/rust/issues/48967
42 cd $MUSL && \
43 curl "https://git.musl-libc.org/cgit/musl/patch/?id=610c5a8524c3d6cd3ac5a5f1231422e7648a3791" |\
44 patch -p1 && \
45 cd -
46 fi
47
48 cd $MUSL
49 ./configure --enable-optimize --enable-debug --disable-shared --prefix=/musl-$TAG $@
50 if [ "$TAG" = "i586" -o "$TAG" = "i686" ]; then
51 hide_output make -j$(nproc) AR=ar RANLIB=ranlib
52 else
53 hide_output make -j$(nproc)
54 fi
55 hide_output make install
56 hide_output make clean
57
58 cd ..
59
60 LLVM=60
61
62 # may have been downloaded in a previous run
63 if [ ! -d libunwind-release_$LLVM ]; then
64 curl -L https://github.com/llvm-mirror/llvm/archive/release_$LLVM.tar.gz | tar xzf -
65 curl -L https://github.com/llvm-mirror/libunwind/archive/release_$LLVM.tar.gz | tar xzf -
66 fi
67
68 mkdir libunwind-build
69 cd libunwind-build
70 cmake ../libunwind-release_$LLVM \
71 -DLLVM_PATH=/build/llvm-release_$LLVM \
72 -DLIBUNWIND_ENABLE_SHARED=0 \
73 -DCMAKE_C_COMPILER=$CC \
74 -DCMAKE_CXX_COMPILER=$CXX \
75 -DCMAKE_C_FLAGS="$CFLAGS" \
76 -DCMAKE_CXX_FLAGS="$CXXFLAGS"
77
78 hide_output make -j$(nproc)
79 cp lib/libunwind.a /musl-$TAG/lib
80 cd ../ && rm -rf libunwind-build