|
| 1 | +#!/bin/bash |
| 2 | +# This script installs clang on the local machine. Note that we don't install |
| 3 | +# clang on Linux since its compiler story is just so different. Each container |
| 4 | +# has its own toolchain configured appropriately already. |
| 5 | + |
| 6 | +set -euo pipefail |
| 7 | +IFS=$'\n\t' |
| 8 | + |
| 9 | +source "$(cd "$(dirname "$0")" && pwd)/../shared.sh" |
| 10 | + |
| 11 | +if isMacOS; then |
| 12 | + curl -f https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/clang%2Bllvm-7.0.0-x86_64-apple-darwin.tar.xz | tar xJf - |
| 13 | + |
| 14 | + ciCommandSetEnv CC "$(pwd)/clang+llvm-7.0.0-x86_64-apple-darwin/bin/clang" |
| 15 | + ciCommandSetEnv CXX "$(pwd)/clang+llvm-7.0.0-x86_64-apple-darwin/bin/clang++" |
| 16 | + |
| 17 | + # Configure `AR` specifically so rustbuild doesn't try to infer it as |
| 18 | + # `clang-ar` by accident. |
| 19 | + ciCommandSetEnv AR "ar" |
| 20 | +elif isWindows; then |
| 21 | + # If we're compiling for MSVC then we, like most other distribution builders, |
| 22 | + # switch to clang as the compiler. This'll allow us eventually to enable LTO |
| 23 | + # amongst LLVM and rustc. Note that we only do this on MSVC as I don't think |
| 24 | + # clang has an output mode compatible with MinGW that we need. If it does we |
| 25 | + # should switch to clang for MinGW as well! |
| 26 | + # |
| 27 | + # Note that the LLVM installer is an NSIS installer |
| 28 | + # |
| 29 | + # Original downloaded here came from |
| 30 | + # http://releases.llvm.org/7.0.0/LLVM-7.0.0-win64.exe |
| 31 | + # That installer was run through `wine` on Linux and then the resulting |
| 32 | + # installation directory (found in `$HOME/.wine/drive_c/Program Files/LLVM`) was |
| 33 | + # packaged up into a tarball. We've had issues otherwise that the installer will |
| 34 | + # randomly hang, provide not a lot of useful information, pollute global state, |
| 35 | + # etc. In general the tarball is just more confined and easier to deal with when |
| 36 | + # working with various CI environments. |
| 37 | + |
| 38 | + mkdir -p citools |
| 39 | + cd citools |
| 40 | + curl -f "${MIRRORS_BASE}/LLVM-7.0.0-win64.tar.gz" | tar xzf - |
| 41 | + ciCommandSetEnv RUST_CONFIGURE_ARGS "${RUST_CONFIGURE_ARGS} --set llvm.clang-cl=$(pwd)/clang-rust/bin/clang-cl.exe" |
| 42 | +fi |
0 commit comments