39
39
40
40
cd $MUSL
41
41
./configure --disable-shared --prefix=/musl-$TAG $@
42
- hide_output make -j$( nproc)
42
+ if [ " $TAG " = " i686" ]; then
43
+ hide_output make -j$( nproc) AR=ar RANLIB=ranlib
44
+ else
45
+ hide_output make -j$( nproc)
46
+ fi
43
47
hide_output make install
44
48
hide_output make clean
45
49
@@ -50,6 +54,37 @@ LLVM=39
50
54
if [ ! -d libunwind-release_$LLVM ]; then
51
55
curl -L https://github.com/llvm-mirror/llvm/archive/release_$LLVM .tar.gz | tar xzf -
52
56
curl -L https://github.com/llvm-mirror/libunwind/archive/release_$LLVM .tar.gz | tar xzf -
57
+ # Whoa what's this mysterious patch we're applying to libunwind! Why are we
58
+ # swapping the values of ESP/EBP in libunwind?!
59
+ #
60
+ # Discovered in #35599 it turns out that the vanilla build of libunwind is not
61
+ # suitable for unwinding i686 musl. After some investigation it ended up
62
+ # looking like the register values for ESP/EBP were indeed incorrect (swapped)
63
+ # in the source. Similar commits in libunwind (r280099 and r282589) have noticed
64
+ # this for other platforms, and we just need to realize it for musl linux as
65
+ # well.
66
+ #
67
+ # More technical info can be found at #35599
68
+ cd libunwind-release_$LLVM
69
+ patch -Np1 << EOF
70
+ diff --git a/include/libunwind.h b/include/libunwind.h
71
+ index c5b9633..1360eb2 100644
72
+ --- a/include/libunwind.h
73
+ +++ b/include/libunwind.h
74
+ @@ -151,8 +151,8 @@ enum {
75
+ UNW_X86_ECX = 1,
76
+ UNW_X86_EDX = 2,
77
+ UNW_X86_EBX = 3,
78
+ - UNW_X86_EBP = 4,
79
+ - UNW_X86_ESP = 5,
80
+ + UNW_X86_ESP = 4,
81
+ + UNW_X86_EBP = 5,
82
+ UNW_X86_ESI = 6,
83
+ UNW_X86_EDI = 7
84
+ };
85
+ fi
86
+ EOF
87
+ cd ..
53
88
fi
54
89
55
90
mkdir libunwind-build
0 commit comments