]> git.lizzy.rs Git - rust.git/blob - src/ci/docker/host-x86_64/dist-various-2/build-solaris-toolchain.sh
Auto merge of #95161 - JakobDegen:fix-early-otherwise-branch, r=wesleywiser
[rust.git] / src / ci / docker / host-x86_64 / dist-various-2 / build-solaris-toolchain.sh
1 #!/usr/bin/env bash
2
3 set -ex
4 source shared.sh
5
6 ARCH=$1
7 LIB_ARCH=$2
8 APT_ARCH=$3
9 MANUFACTURER=$4
10 BINUTILS=2.28.1
11 GCC=6.5.0
12
13 TARGET=${ARCH}-${MANUFACTURER}-solaris2.10
14
15 # First up, build binutils
16 mkdir binutils
17 cd binutils
18
19 curl https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS.tar.xz | tar xJf -
20 mkdir binutils-build
21 cd binutils-build
22 hide_output ../binutils-$BINUTILS/configure --target=$TARGET
23 hide_output make -j10
24 hide_output make install
25
26 cd ../..
27 rm -rf binutils
28
29 # Next, download and install the relevant solaris packages
30 mkdir solaris
31 cd solaris
32
33 dpkg --add-architecture $APT_ARCH
34 apt-get update
35 apt-get download $(apt-cache depends --recurse --no-replaces \
36   libc:$APT_ARCH                                             \
37   liblgrp-dev:$APT_ARCH                                      \
38   liblgrp:$APT_ARCH                                          \
39   libm-dev:$APT_ARCH                                         \
40   libpthread:$APT_ARCH                                       \
41   libresolv:$APT_ARCH                                        \
42   librt:$APT_ARCH                                            \
43   libsendfile-dev:$APT_ARCH                                  \
44   libsendfile:$APT_ARCH                                      \
45   libsocket:$APT_ARCH                                        \
46   system-crt:$APT_ARCH                                       \
47   system-header:$APT_ARCH                                    \
48   | grep "^\w")
49
50 for deb in *$APT_ARCH.deb; do
51   dpkg -x $deb .
52 done
53
54 # The -dev packages are not available from the apt repository we're using.
55 # However, those packages are just symlinks from *.so to *.so.<version>.
56 # This makes all those symlinks.
57 for lib in $(find -name '*.so.*'); do
58   target=${lib%.so.*}.so
59   [ -e $target ] || ln -s ${lib##*/} $target
60 done
61
62 # Remove Solaris 11 functions that are optionally used by libbacktrace.
63 # This is for Solaris 10 compatibility.
64 rm usr/include/link.h
65 patch -p0  << 'EOF'
66 --- usr/include/string.h
67 +++ usr/include/string10.h
68 @@ -93 +92,0 @@
69 -extern size_t strnlen(const char *, size_t);
70 EOF
71
72 mkdir                  /usr/local/$TARGET/usr
73 mv usr/include         /usr/local/$TARGET/usr/include
74 mv usr/lib/$LIB_ARCH/* /usr/local/$TARGET/lib
75 mv     lib/$LIB_ARCH/* /usr/local/$TARGET/lib
76
77 ln -s usr/include /usr/local/$TARGET/sys-include
78 ln -s usr/include /usr/local/$TARGET/include
79
80 cd ..
81 rm -rf solaris
82
83 # Finally, download and build gcc to target solaris
84 mkdir gcc
85 cd gcc
86
87 curl https://ftp.gnu.org/gnu/gcc/gcc-$GCC/gcc-$GCC.tar.xz | tar xJf -
88 cd gcc-$GCC
89
90 mkdir ../gcc-build
91 cd ../gcc-build
92 hide_output ../gcc-$GCC/configure \
93   --enable-languages=c,c++        \
94   --target=$TARGET                \
95   --with-gnu-as                   \
96   --with-gnu-ld                   \
97   --disable-multilib              \
98   --disable-nls                   \
99   --disable-libgomp               \
100   --disable-libquadmath           \
101   --disable-libssp                \
102   --disable-libvtv                \
103   --disable-libcilkrts            \
104   --disable-libada                \
105   --disable-libsanitizer          \
106   --disable-libquadmath-support   \
107   --disable-lto
108
109 hide_output make -j10
110 hide_output make install
111
112 cd ../..
113 rm -rf gcc