forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#39918 - petrhosek:fuchsia-ci, r=alexcrichton
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.
- Loading branch information
Showing
4 changed files
with
165 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
#!/bin/bash | ||
# Copyright 2017 The Rust Project Developers. See the COPYRIGHT | ||
# file at the top-level directory of this distribution and at | ||
# http://rust-lang.org/COPYRIGHT. | ||
# | ||
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
# option. This file may not be copied, modified, or distributed | ||
# except according to those terms. | ||
|
||
set -ex | ||
source shared.sh | ||
|
||
# Download sources | ||
SRCS=( | ||
"https://fuchsia.googlesource.com/magenta magenta 29f09e6" | ||
"https://fuchsia.googlesource.com/third_party/llvm llvm 0f6af23" | ||
"https://fuchsia.googlesource.com/third_party/clang llvm/tools/clang 71b73d0" | ||
"https://fuchsia.googlesource.com/third_party/lld llvm/tools/lld af25ab9" | ||
"https://fuchsia.googlesource.com/third_party/lldb llvm/tools/lldb 90fe975" | ||
"https://fuchsia.googlesource.com/third_party/compiler-rt llvm/runtimes/compiler-rt 2edda55" | ||
"https://fuchsia.googlesource.com/third_party/libcxx llvm/runtimes/libcxx b7fd0be" | ||
"https://fuchsia.googlesource.com/third_party/libcxxabi llvm/runtimes/libcxxabi 66c8647" | ||
"https://fuchsia.googlesource.com/third_party/libunwind llvm/runtimes/libunwind 43ce8ac" | ||
) | ||
|
||
fetch() { | ||
mkdir -p $2 | ||
pushd $2 > /dev/null | ||
curl -sL $1/+archive/$3.tar.gz | tar xzf - | ||
popd > /dev/null | ||
} | ||
|
||
for i in "${SRCS[@]}"; do | ||
fetch $i | ||
done | ||
|
||
# Build toolchain | ||
cd llvm | ||
mkdir build | ||
cd build | ||
hide_output cmake -GNinja \ | ||
-DFUCHSIA_SYSROOT=${PWD}/../../magenta/third_party/ulib/musl \ | ||
-C ../tools/clang/cmake/caches/Fuchsia.cmake \ | ||
.. | ||
hide_output ninja stage2-distribution | ||
hide_output ninja stage2-install-distribution | ||
cd ../.. | ||
|
||
# Build sysroot | ||
rm -rf llvm/runtimes/compiler-rt | ||
./magenta/scripts/download-toolchain | ||
|
||
build_sysroot() { | ||
local arch="$1" | ||
|
||
case "${arch}" in | ||
x86_64) tgt="magenta-pc-x86-64" ;; | ||
aarch64) tgt="magenta-qemu-arm64" ;; | ||
esac | ||
|
||
hide_output make -C magenta -j$(getconf _NPROCESSORS_ONLN) $tgt | ||
dst=/usr/local/${arch}-unknown-fuchsia | ||
mkdir -p $dst | ||
cp -r magenta/build-${tgt}/sysroot/include $dst/ | ||
cp -r magenta/build-${tgt}/sysroot/lib $dst/ | ||
|
||
cd llvm | ||
mkdir build-runtimes-${arch} | ||
cd build-runtimes-${arch} | ||
hide_output cmake -GNinja \ | ||
-DCMAKE_C_COMPILER=clang \ | ||
-DCMAKE_CXX_COMPILER=clang++ \ | ||
-DCMAKE_AR=/usr/local/bin/llvm-ar \ | ||
-DCMAKE_RANLIB=/usr/local/bin/llvm-ranlib \ | ||
-DCMAKE_INSTALL_PREFIX= \ | ||
-DLLVM_MAIN_SRC_DIR=${PWD}/.. \ | ||
-DLLVM_BINARY_DIR=${PWD}/../build \ | ||
-DLLVM_ENABLE_WERROR=OFF \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DLLVM_INCLUDE_TESTS=ON \ | ||
-DCMAKE_SYSTEM_NAME=Fuchsia \ | ||
-DCMAKE_C_COMPILER_TARGET=${arch}-fuchsia \ | ||
-DCMAKE_CXX_COMPILER_TARGET=${arch}-fuchsia \ | ||
-DUNIX=1 \ | ||
-DLIBCXX_HAS_MUSL_LIBC=ON \ | ||
-DLIBCXXABI_USE_LLVM_UNWINDER=ON \ | ||
-DCMAKE_SYSROOT=${dst} \ | ||
-DCMAKE_C_COMPILER_FORCED=TRUE \ | ||
-DCMAKE_CXX_COMPILER_FORCED=TRUE \ | ||
-DLLVM_ENABLE_LIBCXX=ON \ | ||
-DCMAKE_EXE_LINKER_FLAGS="-nodefaultlibs -lc" \ | ||
-DCMAKE_SHARED_LINKER_FLAGS="$(clang --target=${arch}-fuchsia -print-libgcc-file-name)" \ | ||
../runtimes | ||
hide_output env DESTDIR="${dst}" ninja install | ||
cd ../.. | ||
} | ||
|
||
build_sysroot "x86_64" | ||
build_sysroot "aarch64" | ||
|
||
rm -rf magenta llvm | ||
|
||
for arch in x86_64 aarch64; do | ||
for tool in clang clang++; do | ||
cat >/usr/local/bin/${arch}-unknown-fuchsia-${tool} <<EOF | ||
#!/bin/sh | ||
${tool} --target=${arch}-unknown-fuchsia --sysroot=/usr/local/${arch}-unknown-fuchsia "\$@" | ||
EOF | ||
chmod +x /usr/local/bin/${arch}-unknown-fuchsia-${tool} | ||
done | ||
ln -s /usr/local/bin/llvm-ar /usr/local/bin/${arch}-unknown-fuchsia-ar | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright 2017 The Rust Project Developers. See the COPYRIGHT | ||
# file at the top-level directory of this distribution and at | ||
# http://rust-lang.org/COPYRIGHT. | ||
# | ||
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
# option. This file may not be copied, modified, or distributed | ||
# except according to those terms. | ||
|
||
hide_output() { | ||
set +x | ||
on_err=" | ||
echo ERROR: An error was encountered with the build. | ||
cat /tmp/build.log | ||
exit 1 | ||
" | ||
trap "$on_err" ERR | ||
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" & | ||
PING_LOOP_PID=$! | ||
"$@" &> /tmp/build.log | ||
trap - ERR | ||
kill $PING_LOOP_PID | ||
set -x | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters