]> git.lizzy.rs Git - rust.git/blob - src/ci/docker/dist-i586-gnu-i686-musl/build-musl.sh
change the format of the linked issue number
[rust.git] / src / ci / docker / dist-i586-gnu-i686-musl / build-musl.sh
1 #!/bin/sh
2 # Copyright 2016 The Rust Project Developers. See the COPYRIGHT
3 # file at the top-level directory of this distribution and at
4 # http://rust-lang.org/COPYRIGHT.
5 #
6 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9 # option. This file may not be copied, modified, or distributed
10 # except according to those terms.
11
12 set -ex
13
14 # We need to mitigate rust-lang/rust#34978 when compiling musl itself as well
15 export CFLAGS="-fPIC -Wa,-mrelax-relocations=no"
16 export CXXFLAGS="-Wa,-mrelax-relocations=no"
17
18 MUSL=musl-1.1.14
19 curl https://www.musl-libc.org/releases/$MUSL.tar.gz | tar xzf -
20 cd $MUSL
21 CFLAGS="$CFLAGS -m32" ./configure --prefix=/musl-i686 --disable-shared --target=i686
22 make -j10
23 make install
24 cd ..
25
26 # To build MUSL we're going to need a libunwind lying around, so acquire that
27 # here and build it.
28 curl -L https://github.com/llvm-mirror/llvm/archive/release_37.tar.gz | tar xzf -
29 curl -L https://github.com/llvm-mirror/libunwind/archive/release_37.tar.gz | tar xzf -
30
31 # Whoa what's this mysterious patch we're applying to libunwind! Why are we
32 # swapping the values of ESP/EBP in libunwind?!
33 #
34 # Discovered in #35599 it turns out that the vanilla build of libunwind is not
35 # suitable for unwinding 32-bit musl. After some investigation it ended up
36 # looking like the register values for ESP/EBP were indeed incorrect (swapped)
37 # in the source. Similar commits in libunwind (r280099 and r282589) have noticed
38 # this for other platforms, and we just need to realize it for musl linux as
39 # well.
40 #
41 # More technical info can be found at #35599
42 cd libunwind-release_37
43 patch -Np1 < /build/musl-libunwind-patch.patch
44 cd ..
45
46 mkdir libunwind-build
47 cd libunwind-build
48 CFLAGS="$CFLAGS -m32" CXXFLAGS="$CXXFLAGS -m32" cmake ../libunwind-release_37 \
49           -DLLVM_PATH=/build/llvm-release_37 \
50           -DLIBUNWIND_ENABLE_SHARED=0
51 make -j10
52 cp lib/libunwind.a /musl-i686/lib