Skip to content

Commit 9a84611

Browse files
petrhosekalexcrichton
authored andcommitted
travis: Fuchsia builder
This change introduces a Dockerfile and script which builds a complete Fuchsia toolchain which can be used to build Rust distribution for Fuchsia. We only support cross-compiling at the moment, hence only setting the target.
1 parent f573db4 commit 9a84611

File tree

6 files changed

+191
-3
lines changed

6 files changed

+191
-3
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ matrix:
2020
- env: IMAGE=dist-armv7-aarch64-linux DEPLOY=1
2121
- env: IMAGE=dist-freebsd DEPLOY=1
2222
- env: IMAGE=dist-i586-gnu-i686-musl DEPLOY=1
23+
- env: IMAGE=dist-fuchsia DEPLOY=1
2324
- env: IMAGE=dist-mips-linux DEPLOY=1
2425
- env: IMAGE=dist-mips64-linux DEPLOY=1
2526
- env: IMAGE=dist-powerpc-linux DEPLOY=1

src/ci/docker/dist-fuchsia/Dockerfile

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
FROM ubuntu:16.04
2+
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
g++ \
5+
make \
6+
ninja-build \
7+
file \
8+
curl \
9+
ca-certificates \
10+
python2.7-dev \
11+
git \
12+
sudo \
13+
bzip2 \
14+
xz-utils \
15+
swig \
16+
libedit-dev \
17+
libncurses5-dev
18+
19+
RUN curl -L https://cmake.org/files/v3.8/cmake-3.8.0-rc1-Linux-x86_64.tar.gz | \
20+
tar xzf - -C /usr/local --strip-components=1
21+
22+
WORKDIR /tmp
23+
COPY shared.sh build-toolchain.sh /tmp/
24+
RUN /tmp/build-toolchain.sh
25+
26+
RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \
27+
dpkg -i dumb-init_*.deb && \
28+
rm dumb-init_*.deb
29+
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
30+
31+
RUN curl -o /usr/local/bin/sccache \
32+
https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-02-25-sccache-x86_64-unknown-linux-musl && \
33+
chmod +x /usr/local/bin/sccache
34+
35+
ENV \
36+
AR_x86_64_unknown_fuchsia=x86_64-unknown-fuchsia-ar \
37+
CC_x86_64_unknown_fuchsia=x86_64-unknown-fuchsia-clang \
38+
CXX_x86_64_unknown_fuchsia=x86_64-unknown-fuchsia-clang++ \
39+
AR_aarch64_unknown_fuchsia=aarch64-unknown-fuchsia-ar \
40+
CC_aarch64_unknown_fuchsia=aarch64-unknown-fuchsia-clang \
41+
CXX_aarch64_unknown_fuchsia=aarch64-unknown-fuchsia-clang++
42+
43+
ENV TARGETS=x86_64-unknown-fuchsia
44+
ENV TARGETS=$TARGETS,aarch64-unknown-fuchsia
45+
46+
ENV RUST_CONFIGURE_ARGS --target=$TARGETS
47+
ENV SCRIPT python2.7 ../x.py dist --target $TARGETS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/bin/bash
2+
# Copyright 2017 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+
source shared.sh
14+
15+
# Download sources
16+
SRCS=(
17+
"https://fuchsia.googlesource.com/magenta magenta ac69119"
18+
"https://fuchsia.googlesource.com/third_party/llvm llvm 5463083"
19+
"https://fuchsia.googlesource.com/third_party/clang llvm/tools/clang 4ff7b4b"
20+
"https://fuchsia.googlesource.com/third_party/lld llvm/tools/lld fd465a3"
21+
"https://fuchsia.googlesource.com/third_party/lldb llvm/tools/lldb 6bb11f8"
22+
"https://fuchsia.googlesource.com/third_party/compiler-rt llvm/runtimes/compiler-rt 52d4ecc"
23+
"https://fuchsia.googlesource.com/third_party/libcxx llvm/runtimes/libcxx e891cc8"
24+
"https://fuchsia.googlesource.com/third_party/libcxxabi llvm/runtimes/libcxxabi f0f0257"
25+
"https://fuchsia.googlesource.com/third_party/libunwind llvm/runtimes/libunwind 50bddc1"
26+
)
27+
28+
fetch() {
29+
mkdir -p $2
30+
pushd $2 > /dev/null
31+
curl -sL $1/+archive/$3.tar.gz | tar xzf -
32+
popd > /dev/null
33+
}
34+
35+
for i in "${SRCS[@]}"; do
36+
fetch $i
37+
done
38+
39+
# Build toolchain
40+
cd llvm
41+
mkdir build
42+
cd build
43+
hide_output cmake -GNinja \
44+
-DFUCHSIA_SYSROOT=${PWD}/../../magenta/third_party/ulib/musl \
45+
-DLLVM_ENABLE_LTO=OFF \
46+
-DCLANG_BOOTSTRAP_PASSTHROUGH=LLVM_ENABLE_LTO \
47+
-C ../tools/clang/cmake/caches/Fuchsia.cmake \
48+
..
49+
hide_output ninja stage2-distribution
50+
hide_output ninja stage2-install-distribution
51+
cd ../..
52+
53+
# Build sysroot
54+
rm -rf llvm/runtimes/compiler-rt
55+
./magenta/scripts/download-toolchain
56+
57+
build_sysroot() {
58+
local arch="$1"
59+
60+
case "${arch}" in
61+
x86_64) tgt="magenta-pc-x86-64" ;;
62+
aarch64) tgt="magenta-qemu-arm64" ;;
63+
esac
64+
65+
hide_output make -C magenta -j$(getconf _NPROCESSORS_ONLN) $tgt
66+
dst=/usr/local/${arch}-unknown-fuchsia
67+
mkdir -p $dst
68+
cp -r magenta/build-${tgt}/sysroot/include $dst/
69+
cp -r magenta/build-${tgt}/sysroot/lib $dst/
70+
71+
cd llvm
72+
mkdir build-runtimes-${arch}
73+
cd build-runtimes-${arch}
74+
hide_output cmake -GNinja \
75+
-DCMAKE_C_COMPILER=clang \
76+
-DCMAKE_CXX_COMPILER=clang++ \
77+
-DCMAKE_AR=/usr/local/bin/llvm-ar \
78+
-DCMAKE_RANLIB=/usr/local/bin/llvm-ranlib \
79+
-DCMAKE_INSTALL_PREFIX= \
80+
-DLLVM_MAIN_SRC_DIR=${PWD}/.. \
81+
-DLLVM_BINARY_DIR=${PWD}/../build \
82+
-DLLVM_ENABLE_WERROR=OFF \
83+
-DCMAKE_BUILD_TYPE=Release \
84+
-DLLVM_INCLUDE_TESTS=ON \
85+
-DCMAKE_SYSTEM_NAME=Fuchsia \
86+
-DCMAKE_C_COMPILER_TARGET=${arch}-fuchsia \
87+
-DCMAKE_CXX_COMPILER_TARGET=${arch}-fuchsia \
88+
-DUNIX=1 \
89+
-DLIBCXX_HAS_MUSL_LIBC=ON \
90+
-DLIBCXXABI_USE_LLVM_UNWINDER=ON \
91+
-DCMAKE_SYSROOT=${dst} \
92+
-DCMAKE_C_COMPILER_FORCED=TRUE \
93+
-DCMAKE_CXX_COMPILER_FORCED=TRUE \
94+
-DLLVM_ENABLE_LIBCXX=ON \
95+
-DCMAKE_EXE_LINKER_FLAGS="-nodefaultlibs -lc" \
96+
-DCMAKE_SHARED_LINKER_FLAGS="$(clang --target=${arch}-fuchsia -print-libgcc-file-name)" \
97+
../runtimes
98+
hide_output env DESTDIR="${dst}" ninja install
99+
cd ../..
100+
}
101+
102+
build_sysroot "x86_64"
103+
build_sysroot "aarch64"
104+
105+
rm -rf magenta llvm
106+
107+
for arch in x86_64 aarch64; do
108+
for tool in clang clang++; do
109+
cat >/usr/local/bin/${arch}-unknown-fuchsia-${tool} <<EOF
110+
#!/bin/sh
111+
${tool} --target=${arch}-unknown-fuchsia --sysroot=/usr/local/${arch}-unknown-fuchsia "\$@"
112+
EOF
113+
chmod +x /usr/local/bin/${arch}-unknown-fuchsia-${tool}
114+
done
115+
ln -s /usr/local/bin/llvm-ar /usr/local/bin/${arch}-unknown-fuchsia-ar
116+
done

