Skip to content

Commit 3e8e574

Browse files
committed
Use KyleMayes/install-llvm-action to install LLVM
1 parent 7c5aa4f commit 3e8e574

File tree

2 files changed

+9
-65
lines changed

2 files changed

+9
-65
lines changed

.github/workflows/bindgen.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,8 @@ jobs:
162162
# feature_extra_asserts: 0
163163

164164
# Ensure stuff works on macos too
165-
# FIXME: Ideally should use the latest llvm version, but llvm doesn't
166-
# provide releases for x86-64 macOS anymore which is what the runner uses.
167-
#
168165
- os: macos-latest
169-
llvm_version: "9.0"
166+
llvm_version: "16.0"
170167
release_build: 0
171168
no_default_features: 0
172169
feature_extra_asserts: 0
@@ -198,12 +195,15 @@ jobs:
198195
run: |
199196
wget https://mirrors.kernel.org/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_amd64.deb
200197
sudo dpkg -i libtinfo5_6.3-2ubuntu0.1_amd64.deb
198+
- name: Install LLVM and Clang
199+
uses: KyleMayes/[email protected]
200+
with:
201+
version: ${{matrix.llvm_version}}
201202
- name: Run all the tests
202203
env:
203204
GITHUB_ACTIONS_OS: ${{matrix.os}}
204205
RUST_CROSS_COMPILER: ${{matrix.target.cross}}
205206
RUST_TARGET: ${{matrix.target.rust}}
206-
LLVM_VERSION: ${{matrix.llvm_version}}
207207
BINDGEN_MAIN_TESTS: ${{matrix.main_tests}}
208208
BINDGEN_RELEASE_BUILD: ${{matrix.release_build}}
209209
BINDGEN_FEATURE_RUNTIME: ${{matrix.feature_runtime}}

ci/test.sh

Lines changed: 4 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -8,64 +8,8 @@ set -x
88
# Give a pipeline a non-zero exit code if one of its constituents fails
99
set -o pipefail
1010

11-
function llvm_linux_target_triple() {
12-
case "$1" in
13-
9.0.1) echo "x86_64-linux-gnu-ubuntu-16.04" ;;
14-
*) echo "x86_64-linux-gnu-ubuntu-18.04" ;;
15-
esac
16-
}
17-
18-
function llvm_macos_target_triple() {
19-
case "$1" in
20-
9.0.1) echo "x86_64-apple-darwin" ;;
21-
*) echo "arm64-apple-darwin22.0" ;;
22-
esac
23-
}
24-
25-
function llvm_version_triple() {
26-
case "$1" in
27-
9.0) echo "9.0.1" ;;
28-
# By default, take the .0 patch release
29-
*) echo "$1.0" ;;
30-
esac
31-
}
32-
33-
function llvm_base_url() {
34-
local llvm_version_triple=$1
35-
echo "https://github.com/llvm/llvm-project/releases/download/llvmorg-$llvm_version_triple"
36-
}
37-
38-
function llvm_download() {
39-
local base_url=$1
40-
local arch=$2
41-
42-
export LLVM=clang+llvm-${LLVM_VERSION_TRIPLE}-$arch
43-
export LLVM_DIRECTORY="$HOME/.llvm/${LLVM}"
44-
45-
if [ -d "${LLVM_DIRECTORY}" ]; then
46-
echo "Using cached LLVM download for ${LLVM}..."
47-
else
48-
wget --no-verbose $base_url/${LLVM}.tar.xz
49-
mkdir -p "${LLVM_DIRECTORY}"
50-
tar xf ${LLVM}.tar.xz -C "${LLVM_DIRECTORY}" --strip-components=1
51-
fi
52-
53-
export LIBCLANG_PATH="${LLVM_DIRECTORY}/lib"
54-
export LLVM_CONFIG_PATH="${LLVM_DIRECTORY}/bin/llvm-config"
55-
}
56-
57-
# Download and set up a sane LLVM version
5811
set_llvm_env() {
59-
export LLVM_VERSION_TRIPLE=`llvm_version_triple ${LLVM_VERSION}`
60-
local base_url=`llvm_base_url ${LLVM_VERSION_TRIPLE}`
61-
62-
if [ "$GITHUB_ACTIONS_OS" == "ubuntu-latest" ]; then
63-
llvm_download $base_url `llvm_linux_target_triple ${LLVM_VERSION_TRIPLE}`
64-
export LD_LIBRARY_PATH="${LLVM_DIRECTORY}/lib":${LD_LIBRARY_PATH:-}
65-
else
66-
llvm_download $base_url `llvm_macos_target_triple ${LLVM_VERSION_TRIPLE}`
67-
export DYLD_LIBRARY_PATH="${LLVM_DIRECTORY}/lib":${DYLD_LIBRARY_PATH:-}
68-
fi
12+
# FIXME: set any env vars that might be required
6913
}
7014

7115
assert_no_diff() {
@@ -74,8 +18,6 @@ assert_no_diff() {
7418
git diff-index --quiet HEAD
7519
}
7620

77-
set_llvm_env
78-
7921
get_cargo_args() {
8022
local args=""
8123
if [ ! -z "$RUST_TARGET" ]; then
@@ -100,6 +42,8 @@ get_cargo_args() {
10042
echo $args
10143
}
10244

45+
set_llvm_env
46+
10347
if [ ! -z "$RUST_CROSS_COMPILER" ]; then
10448
export RUSTFLAGS="-C linker=${RUST_CROSS_COMPILER}-gcc"
10549
fi
@@ -128,7 +72,7 @@ if [ "$BINDGEN_RUST_FOR_LINUX_TEST" == "1" ]; then
12872

12973
# Put LLVM binaries in the path for `LLVM=1`. The LLVM `bin` directory should
13074
# go first since there are others in the Ubuntu image.
131-
export PATH="${LLVM_DIRECTORY}/bin:${PATH}"
75+
export PATH="${LLVM_PATH}/bin:${PATH}"
13276

13377
# Kernel build dependency: `bindgen-cli`, which is under test.
13478
#

0 commit comments

Comments
 (0)