Skip to content

Commit

Permalink
Add x86_64-unknown-illumos target.
Browse files Browse the repository at this point in the history
Also reduces the size of the Solaris images by ~80MB.
  • Loading branch information
Alexhuszagh committed Jul 6, 2022
1 parent 3dc0d1f commit b77037d
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ jobs:
- { target: x86_64-unknown-netbsd, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1 }
- { target: sparcv9-sun-solaris, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1 }
- { target: x86_64-sun-solaris, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1 }
- { target: x86_64-unknown-illumos, os: ubuntu-latest, cpp: 1, dylib: 1, std: 1 }
- { target: thumbv6m-none-eabi, os: ubuntu-latest, std: 1 }
- { target: thumbv7em-none-eabi, os: ubuntu-latest, std: 1 }
- { target: thumbv7em-none-eabihf, os: ubuntu-latest, std: 1 }
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Added

- #913 - added the `x86_64-unknown-illumos` target.
- #905 - added `qemu-runner` for musl images, allowing use of native or emulated runners.
- #905 - added qemu emulation to `i586-unknown-linux-gnu`, `i686-unknown-linux-musl`, and `i586-unknown-linux-gnu`, so they can run on an `x86` CPU, rather than an `x86_64` CPU.
- #900 - add the option to skip copying build artifacts back to host when using remote cross via `CROSS_REMOTE_SKIP_BUILD_ARTIFACTS`.
Expand Down
20 changes: 20 additions & 0 deletions docker/Dockerfile.x86_64-unknown-illumos
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ubuntu:20.04

COPY common.sh lib.sh /
RUN /common.sh

COPY cmake.sh /
RUN /cmake.sh

COPY xargo.sh /
RUN /xargo.sh

COPY illumos.sh /
RUN /illumos.sh x86_64

