Skip to content

Commit

Permalink
build dist for x86_64-unknown-illumos
Browse files Browse the repository at this point in the history
This change adds the "x86_64-unknown-illumos" host triple to the
"dist-various-2" builder and sets things up to build the full set of
"dist" packages for illumos hosts so that illumos users can use "rustup"
to install packages.  It also adjusts the manifest builder to expect
complete toolchains for this platform.
  • Loading branch information
jclulow committed Apr 21, 2020
1 parent cff9a75 commit 320b996
Show file tree
Hide file tree
Showing 4 changed files with 214 additions and 24 deletions.
25 changes: 17 additions & 8 deletions src/ci/docker/dist-various-2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ RUN apt-get update && apt-get build-dep -y clang llvm && apt-get install -y --no
RUN apt-key adv --batch --yes --keyserver keyserver.ubuntu.com --recv-keys 74DA7924C5513486
RUN add-apt-repository -y 'deb http://apt.dilos.org/dilos dilos2 main'

COPY scripts/illumos-toolchain.sh /tmp/
RUN bash /tmp/illumos-toolchain.sh x86_64 sysroot
RUN bash /tmp/illumos-toolchain.sh x86_64 binutils
RUN bash /tmp/illumos-toolchain.sh x86_64 gcc

WORKDIR /build
COPY scripts/musl.sh /build
RUN env \
Expand Down Expand Up @@ -63,17 +68,19 @@ ENV \
AR_aarch64_fuchsia=aarch64-fuchsia-ar \
CC_aarch64_fuchsia=aarch64-fuchsia-clang \
CXX_aarch64_fuchsia=aarch64-fuchsia-clang++ \
AR_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-ar \
CC_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-gcc \
CXX_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-g++ \
AR_x86_64_sun_solaris=x86_64-sun-solaris2.10-ar \
CC_x86_64_sun_solaris=x86_64-sun-solaris2.10-gcc \
CXX_x86_64_sun_solaris=x86_64-sun-solaris2.10-g++ \
AR_sparcv9_sun_solaris=sparcv9-solaris-ar \
CC_sparcv9_sun_solaris=sparcv9-solaris-gcc \
CXX_sparcv9_sun_solaris=sparcv9-solaris-g++ \
AR_x86_64_sun_solaris=x86_64-solaris-ar \
CC_x86_64_sun_solaris=x86_64-solaris-gcc \
CXX_x86_64_sun_solaris=x86_64-solaris-g++ \
AR_x86_64_unknown_illumos=x86_64-illumos-ar \
CC_x86_64_unknown_illumos=x86_64-illumos-gcc \
CXX_x86_64_unknown_illumos=x86_64-illumos-g++ \
CC_armv7_unknown_linux_gnueabi=arm-linux-gnueabi-gcc-7 \
CXX_armv7_unknown_linux_gnueabi=arm-linux-gnueabi-g++-7 \
CC=gcc-7 \
CXX=g++-7

ENV CARGO_TARGET_X86_64_FUCHSIA_AR /usr/local/bin/llvm-ar
ENV CARGO_TARGET_X86_64_FUCHSIA_RUSTFLAGS \
-C link-arg=--sysroot=/usr/local/x86_64-fuchsia \
Expand All @@ -85,6 +92,8 @@ ENV CARGO_TARGET_AARCH64_FUCHSIA_RUSTFLAGS \
-C link-arg=-L/usr/local/aarch64-fuchsia/lib \
-C link-arg=-L/usr/local/lib/aarch64-fuchsia/lib

ENV HOSTS=x86_64-unknown-illumos

ENV TARGETS=x86_64-fuchsia
ENV TARGETS=$TARGETS,aarch64-fuchsia
ENV TARGETS=$TARGETS,wasm32-unknown-unknown
Expand All @@ -110,4 +119,4 @@ ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --disable-docs \
--set target.wasm32-wasi.wasi-root=/wasm32-wasi \
--musl-root-armv7=/musl-armv7

ENV SCRIPT python3 ../x.py dist --target $TARGETS
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS,$TARGETS
35 changes: 19 additions & 16 deletions src/ci/docker/dist-various-2/build-solaris-toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ cd binutils
curl https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS.tar.xz | tar xJf -
mkdir binutils-build
cd binutils-build
hide_output ../binutils-$BINUTILS/configure --target=$ARCH-sun-solaris2.10
hide_output ../binutils-$BINUTILS/configure \
--target=$ARCH-sun-solaris2.10 \
--program-prefix="$ARCH-solaris-"
hide_output make -j10
hide_output make install

Expand Down Expand Up @@ -74,21 +76,22 @@ cd gcc-$GCC

mkdir ../gcc-build
cd ../gcc-build
hide_output ../gcc-$GCC/configure \
--enable-languages=c,c++ \
--target=$ARCH-sun-solaris2.10 \
--with-gnu-as \
--with-gnu-ld \
--disable-multilib \
--disable-nls \
--disable-libgomp \
--disable-libquadmath \
--disable-libssp \
--disable-libvtv \
--disable-libcilkrts \
--disable-libada \
--disable-libsanitizer \
--disable-libquadmath-support \
hide_output ../gcc-$GCC/configure \
--enable-languages=c,c++ \
--target=$ARCH-sun-solaris2.10 \
--program-prefix="$ARCH-solaris-" \
--with-gnu-as \
--with-gnu-ld \
--disable-multilib \
--disable-nls \
--disable-libgomp \
--disable-libquadmath \
--disable-libssp \
--disable-libvtv \
--disable-libcilkrts \
--disable-libada \
--disable-libsanitizer \
--disable-libquadmath-support \
--disable-lto

hide_output make -j10
Expand Down
177 changes: 177 additions & 0 deletions src/ci/docker/scripts/illumos-toolchain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
#!/bin/bash

set -o errexit
set -o pipefail
set -o xtrace

ARCH="$1"
PHASE="$2"

JOBS="$(getconf _NPROCESSORS_ONLN)"

case "$ARCH" in
x86_64)
SYSROOT_MACH='i386'
;;
*)
printf 'ERROR: unknown architecture: %s\n' "$ARCH"
exit 1
esac

BUILD_TARGET="$ARCH-sun-solaris2.10"

#
# The illumos and the Solaris build both use the same GCC-level host triple,
# though different versions of GCC are used and with different configure
# options. To ensure as little accidental cross-pollination as possible, we
# build the illumos toolchain in a specific directory tree and just symlink the
# expected tools into /usr/local/bin at the end. We omit /usr/local/bin from
# PATH here for similar reasons.
#
PREFIX="/opt/illumos/$ARCH"
export PATH="$PREFIX/bin:/usr/bin:/bin:/usr/sbin:/sbin"

#
# NOTE: The compiler version selected here is more specific than might appear.
# GCC 7.X releases do not appear to cross-compile correctly for Solaris
# targets, at least insofar as they refuse to enable TLS in libstdc++. When
# changing the GCC version in future, one must carefully verify that TLS is
# enabled in all of the static libraries we intend to include in output
# binaries.
#
GCC_VERSION='8.4.0'
GCC_MD5='bb815a8e3b7be43c4a26fa89dbbd9795'
GCC_BASE="gcc-$GCC_VERSION"
GCC_TAR="gcc-$GCC_VERSION.tar.xz"
GCC_URL="https://ftp.gnu.org/gnu/gcc/$GCC_BASE/$GCC_TAR"

SYSROOT_VER='20181213-de6af22ae73b-v1'
SYSROOT_MD5='23462f7f5297f390803d27c424c32ad6'
SYSROOT_TAR="illumos-sysroot-$SYSROOT_MACH-$SYSROOT_VER.tar.gz"
SYSROOT_URL='https://github.com/illumos/sysroot/releases/download/'
SYSROOT_URL+="$SYSROOT_VER/$SYSROOT_TAR"
SYSROOT_DIR="$PREFIX/sysroot"

BINUTILS_VERSION='2.25.1'
BINUTILS_MD5='ac493a78de4fee895961d025b7905be4'
BINUTILS_BASE="binutils-$BINUTILS_VERSION"
BINUTILS_TAR="$BINUTILS_BASE.tar.bz2"
BINUTILS_URL="https://ftp.gnu.org/gnu/binutils/$BINUTILS_TAR"


