Skip to content

Commit

Permalink
Auto merge of #138 - bgermann:master, r=japaric
Browse files Browse the repository at this point in the history
Add Solaris targets

Closes #134.
  • Loading branch information
homunkulus committed Oct 20, 2017
2 parents 4c5f6b0 + 02c7b81 commit 359c3bb
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 3 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,14 @@ matrix:

# BSD
- env: TARGET=i686-unknown-freebsd DYLIB=1 STD=1 OPENSSL=0.7.17
- env: TARGET=x86_64-unknown-dragonfly DYLIB=1 OPENSSL=0.5.5
- env: TARGET=x86_64-unknown-dragonfly DYLIB=1 OPENSSL=0.5.5
- env: TARGET=x86_64-unknown-freebsd DYLIB=1 STD=1 OPENSSL=0.5.5
- env: TARGET=x86_64-unknown-netbsd DYLIB=1 STD=1 OPENSSL=0.7.17

# Solaris
- env: TARGET=sparcv9-sun-solaris DYLIB=1 STD=1 OPENSSL=0.7.17
- env: TARGET=x86_64-sun-solaris DYLIB=1 STD=1 OPENSSL=0.7.17

# Windows
- env: TARGET=x86_64-pc-windows-gnu CPP=1 STD=1 RUN=1
- env: TARGET=i686-pc-windows-gnu CPP=1 STD=1 RUN=1
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,20 +212,22 @@ worst, "hang" (never terminate).
| `powerpc64le-unknown-linux-gnu` | 2.19 | 4.8.2 | 1.0.2k || 2.7.1 ||
| `s390x-unknown-linux-gnu` | 2.23 | 5.3.1 | 1.0.2k || 2.8.0 | |
| `sparc64-unknown-linux-gnu` [2] | 2.23 | 5.3.1 | 1.0.2k || 2.8.0 ||
| `sparcv9-sun-solaris` [1] | 2.11 | 5.3.0 | 1.0.2k | | N/A | |
| `thumbv6m-none-eabi` [3] | 2.2.0 | 5.3.1 | N/A | | N/A | |
| `thumbv7em-none-eabi` [3] | 2.2.0 | 5.3.1 | N/A | | N/A | |
| `thumbv7em-none-eabihf` [3] | 2.2.0 | 5.3.1 | N/A | | N/A | |
| `thumbv7m-none-eabi` [3] | 2.2.0 | 5.3.1 | N/A | | N/A | |
| `wasm32-unknown-emscripten` [4] | 1.1.15 | 1.37.13 | N/A || N/A ||
| `x86_64-linux-android` | N/A | 4.9 | 1.0.2k || N/A | |
| `x86_64-pc-windows-gnu` | N/A | 6.2.0 | N/A || N/A ||
| `x86_64-sun-solaris` [1] | 2.11 | 5.3.0 | 1.0.2k | | N/A | |
| `x86_64-unknown-dragonfly` [1] [2] | 4.6.0 | 5.3.0 | 1.0.2k | | N/A ||
| `x86_64-unknown-freebsd` [1] | 10.2 | 5.3.0 | 1.0.2k | | N/A | |
| `x86_64-unknown-linux-gnu` | 2.15 | 4.6.2 | 1.0.2k || N/A ||
| `x86_64-unknown-linux-musl` | 1.1.15 | 5.3.1 | 1.0.2k | | N/A ||
| `x86_64-unknown-netbsd`[1] | 7.0 | 5.3.0 | 1.0.2k | | N/A | |

[1] For *BSD targets, the libc column indicates the OS release version from
[1] For *BSD and Solaris targets, the libc column indicates the OS release version from
where libc was extracted.

[2] No `std` component available as of 2017-01-10
Expand Down
126 changes: 126 additions & 0 deletions docker/solaris.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
set -ex

