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.
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.
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"
19 curl https://www.musl-libc.org/releases/$MUSL.tar.gz | tar xzf -
22 CFLAGS="$CFLAGS -m32" \
23 ./configure --prefix=/musl-i686 --disable-shared \
25 make AR=ar RANLIB=ranlib -j10
29 # To build MUSL we're going to need a libunwind lying around, so acquire that
31 curl -L https://github.com/llvm-mirror/llvm/archive/release_37.tar.gz | tar xzf -
32 curl -L https://github.com/llvm-mirror/libunwind/archive/release_37.tar.gz | tar xzf -
34 # Whoa what's this mysterious patch we're applying to libunwind! Why are we
35 # swapping the values of ESP/EBP in libunwind?!
37 # Discovered in #35599 it turns out that the vanilla build of libunwind is not
38 # suitable for unwinding 32-bit musl. After some investigation it ended up
39 # looking like the register values for ESP/EBP were indeed incorrect (swapped)
40 # in the source. Similar commits in libunwind (r280099 and r282589) have noticed
41 # this for other platforms, and we just need to realize it for musl linux as
44 # More technical info can be found at #35599
45 cd libunwind-release_37
46 patch -Np1 < /build/musl-libunwind-patch.patch
51 CFLAGS="$CFLAGS -m32" CXXFLAGS="$CXXFLAGS -m32" cmake ../libunwind-release_37 \
52 -DLLVM_PATH=/build/llvm-release_37 \
53 -DLIBUNWIND_ENABLE_SHARED=0
55 cp lib/libunwind.a /musl-i686/lib