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.
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.
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"
31 curl -sL $1/+archive/$3.tar.gz | tar xzf -
35 for i in "${SRCS[@]}"; do
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 \
49 hide_output ninja stage2-distribution
50 hide_output ninja stage2-install-distribution
54 rm -rf llvm/runtimes/compiler-rt
55 ./magenta/scripts/download-toolchain
61 x86_64) tgt="magenta-pc-x86-64" ;;
62 aarch64) tgt="magenta-qemu-arm64" ;;
65 hide_output make -C magenta -j$(getconf _NPROCESSORS_ONLN) $tgt
66 dst=/usr/local/${arch}-unknown-fuchsia
68 cp -r magenta/build-${tgt}/sysroot/include $dst/
69 cp -r magenta/build-${tgt}/sysroot/lib $dst/
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 \
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)" \
98 hide_output env DESTDIR="${dst}" ninja install
102 build_sysroot "x86_64"
103 build_sysroot "aarch64"
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
111 ${tool} --target=${arch}-unknown-fuchsia --sysroot=/usr/local/${arch}-unknown-fuchsia "\$@"
113 chmod +x /usr/local/bin/${arch}-unknown-fuchsia-${tool}
115 ln -s /usr/local/bin/llvm-ar /usr/local/bin/${arch}-unknown-fuchsia-ar