]>
Commit | Line | Data |
---|---|---|
e74abb32 XL |
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 | ||
3dfed10e | 11 | # Update both macOS's and Windows's tarballs when bumping the version here. |
cdc7bbd5 | 12 | LLVM_VERSION="12.0.0" |
3dfed10e | 13 | |
e74abb32 | 14 | if isMacOS; then |
29967ef6 XL |
15 | # If the job selects a specific Xcode version, use that instead of |
16 | # downloading our own version. | |
17 | if [[ ${USE_XCODE_CLANG-0} -eq 1 ]]; then | |
18 | bindir="$(xcode-select --print-path)/Toolchains/XcodeDefault.xctoolchain/usr/bin" | |
19 | else | |
20 | file="${MIRRORS_BASE}/clang%2Bllvm-${LLVM_VERSION}-x86_64-apple-darwin.tar.xz" | |
17df50a5 XL |
21 | retry curl -f "${file}" -o "clang+llvm-${LLVM_VERSION}-x86_64-apple-darwin.tar.xz" |
22 | tar xJf "clang+llvm-${LLVM_VERSION}-x86_64-apple-darwin.tar.xz" | |
29967ef6 XL |
23 | bindir="$(pwd)/clang+llvm-${LLVM_VERSION}-x86_64-apple-darwin/bin" |
24 | fi | |
e74abb32 | 25 | |
29967ef6 XL |
26 | ciCommandSetEnv CC "${bindir}/clang" |
27 | ciCommandSetEnv CXX "${bindir}/clang++" | |
e74abb32 | 28 | |
dfeec247 XL |
29 | # macOS 10.15 onwards doesn't have libraries in /usr/include anymore: those |
30 | # are now located deep into the filesystem, under Xcode's own files. The | |
31 | # native clang is configured to use the correct path, but our custom one | |
32 | # doesn't. This sets the SDKROOT environment variable to the SDK so that | |
33 | # our own clang can figure out the correct include path on its own. | |
34 | ciCommandSetEnv SDKROOT "$(xcrun --sdk macosx --show-sdk-path)" | |
35 | ||
e74abb32 XL |
36 | # Configure `AR` specifically so rustbuild doesn't try to infer it as |
37 | # `clang-ar` by accident. | |
38 | ciCommandSetEnv AR "ar" | |
60c5eb7d | 39 | elif isWindows && [[ ${CUSTOM_MINGW-0} -ne 1 ]]; then |
e74abb32 XL |
40 | # If we're compiling for MSVC then we, like most other distribution builders, |
41 | # switch to clang as the compiler. This'll allow us eventually to enable LTO | |
42 | # amongst LLVM and rustc. Note that we only do this on MSVC as I don't think | |
43 | # clang has an output mode compatible with MinGW that we need. If it does we | |
44 | # should switch to clang for MinGW as well! | |
45 | # | |
cdc7bbd5 XL |
46 | # The LLVM installer is an NSIS installer, which we can extract with 7z. We |
47 | # don't want to run the installer directly; extracting it is more reliable | |
48 | # in CI environments. | |
e74abb32 | 49 | |
cdc7bbd5 | 50 | mkdir -p citools/clang-rust |
e74abb32 | 51 | cd citools |
17df50a5 XL |
52 | retry curl -f "${MIRRORS_BASE}/LLVM-${LLVM_VERSION}-win64.exe" \ |
53 | -o "LLVM-${LLVM_VERSION}-win64.exe" | |
cdc7bbd5 | 54 | 7z x -oclang-rust/ "LLVM-${LLVM_VERSION}-win64.exe" |
e74abb32 XL |
55 | ciCommandSetEnv RUST_CONFIGURE_ARGS \ |
56 | "${RUST_CONFIGURE_ARGS} --set llvm.clang-cl=$(pwd)/clang-rust/bin/clang-cl.exe" | |
57 | fi |