src/ci/docker/dist-fuchsia/shared.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
# file at the top-level directory of this distribution and at
3+
# http://rust-lang.org/COPYRIGHT.
4+
#
5+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
# option. This file may not be copied, modified, or distributed
9+
# except according to those terms.
10+
11+
hide_output() {
12+
set +x
13+
on_err="
14+
echo ERROR: An error was encountered with the build.
15+
cat /tmp/build.log
16+
exit 1
17+
"
18+
trap "$on_err" ERR
19+
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
20+
PING_LOOP_PID=$!
21+
"$@" &> /tmp/build.log
22+
trap - ERR
23+
kill $PING_LOOP_PID
24+
set -x
25+
}

src/libstd/sys_common/gnu/libbacktrace.rs

-3
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ extern "C" fn(data: *mut libc::c_void,
105105
msg: *const libc::c_char,
106106
errnum: libc::c_int);
107107
enum backtrace_state {}
108-
#[link(name = "backtrace", kind = "static")]
109-
#[cfg(all(not(test), not(cargobuild)))]
110-
extern {}
111108

112109
extern {
113110
fn backtrace_create_state(filename: *const libc::c_char,

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

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ static HOSTS: &'static [&'static str] = &[
4545

4646
static TARGETS: &'static [&'static str] = &[
4747
"aarch64-apple-ios",
48+
"aarch64-unknown-fuchsia",
4849
"aarch64-linux-android",
4950
"aarch64-unknown-linux-gnu",
5051
"arm-linux-androideabi",
@@ -86,6 +87,7 @@ static TARGETS: &'static [&'static str] = &[
8687
"x86_64-pc-windows-msvc",
8788
"x86_64-rumprun-netbsd",
8889
"x86_64-unknown-freebsd",
90+
"x86_64-unknown-fuchsia",
8991
"x86_64-unknown-linux-gnu",
9092
"x86_64-unknown-linux-musl",
9193
"x86_64-unknown-netbsd",

0 commit comments

Comments
 (0)