main() {
local arch=$1

local binutils=2.25.1 \
gcc=5.3.0 \
target=$arch-sun-solaris2.11

local dependencies=(
bzip2
ca-certificates
curl
g++
make
software-properties-common
wget
xz-utils
)

apt-get update
local purge_list=()
for dep in ${dependencies[@]}; do
if ! dpkg -L $dep; then
apt-get install --no-install-recommends -y $dep
purge_list+=( $dep )
fi
done

local td=$(mktemp -d)

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

curl https://ftp.gnu.org/gnu/binutils/binutils-$binutils.tar.bz2 | \
tar -C $td/binutils --strip-components=1 -xj

curl https://ftp.gnu.org/gnu/gcc/gcc-$gcc/gcc-$gcc.tar.bz2 | \
tar -C $td/gcc --strip-components=1 -xj

pushd $td

cd gcc
./contrib/download_prerequisites
cd ..

local apt_arch=
local lib_arch=
case $arch in
x86_64)
apt_arch=solaris-i386
lib_arch=amd64
;;
sparcv9)
apt_arch=solaris-sparc
lib_arch=sparcv9
;;
esac

apt-key adv --batch --yes --keyserver keyserver.ubuntu.com --recv-keys 74DA7924C5513486
add-apt-repository -y 'deb http://apt.dilos.org/dilos dilos2-testing main'
dpkg --add-architecture $apt_arch
apt-get update
apt-get download $(apt-cache depends --recurse --no-replaces \
libc-dev:$apt_arch \
libdl-dev:$apt_arch \
libm-dev:$apt_arch \
libnsl-dev:$apt_arch \
libpthread-dev:$apt_arch \
libresolv-dev:$apt_arch \
librt-dev:$apt_arch \
libsocket-dev:$apt_arch \
system-crt:$apt_arch \
system-header:$apt_arch \
| grep "^\w")

for deb in *$apt_arch.deb; do
dpkg -x $deb $td/solaris
done

cd binutils-build
../binutils/configure \
--target=$target
nice make -j$(nproc)
make install
cd ..