download_file() {
local file="$1"
local url="$2"
local md5="$3"

while :; do
if [[ -f "$file" ]]; then
if ! h="$(md5sum "$file" | awk '{ print $1 }')"; then
printf 'ERROR: reading hash\n' >&2
exit 1
fi

if [[ "$h" == "$md5" ]]; then
return 0
fi

printf 'WARNING: hash mismatch: %s != expected %s\n' \
"$h" "$md5" >&2
rm -f "$file"
fi

printf 'Downloading: %s\n' "$url"
if ! curl -f -L -o "$file" "$url"; then
rm -f "$file"
sleep 1
fi
done
}


case "$PHASE" in
sysroot)
download_file "/tmp/$SYSROOT_TAR" "$SYSROOT_URL" "$SYSROOT_MD5"
mkdir -p "$SYSROOT_DIR"
cd "$SYSROOT_DIR"
tar -xzf "/tmp/$SYSROOT_TAR"
rm -f "/tmp/$SYSROOT_TAR"
;;

binutils)
download_file "/tmp/$BINUTILS_TAR" "$BINUTILS_URL" "$BINUTILS_MD5"
mkdir -p /ws/src/binutils
cd /ws/src/binutils
tar -xjf "/tmp/$BINUTILS_TAR"
rm -f "/tmp/$BINUTILS_TAR"

mkdir -p /ws/build/binutils
cd /ws/build/binutils
"/ws/src/binutils/$BINUTILS_BASE/configure" \
--prefix="$PREFIX" \
--target="$BUILD_TARGET" \
--program-prefix="$ARCH-illumos-" \
--with-sysroot="$SYSROOT_DIR"

make -j "$JOBS"

mkdir -p "$PREFIX"
make install

cd /
rm -rf /ws/src/binutils /ws/build/binutils
;;

gcc)
download_file "/tmp/$GCC_TAR" "$GCC_URL" "$GCC_MD5"
mkdir -p /ws/src/gcc
cd /ws/src/gcc
tar -xJf "/tmp/$GCC_TAR"
rm -f "/tmp/$GCC_TAR"

mkdir -p /ws/build/gcc
cd /ws/build/gcc
export CFLAGS='-fPIC'
export CXXFLAGS='-fPIC'
export CXXFLAGS_FOR_TARGET='-fPIC'
export CFLAGS_FOR_TARGET='-fPIC'
"/ws/src/gcc/$GCC_BASE/configure" \
--prefix="$PREFIX" \
--target="$BUILD_TARGET" \
--program-prefix="$ARCH-illumos-" \
--with-sysroot="$SYSROOT_DIR" \
--with-gnu-as \
--with-gnu-ld \
--disable-nls \
--disable-libgomp \
--disable-libquadmath \
--disable-libssp \
--disable-libvtv \
--disable-libcilkrts \
--disable-libada \
--disable-libsanitizer \
--disable-libquadmath-support \
--disable-shared \
--enable-tls

make -j "$JOBS"

mkdir -p "$PREFIX"
make install

#
# Link toolchain commands into /usr/local/bin so that cmake and others
# can find them:
#
(cd "$PREFIX/bin" && ls -U) | grep "^$ARCH-illumos-" |
xargs -t -I% ln -s "$PREFIX/bin/%" '/usr/local/bin/'

cd /
rm -rf /ws/src/gcc /ws/build/gcc
;;

*)
printf 'ERROR: unknown phase "%s"\n' "$PHASE" >&2
exit 100
;;
esac
1 change: 1 addition & 0 deletions src/tools/build-manifest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ static HOSTS: &[&str] = &[
"x86_64-pc-windows-gnu",
"x86_64-pc-windows-msvc",
"x86_64-unknown-freebsd",
"x86_64-unknown-illumos",
"x86_64-unknown-linux-gnu",
"x86_64-unknown-linux-musl",
"x86_64-unknown-netbsd",
Expand Down

0 comments on commit 320b996

Please sign in to comment.