10 JOBS="$(getconf _NPROCESSORS_ONLN)"
17 printf 'ERROR: unknown architecture: %s\n' "$ARCH"
21 BUILD_TARGET="$ARCH-pc-solaris2.10"
24 # The illumos and the Solaris build both use the same GCC-level host triple,
25 # though different versions of GCC are used and with different configure
26 # options. To ensure as little accidental cross-pollination as possible, we
27 # build the illumos toolchain in a specific directory tree and just symlink the
28 # expected tools into /usr/local/bin at the end. We omit /usr/local/bin from
29 # PATH here for similar reasons.
31 PREFIX="/opt/illumos/$ARCH"
32 export PATH="$PREFIX/bin:/usr/bin:/bin:/usr/sbin:/sbin"
35 # NOTE: The compiler version selected here is more specific than might appear.
36 # GCC 7.X releases do not appear to cross-compile correctly for Solaris
37 # targets, at least insofar as they refuse to enable TLS in libstdc++. When
38 # changing the GCC version in future, one must carefully verify that TLS is
39 # enabled in all of the static libraries we intend to include in output
43 GCC_SUM='e30a6e52d10e1f27ed55104ad233c30bd1e99cfb5ff98ab022dc941edd1b2dd4'
44 GCC_BASE="gcc-$GCC_VERSION"
45 GCC_TAR="gcc-$GCC_VERSION.tar.xz"
46 GCC_URL="https://ftp.gnu.org/gnu/gcc/$GCC_BASE/$GCC_TAR"
48 SYSROOT_VER='20181213-de6af22ae73b-v1'
49 SYSROOT_SUM='ee792d956dfa6967453cebe9286a149143290d296a8ce4b8a91d36bea89f8112'
50 SYSROOT_TAR="illumos-sysroot-$SYSROOT_MACH-$SYSROOT_VER.tar.gz"
51 SYSROOT_URL='https://github.com/illumos/sysroot/releases/download/'
52 SYSROOT_URL+="$SYSROOT_VER/$SYSROOT_TAR"
53 SYSROOT_DIR="$PREFIX/sysroot"
55 BINUTILS_VERSION='2.25.1'
56 BINUTILS_SUM='b5b14added7d78a8d1ca70b5cb75fef57ce2197264f4f5835326b0df22ac9f22'
57 BINUTILS_BASE="binutils-$BINUTILS_VERSION"
58 BINUTILS_TAR="$BINUTILS_BASE.tar.bz2"
59 BINUTILS_URL="https://ftp.gnu.org/gnu/binutils/$BINUTILS_TAR"
68 if [[ -f "$file" ]]; then
69 if ! h="$(sha256sum "$file" | awk '{ print $1 }')"; then
70 printf 'ERROR: reading hash\n' >&2
74 if [[ "$h" == "$sum" ]]; then
78 printf 'WARNING: hash mismatch: %s != expected %s\n' \
83 printf 'Downloading: %s\n' "$url"
84 if ! curl -f -L -o "$file" "$url"; then
94 download_file "/tmp/$SYSROOT_TAR" "$SYSROOT_URL" "$SYSROOT_SUM"
95 mkdir -p "$SYSROOT_DIR"
97 tar -xzf "/tmp/$SYSROOT_TAR"
98 rm -f "/tmp/$SYSROOT_TAR"
102 download_file "/tmp/$BINUTILS_TAR" "$BINUTILS_URL" "$BINUTILS_SUM"
103 mkdir -p /ws/src/binutils
105 tar -xjf "/tmp/$BINUTILS_TAR"
106 rm -f "/tmp/$BINUTILS_TAR"
108 mkdir -p /ws/build/binutils
109 cd /ws/build/binutils
110 "/ws/src/binutils/$BINUTILS_BASE/configure" \
112 --target="$BUILD_TARGET" \
113 --program-prefix="$ARCH-illumos-" \
114 --with-sysroot="$SYSROOT_DIR"
122 rm -rf /ws/src/binutils /ws/build/binutils
126 download_file "/tmp/$GCC_TAR" "$GCC_URL" "$GCC_SUM"
129 tar -xJf "/tmp/$GCC_TAR"
130 rm -f "/tmp/$GCC_TAR"
132 mkdir -p /ws/build/gcc
134 export CFLAGS='-fPIC'
135 export CXXFLAGS='-fPIC'
136 export CXXFLAGS_FOR_TARGET='-fPIC'
137 export CFLAGS_FOR_TARGET='-fPIC'
138 "/ws/src/gcc/$GCC_BASE/configure" \
140 --target="$BUILD_TARGET" \
141 --program-prefix="$ARCH-illumos-" \
142 --with-sysroot="$SYSROOT_DIR" \
147 --disable-libquadmath \
150 --disable-libcilkrts \
152 --disable-libsanitizer \
153 --disable-libquadmath-support \
163 # Link toolchain commands into /usr/local/bin so that cmake and others
166 (cd "$PREFIX/bin" && ls -U) | grep "^$ARCH-illumos-" |
167 xargs -t -I% ln -s "$PREFIX/bin/%" '/usr/local/bin/'
170 rm -rf /ws/src/gcc /ws/build/gcc
174 printf 'ERROR: unknown phase "%s"\n' "$PHASE" >&2