1 # This script runs `musl-cross-make` to prepare C toolchain (Binutils, GCC, musl itself)
2 # and builds static libunwind that we distribute for static target.
4 # Versions of the toolchain components are configurable in `musl-cross-make/Makefile` and
5 # musl unlike GLIBC is forward compatible so upgrading it shouldn't break old distributions.
6 # Right now we have: Binutils 2.27, GCC 6.3.0, musl 1.1.18
12 echo ERROR: An error was encountered with the build.
17 bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
27 TARGET=$ARCH-linux-musl
32 # Ancient binutils versions don't understand debug symbols produced by more recent tools.
33 # Apparently applying `-fPIC` everywhere allows them to link successfully.
34 export CFLAGS="-fPIC $CFLAGS"
36 git clone https://github.com/richfelker/musl-cross-make -b v0.9.7
39 hide_output make -j$(nproc) TARGET=$TARGET
40 hide_output make install TARGET=$TARGET OUTPUT=$OUTPUT
44 # Install musl library to make binaries executable
45 ln -s $OUTPUT/$TARGET/lib/libc.so /lib/ld-musl-$ARCH.so.1
46 echo $OUTPUT/$TARGET/lib >> /etc/ld-musl-$ARCH.path
50 export CXX=$TARGET-g++
54 # may have been downloaded in a previous run
55 if [ ! -d libunwind-release_$LLVM ]; then
56 curl -L https://github.com/llvm-mirror/llvm/archive/release_$LLVM.tar.gz | tar xzf -
57 curl -L https://github.com/llvm-mirror/libunwind/archive/release_$LLVM.tar.gz | tar xzf -
60 # fixme(mati865): Replace it with https://github.com/rust-lang/rust/pull/59089
63 cmake ../libunwind-release_$LLVM \
64 -DLLVM_PATH=/build/llvm-release_$LLVM \
65 -DLIBUNWIND_ENABLE_SHARED=0 \
66 -DCMAKE_C_COMPILER=$CC \
67 -DCMAKE_CXX_COMPILER=$CXX \
68 -DCMAKE_C_FLAGS="$CFLAGS" \
69 -DCMAKE_CXX_FLAGS="$CXXFLAGS"
71 hide_output make -j$(nproc)
72 cp lib/libunwind.a $OUTPUT/$TARGET/lib
73 cd - && rm -rf libunwind-build