Skip to content

Commit 80fe86f

Browse files
committed
Add build environment for Solaris
This can be used to build rust-std. The dilos illumos distribution was chosen, because illumos is free software as opposed to Oracle Solaris and dilos is the only illumos distribution that supports x86_64 and sparcv9 at the same level.
1 parent 61bad30 commit 80fe86f

File tree

3 files changed

+145
-0
lines changed

3 files changed

+145
-0
lines changed

src/ci/docker/dist-solaris/Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM ubuntu:16.04
2+
3+
COPY scripts/cross-apt-packages.sh /scripts/
4+
RUN sh /scripts/cross-apt-packages.sh
5+
6+
RUN apt-get install -y --no-install-recommends \
7+
software-properties-common libgmp-dev libmpfr-dev libmpc-dev libisl-dev
8+
RUN apt-key adv --batch --yes --keyserver keyserver.ubuntu.com --recv-keys 74DA7924C5513486
9+
RUN add-apt-repository -y 'deb http://apt.dilos.org/dilos dilos2-testing main'
10+
11+
COPY dist-solaris/build-toolchain.sh /tmp/
12+
RUN /tmp/build-toolchain.sh x86_64 amd64 solaris-i386
13+
RUN /tmp/build-toolchain.sh sparcv9 sparcv9 solaris-sparc
14+
15+
COPY scripts/sccache.sh /scripts/
16+
RUN sh /scripts/sccache.sh
17+
18+
ENV \
19+
AR_sparcv9_sun_solaris=sparcv9-sun-solaris2.11-ar \
20+
CC_sparcv9_sun_solaris=sparcv9-sun-solaris2.11-sysroot \
21+
CXX_sparcv9_sun_solaris=sparcv9-sun-solaris2.11-g++ \
22+
AR_x86_64_sun_solaris=x86_64-sun-solaris2.11-ar \
23+
CC_x86_64_sun_solaris=x86_64-sun-solaris2.11-sysroot \
24+
CXX_x86_64_sun_solaris=x86_64-sun-solaris2.11-g++
25+
26+
ENV TARGETS=sparcv9-sun-solaris,x86_64-sun-solaris
27+
28+
ENV RUST_CONFIGURE_ARGS --target=$TARGETS --enable-extended
29+
ENV SCRIPT python2.7 ../x.py dist --target $TARGETS
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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

src/tools/build-manifest/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,15 @@ static TARGETS: &'static [&'static str] = &[
8383
"powerpc64le-unknown-linux-gnu",
8484
"s390x-unknown-linux-gnu",
8585
"sparc64-unknown-linux-gnu",
86+
"sparcv9-sun-solaris",
8687
"wasm32-unknown-emscripten",
8788
"x86_64-linux-android",
8889
"x86_64-apple-darwin",
8990
"x86_64-apple-ios",
9091
"x86_64-pc-windows-gnu",
9192
"x86_64-pc-windows-msvc",
9293
"x86_64-rumprun-netbsd",
94+
"x86_64-sun-solaris",
9395
"x86_64-unknown-freebsd",
9496
"x86_64-unknown-fuchsia",
9597
"x86_64-unknown-linux-gnu",

0 commit comments

Comments
 (0)