local destdir=/usr/local/$target
mkdir $destdir/usr
cp -r $td/solaris/usr/include $destdir/usr
mv $td/solaris/usr/lib/$lib_arch/* $destdir/lib
mv $td/solaris/lib/$lib_arch/* $destdir/lib

ln -s usr/include $destdir/sys-include
ln -s usr/include $destdir/include

cd gcc-build
../gcc/configure \
--disable-libada \
--disable-libcilkrts \
--disable-libgomp \
--disable-libquadmath \
--disable-libquadmath-support \
--disable-libsanitizer \
--disable-libssp \
--disable-libvtv \
--disable-lto \
--disable-multilib \
--disable-nls \
--enable-languages=c,c++ \
--with-gnu-as \
--with-gnu-ld \
--target=$target
nice make -j$(nproc)
make install
cd ..

# clean up
popd

apt-get purge --auto-remove -y ${purge_list[@]}

rm -rf $td
rm $0
}

main "${@}"
23 changes: 23 additions & 0 deletions docker/sparcv9-sun-solaris/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM ubuntu:16.04

RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
cmake \
gcc \
libc6-dev \
make \
pkg-config

COPY xargo.sh /
RUN bash /xargo.sh

COPY solaris.sh openssl.sh /
RUN bash /solaris.sh sparcv9 && \
bash /openssl.sh solaris64-sparcv9-gcc sparcv9-sun-solaris2.11-

ENV CARGO_TARGET_SPARCV9_SUN_SOLARIS_LINKER=sparcv9-sun-solaris2.11-gcc \
CC_sparcv9_sun_solaris=sparcv9-sun-solaris2.11-gcc \
OPENSSL_DIR=/openssl \
OPENSSL_INCLUDE_DIR=/openssl/include \
OPENSSL_LIB_DIR=/openssl/lib
23 changes: 23 additions & 0 deletions docker/x86_64-sun-solaris/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM ubuntu:16.04

RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
cmake \
gcc \
libc6-dev \
make \
pkg-config

COPY xargo.sh /
RUN bash /xargo.sh

COPY solaris.sh openssl.sh /
RUN bash /solaris.sh x86_64 && \
bash /openssl.sh solaris64-x86_64-gcc x86_64-sun-solaris2.11-

ENV CARGO_TARGET_X86_64_SUN_SOLARIS_LINKER=x86_64-sun-solaris2.11-gcc \
CC_x86_64_sun_solaris=x86_64-sun-solaris2.11-gcc \
OPENSSL_DIR=/openssl \
OPENSSL_INCLUDE_DIR=/openssl/include \
OPENSSL_LIB_DIR=/openssl/lib
18 changes: 17 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ pub enum Target {
X86_64UnknownFreebsd,
X86_64UnknownNetbsd,

// Solaris / illumos
Sparcv9SunSolaris,
X86_64SunSolaris,

// Windows
X86_64PcWindowsGnu,
I686PcWindowsGnu,
Expand Down Expand Up @@ -161,6 +165,14 @@ impl Target {
}
}

fn is_solaris(&self) -> bool {
match *self {
Target::Sparcv9SunSolaris |
Target::X86_64SunSolaris => true,
_ => false,
}
}

fn is_android(&self) -> bool {
match *self {
Target::ArmLinuxAndroideabi |
Expand Down Expand Up @@ -214,7 +226,7 @@ impl Target {

fn needs_docker(&self) -> bool {
self.is_linux() || self.is_android() || self.is_bare_metal() || self.is_bsd() ||
!self.is_builtin() || self.is_windows() || self.is_emscripten()
self.is_solaris() || !self.is_builtin() || self.is_windows() || self.is_emscripten()
}

fn needs_interpreter(&self) -> bool {
Expand Down Expand Up @@ -265,6 +277,7 @@ impl Target {
PowerpcUnknownLinuxGnu => "powerpc-unknown-linux-gnu",
S390xUnknownLinuxGnu => "s390x-unknown-linux-gnu",
Sparc64UnknownLinuxGnu => "sparc64-unknown-linux-gnu",
Sparcv9SunSolaris => "sparcv9-sun-solaris",
Thumbv6mNoneEabi => "thumbv6m-none-eabi",
Thumbv7emNoneEabi => "thumbv7em-none-eabi",
Thumbv7emNoneEabihf => "thumbv7em-none-eabihf",
Expand All @@ -273,6 +286,7 @@ impl Target {
X86_64AppleDarwin => "x86_64-apple-darwin",
X86_64PcWindowsGnu => "x86_64-pc-windows-gnu",
X86_64LinuxAndroid => "x86_64-linux-android",
X86_64SunSolaris => "x86_64-sun-solaris",
X86_64UnknownDragonfly => "x86_64-unknown-dragonfly",
X86_64UnknownFreebsd => "x86_64-unknown-freebsd",
X86_64UnknownLinuxGnu => "x86_64-unknown-linux-gnu",
Expand Down Expand Up @@ -315,6 +329,7 @@ impl Target {
"powerpc64le-unknown-linux-gnu" => Powerpc64leUnknownLinuxGnu,
"s390x-unknown-linux-gnu" => S390xUnknownLinuxGnu,
"sparc64-unknown-linux-gnu" => Sparc64UnknownLinuxGnu,
"sparcv9-sun-solaris" => Sparcv9SunSolaris,
"thumbv6m-none-eabi" => Thumbv6mNoneEabi,
"thumbv7em-none-eabi" => Thumbv7emNoneEabi,
"thumbv7em-none-eabihf" => Thumbv7emNoneEabihf,
Expand All @@ -323,6 +338,7 @@ impl Target {
"x86_64-apple-darwin" => X86_64AppleDarwin,
"x86_64-linux-android" => X86_64LinuxAndroid,
"x86_64-pc-windows-gnu" => X86_64PcWindowsGnu,
"x86_64-sun-solaris" => X86_64SunSolaris,
"x86_64-unknown-dragonfly" => X86_64UnknownDragonfly,
"x86_64-unknown-freebsd" => X86_64UnknownFreebsd,
"x86_64-unknown-linux-gnu" => X86_64UnknownLinuxGnu,
Expand Down

0 comments on commit 359c3bb

Please sign in to comment.