ENV PATH=$PATH:/usr/local/x86_64-unknown-illumos/bin/ \
CARGO_TARGET_X86_64_UNKNOWN_ILLUMOS_LINKER=x86_64-unknown-illumos-gcc \
AR_x86_64_unknown_illumos=x86_64-unknown-illumos-ar \
CC_x86_64_unknown_illumos=x86_64-unknown-illumos-gcc \
CXX_x86_64_unknown_illumos=x86_64-unknown-illumos-g++ \
BINDGEN_EXTRA_CLANG_ARGS_sparcv9_sun_solaris="--sysroot=/usr/local/x86_64-unknown-illumos/sysroot"
3 changes: 1 addition & 2 deletions docker/freebsd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ main() {

local td
td="$(mktemp -d)"
pushd "${td}"

mkdir "${td}"/{binutils,gcc}{,-build} "${td}/freebsd"

Expand All @@ -70,8 +71,6 @@ main() {
curl --retry 3 -sSfL "https://ftp.gnu.org/gnu/gcc/gcc-${gcc}/gcc-${gcc}.tar.gz" -O
tar -C "${td}/gcc" --strip-components=1 -xf "gcc-${gcc}.tar.gz"

pushd "${td}"

cd gcc
sed -i -e 's/ftp:/https:/g' ./contrib/download_prerequisites
./contrib/download_prerequisites
Expand Down
138 changes: 138 additions & 0 deletions docker/illumos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#!/usr/bin/env bash
# This script is based off of rust-lang/rust's implementation.
# https://github.com/rust-lang/rust/blob/47f291ec2d9d6e4820cca517e69b3efddec40c20/src/ci/docker/scripts/illumos-toolchain.sh

set -x
set -euo pipefail

# shellcheck disable=SC1091
. lib.sh

main() {
local arch="${1}"
local binutils=2.28.1
local gcc=8.4.0
local target="${arch}-unknown-illumos"
local build_target="${arch}-pc-solaris2.10"
local prefix="/usr/local/${target}"
local sysroot_dir="${prefix}/sysroot"
local real_sum

install_packages ca-certificates \
curl \
g++ \
make \
wget \
xz-utils

local td
td="$(mktemp -d)"
pushd "${td}"

mkdir "${td}"/{binutils,gcc}{,-build} "${td}/illumos"

local binutils_file="binutils-${binutils}.tar.xz"
local binutils_sum="16328a906e55a3c633854beec8e9e255a639b366436470b4f6245eb0d2fde942"
curl --retry 3 -sSfL "https://ftp.gnu.org/gnu/binutils/${binutils_file}" -O
real_sum=$(sha256sum "${binutils_file}" | cut -d ' ' -f 1)
if [[ "${binutils_sum}" != "${real_sum}" ]]; then
echo "Error: invalid hash for binutils." >&2
exit 1
fi
tar -C "${td}/binutils" --strip-components=1 -xJf "${binutils_file}"

local gcc_file="gcc-${gcc}.tar.xz"
local gcc_sum="e30a6e52d10e1f27ed55104ad233c30bd1e99cfb5ff98ab022dc941edd1b2dd4"
curl --retry 3 -sSfL "https://ftp.gnu.org/gnu/gcc/gcc-${gcc}/${gcc_file}" -O
real_sum=$(sha256sum "${gcc_file}" | cut -d ' ' -f 1)
if [[ "${gcc_sum}" != "${real_sum}" ]]; then
echo "Error: invalid hash for gcc." >&2
exit 1
fi
tar -C "${td}/gcc" --strip-components=1 -xJf "${gcc_file}"

pushd gcc
sed -i -e 's/ftp:/https:/g' ./contrib/download_prerequisites
./contrib/download_prerequisites
popd

local mach
case "${arch}" in
x86_64)
mach='i386'
;;
*)
echo "ERROR: unknown architecture: ${arch}" >&2
exit 1
;;
esac

local sysroot_version="20181213-de6af22ae73b-v1"
local sysroot_file="illumos-sysroot-${mach}-${sysroot_version}.tar.gz"
local sysroot_repo="https://github.com/illumos/sysroot"
local sysroot_sum="ee792d956dfa6967453cebe9286a149143290d296a8ce4b8a91d36bea89f8112"
curl --retry 3 -sSfL "${sysroot_repo}/releases/download/${sysroot_version}/${sysroot_file}" -O
real_sum=$(sha256sum "${sysroot_file}" | cut -d ' ' -f 1)
if [[ "${sysroot_sum}" != "${real_sum}" ]]; then
echo "Error: invalid hash for illumos sysroot." >&2
exit 1
fi
mkdir -p "${sysroot_dir}"
pushd "${sysroot_dir}"
tar -xzf "${td}/${sysroot_file}"
popd

mkdir -p "${prefix}"
pushd binutils-build
../binutils/configure \
--target="${build_target}" \
--prefix="${prefix}" \
--program-prefix="${target}-" \
--with-sysroot="${sysroot_dir}"
make "-j$(nproc)"
make install
popd

# note: solaris2.10 is obsolete, so we can't upgrade to GCC 10 till then.
# for gcc 9.4.0, need `--enable-obsolete`.
export CFLAGS='-fPIC'
export CXXFLAGS='-fPIC'
export CXXFLAGS_FOR_TARGET='-fPIC'
export CFLAGS_FOR_TARGET='-fPIC'
mkdir -p "${prefix}"
pushd gcc-build
../gcc/configure \
--prefix="${prefix}" \
--target="${build_target}" \
--program-prefix="${target}-" \
--with-sysroot="${sysroot_dir}" \
--enable-languages=c,c++ \
--disable-libada \
--disable-libcilkrts \
--disable-libgomp \
--disable-libquadmath \
--disable-libquadmath-support \
--disable-libsanitizer \
--disable-libssp \
--disable-libvtv \
--disable-lto \
--disable-multilib \
--disable-shared \
--disable-nls \
--enable-tls \
--with-gnu-as \
--with-gnu-ld
make "-j$(nproc)"
make install
popd

# clean up
popd

purge_packages

rm -rf "${td}"
rm "${0}"
}

main "${@}"
3 changes: 1 addition & 2 deletions docker/solaris.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ main() {

local td
td="$(mktemp -d)"
pushd "${td}"

mkdir "${td}"/{binutils,gcc}{,-build} "${td}/solaris"

Expand All @@ -34,8 +35,6 @@ main() {
curl --retry 3 -sSfL "https://ftp.gnu.org/gnu/gcc/gcc-${gcc}/gcc-${gcc}.tar.xz" -O
tar -C "${td}/gcc" --strip-components=1 -xJf "gcc-${gcc}.tar.xz"

pushd "${td}"

cd gcc
sed -i -e 's/ftp:/https:/g' ./contrib/download_prerequisites
./contrib/download_prerequisites
Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ impl Target {
self.triple().contains("solaris")
}

fn is_illumos(&self) -> bool {
self.triple().contains("illumos")
}

fn is_android(&self) -> bool {
self.triple().contains("android")
}
Expand All @@ -219,6 +223,7 @@ impl Target {
|| self.is_bare_metal()
|| self.is_bsd()
|| self.is_solaris()
|| self.is_illumos()
|| !self.is_builtin()
|| self.is_windows()
|| self.is_emscripten()
Expand Down

0 comments on commit b77037d

Please sign in to comment.