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 creates a new Docker image, "dist-x86_64-illumos", 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 18, 2020
1 parent cff9a75 commit 092af47
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ jobs:
- dist-x86_64-apple
- dist-x86_64-apple-alt
- dist-x86_64-freebsd
- dist-x86_64-illumos
- dist-x86_64-linux
- dist-x86_64-linux-alt
- dist-x86_64-mingw
Expand Down Expand Up @@ -426,6 +427,9 @@ jobs:
- name: dist-x86_64-freebsd
os: ubuntu-latest-xl
env: {}
- name: dist-x86_64-illumos
os: ubuntu-latest-xl
env: {}
- name: dist-x86_64-linux
os: ubuntu-latest-xl
env: {}
Expand Down
1 change: 1 addition & 0 deletions src/ci/azure-pipelines/auto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
dist-powerpc64le-linux: {}
dist-s390x-linux: {}
dist-x86_64-freebsd: {}
dist-x86_64-illumos: {}
dist-x86_64-musl: {}
dist-x86_64-netbsd: {}
i686-gnu: {}
Expand Down
33 changes: 33 additions & 0 deletions src/ci/docker/dist-x86_64-illumos/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM ubuntu:18.04

# Enable source repositories, which are disabled by default on Ubuntu >= 18.04
RUN sed -i 's/^# deb-src/deb-src/' /etc/apt/sources.list

COPY scripts/cross-apt-packages.sh /tmp/
RUN bash /tmp/cross-apt-packages.sh

# Required for cross-build gcc
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libgmp-dev \
libmpfr-dev \
libmpc-dev

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

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

ENV \
AR_x86_64_unknown_illumos=x86_64-sun-solaris2.10-ar \
CC_x86_64_unknown_illumos=x86_64-sun-solaris2.10-gcc \
CXX_x86_64_unknown_illumos=x86_64-sun-solaris2.10-g++

ENV HOSTS=x86_64-unknown-illumos

ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS
148 changes: 148 additions & 0 deletions src/ci/docker/scripts/illumos-toolchain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
#!/bin/bash

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

JOBS="$(getconf _NPROCESSORS_ONLN)"

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

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

#
# 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='/ws/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 "$2" 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" \
--target="$BUILD_TARGET" \
--with-sysroot="$SYSROOT_DIR"

make -j "$JOBS"
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" \
--target="$BUILD_TARGET" \
--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"
make install

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

*)
printf 'ERROR: unknown phase "%s"\n' "$1" >&2
exit 100
;;
esac
4 changes: 4 additions & 0 deletions src/ci/github-actions/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ jobs:
- dist-x86_64-apple
- dist-x86_64-apple-alt
- dist-x86_64-freebsd
- dist-x86_64-illumos
- dist-x86_64-linux
- dist-x86_64-linux-alt
- dist-x86_64-mingw
Expand Down Expand Up @@ -427,6 +428,9 @@ jobs:
- name: dist-x86_64-freebsd
<<: *job-linux-xl

- name: dist-x86_64-illumos
<<: *job-linux-xl

- name: dist-x86_64-linux
<<: *job-linux-xl

Expand Down
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 092af47

Please sign in to comment.