|
| 1 | +#!/bin/bash |
| 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 | +ARCH=$1 |
| 15 | +LIB_ARCH=$2 |
| 16 | +APT_ARCH=$3 |
| 17 | +BINUTILS=2.28.1 |
| 18 | +GCC=6.4.0 |
| 19 | + |
| 20 | +hide_output() { |
| 21 | + set +x |
| 22 | + on_err=" |
| 23 | +echo ERROR: An error was encountered with the build. |
| 24 | +cat /tmp/build.log |
| 25 | +exit 1 |
| 26 | +" |
| 27 | + trap "$on_err" ERR |
| 28 | + bash -c "while true; do sleep 30; echo \$(date) - building ...; done" & |
| 29 | + PING_LOOP_PID=$! |
| 30 | + $@ &> /tmp/build.log |
| 31 | + trap - ERR |
| 32 | + kill $PING_LOOP_PID |
| 33 | + set -x |
| 34 | +} |
| 35 | + |
| 36 | +# First up, build binutils |
| 37 | +mkdir binutils |
| 38 | +cd binutils |
| 39 | + |
| 40 | +curl https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS.tar.xz | tar xJf - |
| 41 | +mkdir binutils-build |
| 42 | +cd binutils-build |
| 43 | +hide_output ../binutils-$BINUTILS/configure --target=$ARCH-sun-solaris2.11 |
| 44 | +hide_output make -j10 |
| 45 | +hide_output make install |
| 46 | + |
| 47 | +cd ../.. |
| 48 | +rm -rf binutils |
| 49 | + |
| 50 | +# Next, download and install the relevant solaris packages |
| 51 | +mkdir solaris |
| 52 | +cd solaris |
| 53 | + |
| 54 | +dpkg --add-architecture $APT_ARCH |
| 55 | +apt-get update |
| 56 | +apt-get download \ |
| 57 | + libc:$APT_ARCH \ |
| 58 | + libc-dev:$APT_ARCH \ |
| 59 | + libm:$APT_ARCH \ |
| 60 | + libm-dev:$APT_ARCH \ |
| 61 | + libpthread:$APT_ARCH \ |
| 62 | + libpthread-dev:$APT_ARCH \ |
| 63 | + librt:$APT_ARCH \ |
| 64 | + librt-dev:$APT_ARCH \ |
| 65 | + system-crt:$APT_ARCH \ |
| 66 | + system-header:$APT_ARCH |
| 67 | + |
| 68 | +for deb in *$APT_ARCH.deb; do |
| 69 | + dpkg -x $deb . |
| 70 | +done |
| 71 | + |
| 72 | +mkdir /usr/local/$ARCH-sun-solaris2.11/usr |
| 73 | +mv usr/include /usr/local/$ARCH-sun-solaris2.11/usr/include |
| 74 | +mv usr/lib/$LIB_ARCH/* /usr/local/$ARCH-sun-solaris2.11/lib |
| 75 | +mv lib/$LIB_ARCH/* /usr/local/$ARCH-sun-solaris2.11/lib |
| 76 | + |
| 77 | +ln -s /usr/local/$ARCH-sun-solaris2.11/usr/include /usr/local/$ARCH-sun-solaris2.11/sys-include |
| 78 | +ln -s /usr/local/$ARCH-sun-solaris2.11/usr/include /usr/local/$ARCH-sun-solaris2.11/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=$ARCH-sun-solaris2.11 \ |
| 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 | + --with-sysroot=/usr/local/$ARCH-sun-solaris2.11 |
| 109 | + |
| 110 | +hide_output make -j10 |
| 111 | +hide_output make install |
| 112 | + |
| 113 | +cd ../.. |
| 114 | +rm -rf gcc |
0 commit comments