Skip to content

Commit c5bbde3

Browse files
committed
ci: extract installing clang into a script
1 parent a360772 commit c5bbde3

File tree

4 files changed

+58
-47
lines changed

4 files changed

+58
-47
lines changed

src/ci/azure-pipelines/steps/install-clang.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/ci/azure-pipelines/steps/run.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ steps:
5757
displayName: Install sccache
5858
condition: and(succeeded(), not(variables.SKIP_JOB))
5959

60-
- template: install-clang.yml
60+
- bash: src/ci/scripts/install-clang.sh
61+
env:
62+
AGENT_OS: $(Agent.OS)
63+
displayName: Install clang
64+
condition: and(succeeded(), not(variables.SKIP_JOB))
6165

6266
# Switch to XCode 9.3 on OSX since it seems to be the last version that supports
6367
# i686-apple-darwin. We'll eventually want to upgrade this and it will probably

src/ci/scripts/install-clang.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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

src/ci/shared.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,14 @@ function ciCommandAddPath {
5555

5656
echo "##vso[task.prependpath]${path}"
5757
}
58+
59+
function ciCommandSetEnv {
60+
if [[ $# -ne 2 ]]; then
61+
echo "usage: $0 <name> <value>"
62+
exit 1
63+
fi
64+
name="$1"
65+
value="$2"
66+
67+
echo "##vso[task.setvariable variable=${name}]${value}"
68+
}

0 commit comments

Comments
 (0)