Skip to content

Commit 057dee0

Browse files
committed
workflows: install llvm tools from apt.llvm.org
This commit adds a script install_clang_version.sh that is used across all the relevant github workflows to ensure a particular version of clang is installed, along with the dependencies needed (lld and libomp-dev).
1 parent 78225cb commit 057dee0

File tree

9 files changed

+124
-126
lines changed

9 files changed

+124
-126
lines changed

.github/actionlint.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# To tell rhysd/actionlint that we have a custom runner
22
self-hosted-runner:
33
labels:
4-
- ubuntu-22.04-32core
5-
- ubuntu-22.04-8core
4+
- ubuntu-24.04-64core
5+
- ubuntu-24.04-32core
6+
- ubuntu-24.04-16core
7+
- ubuntu-24.04-8core

.github/install_clang_version.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
set -e
3+
4+
if [ $# -ne 1 ]; then
5+
echo "Usage: $0 <clang_version>"
6+
echo "Example: $0 19"
7+
exit 1
8+
fi
9+
10+
CLANG_VERSION=$1
11+
12+
# Get the current Ubuntu codename dynamically
13+
CODENAME=$(lsb_release -cs)
14+
15+
# Instructions from https://apt.llvm.org/
16+
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
17+
echo "deb http://apt.llvm.org/${CODENAME}/ llvm-toolchain-${CODENAME}-${CLANG_VERSION} main" | sudo tee /etc/apt/sources.list.d/llvm.list
18+
sudo apt update
19+
sudo apt-get install -y clang-${CLANG_VERSION} lld-${CLANG_VERSION} libomp-${CLANG_VERSION}-dev
20+
21+
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${CLANG_VERSION} 200
22+
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${CLANG_VERSION} 200
23+
sudo update-alternatives --install /usr/bin/lld lld /usr/bin/lld-${CLANG_VERSION} 200

.github/workflows/build_and_test.yml

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,42 +13,39 @@ concurrency:
1313
jobs:
1414
build-and-test:
1515
runs-on:
16-
labels: ubuntu-22.04-32core
16+
labels: ubuntu-24.04-64core
1717
steps:
18-
- name: Install dependencies
19-
run: |
20-
sudo apt-get install -y libomp-dev
2118
- name: Check out repository code
2219
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # pin@v3
2320

21+
- name: Install dependencies
22+
run: |
23+
./.github/install_clang_version.sh 19
24+
2425
- name: Cache bazel build artifacts
2526
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # [email protected]
2627
with:
2728
path: |
2829
~/.cache/bazel
29-
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE.bzlmod', 'MODULE.bazel') }}-${{ hashFiles('bazel/import_llvm.bzl') }}
30+
key: ${{ runner.os }}-clang19-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE.bzlmod', 'MODULE.bazel') }}-${{ hashFiles('bazel/import_llvm.bzl') }}
3031
restore-keys: |
31-
${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE.bzlmod', 'MODULE.bazel') }}-${{ hashFiles('bazel/import_llvm.bzl') }}
32-
${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE.bzlmod', 'MODULE.bazel') }}-
32+
${{ runner.os }}-clang19-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE.bzlmod', 'MODULE.bazel') }}-${{ hashFiles('bazel/import_llvm.bzl') }}
33+
${{ runner.os }}-clang19-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE.bzlmod', 'MODULE.bazel') }}-
34+
35+
- name: Confirm bazel is using the right C compiler
36+
run: |
37+
# Pure debugging bazel stuff: ensure the compiler installed is the
38+
# one used by bazel. Note that the path to the C compiler is part of
39+
# the cache, so if the compiler changes but the cache does not, it
40+
# will try to use the old compiler path.
41+
which -a clang | xargs ls -al
42+
ls -al /etc/alternatives/clang
43+
bazel cquery --output=starlark --starlark:expr="str(providers(target))" @bazel_tools//tools/cpp:current_cc_toolchain | sed 's/,/\n/g' | grep -C 5 clang
3344
3445
- name: "Run `bazel build`"
3546
run: |
36-
bazel build -c opt //... --explain=bazel-explain.log --verbose_explanations
47+
bazel build -c opt //...
3748
3849
- name: "Run `bazel test`"
3950
run: |
4051
bazel test -c opt //...
41-
42-
- name: Upload bazel explanation log
43-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # [email protected]
44-
if: always()
45-
with:
46-
name: bazel-logs
47-
path: bazel-explain.log
48-
retention-days: 30
49-
50-
- uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # [email protected]
51-
with:
52-
path: |
53-
~/.cache/bazel
54-
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE.bzlmod', 'MODULE.bazel') }}-${{ hashFiles('bazel/import_llvm.bzl') }}

.github/workflows/build_and_test_macos.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ jobs:
2323
with:
2424
path: |
2525
~/.cache/bazel
26-
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE.bzlmod', 'MODULE.bazel') }}-${{ hashFiles('bazel/import_llvm.bzl') }}
26+
key: ${{ runner.os }}-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE.bzlmod', 'MODULE.bazel') }}-${{ hashFiles('bazel/import_llvm.bzl') }}
2727
restore-keys: |
28-
${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE.bzlmod', 'MODULE.bazel') }}-
28+
${{ runner.os }}-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE.bzlmod', 'MODULE.bazel') }}-
2929
3030
- name: Install coreutils
3131
run: brew install coreutils

.github/workflows/build_options_matrix.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@ jobs:
2424
- 1
2525
fail-fast: false
2626
runs-on:
27-
labels: ubuntu-22.04-8core
27+
labels: ubuntu-24.04-64core
2828
steps:
2929
- name: Install dependencies
3030
run: |
31-
sudo apt-get update
32-
sudo apt-get install -y libomp-dev
31+
./.github/install_clang_version.sh 19
3332
3433
- name: Check out repository code
3534
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # pin@v3

.github/workflows/clang_matrix.yml

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,19 @@ jobs:
1414
strategy:
1515
matrix:
1616
# since upgrading to C++20, only clang-17 and later are supported.
17-
clang-version: [17, 18, 19, 20]
17+
clang-version: [17, 18, 19, 20, 21]
1818
fail-fast: false
1919
runs-on:
20-
labels: ubuntu-22.04-8core
20+
labels: ubuntu-24.04-64core
2121
steps:
2222
- name: Install dependencies
2323
run: |
24-
sudo apt-get update
25-
sudo apt-get install -y libomp-dev
24+
./.github/install_clang_version.sh ${{ matrix.clang-version }}
2625
2726
- name: Check out repository code
2827
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # pin@v3
2928

30-
- name: Install Clang ${{ matrix.clang-version }}
31-
run: |
32-
sudo apt-get update
33-
sudo apt-get install -y clang-${{ matrix.clang-version }}
34-
clang-${{ matrix.clang-version }} --version
35-
36-
- name: "Run `bazel build` with Clang ${{ matrix.clang-version }}"
37-
run: |
38-
bazel build --keep_going --incompatible_strict_action_env \
39-
--action_env=CC=clang-${{ matrix.clang-version }} \
40-
--action_env=CXX=clang++-${{ matrix.clang-version }} \
41-
--host_action_env=CC=clang-${{ matrix.clang-version }} \
42-
--host_action_env=CXX=clang++-${{ matrix.clang-version }} \
43-
--//:enable_openmp=0 \
44-
-c fastbuild //...
45-
4629
- name: "Run `bazel build` with Clang ${{ matrix.clang-version }} + OpenMP"
4730
run: |
4831
bazel build --keep_going --incompatible_strict_action_env \
49-
--action_env=CC=clang-${{ matrix.clang-version }} \
50-
--action_env=CXX=clang++-${{ matrix.clang-version }} \
51-
--host_action_env=CC=clang-${{ matrix.clang-version }} \
52-
--host_action_env=CXX=clang++-${{ matrix.clang-version }} \
53-
--//:enable_openmp=1 \
54-
-c fastbuild //...
32+
-c opt //...

.github/workflows/docs.yml

Lines changed: 68 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -12,78 +12,83 @@ concurrency:
1212
jobs:
1313
build-and-deploy:
1414
runs-on:
15-
labels: ubuntu-22.04-32core
15+
labels: ubuntu-24.04-16core
1616
permissions:
1717
contents: write
1818
steps:
19-
- name: Checkout
20-
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # pin@v3
21-
with:
22-
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
23-
- name: Cache bazel build artifacts
24-
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # [email protected]
25-
with:
26-
path: |
27-
~/.cache/bazel
28-
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE.bzlmod', 'MODULE.bazel') }}-${{ hashFiles('bazel/import_llvm.bzl') }}
29-
restore-keys: |
30-
${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE.bzlmod', 'MODULE.bazel') }}-
19+
- name: Checkout
20+
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # pin@v3
21+
with:
22+
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
3123

24+
- name: Install dependencies
25+
run: |
26+
./.github/install_clang_version.sh 19
3227
33-
# This requires building mlir-tblgen, but may not require a full llvm build
34-
# as a result. It results in the files being added to their respective
35-
# locations (relative to each *_inc_gen target) under bazel-bin. Note the
36-
# _filegroup suffix is required to actually write the markdown files to
37-
# disk.
38-
- name: "Build markdown files from tblgen sources"
39-
run: |
40-
bazel query "filter('_filegroup', siblings(kind('gentbl_rule', @heir//...)))" | \
41-
xargs bazel build --//:enable_openmp=0 -c fastbuild "$@"
28+
- name: Cache bazel build artifacts
29+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # [email protected]
30+
with:
31+
path: |
32+
~/.cache/bazel
33+
key: ${{ runner.os }}-clang19-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE.bzlmod', 'MODULE.bazel') }}-${{ hashFiles('bazel/import_llvm.bzl') }}
34+
restore-keys: |
35+
${{ runner.os }}-clang19-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE.bzlmod', 'MODULE.bazel') }}-${{ hashFiles('bazel/import_llvm.bzl') }}
36+
${{ runner.os }}-clang19-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE.bzlmod', 'MODULE.bazel') }}-
4237
43-
- name: "Copy markdown files to docs/"
44-
run: |
45-
python -m pip install --upgrade pip
46-
python -m pip install pyyaml==6.0.2 fire==0.7.0
47-
# heir-opt is needed to generate the doctest examples
48-
bazel build --//:enable_openmp=0 -c fastbuild //tools:heir-opt
49-
python -m scripts.docs.copy_tblgen_files
38+
# This requires building mlir-tblgen, but may not require a full llvm build
39+
# as a result. It results in the files being added to their respective
40+
# locations (relative to each *_inc_gen target) under bazel-bin. Note the
41+
# _filegroup suffix is required to actually write the markdown files to
42+
# disk.
43+
- name: "Build markdown files from tblgen sources"
44+
run: |
45+
bazel query "filter('_filegroup', siblings(kind('gentbl_rule', @heir//...)))" | \
46+
xargs bazel build --//:enable_openmp=0 -c opt "$@"
5047
51-
# Please update the local install instructions at docs/README.md if
52-
# changing hugo version
53-
- name: Setup Hugo
54-
uses: peaceiris/actions-hugo@16361eb4acea8698b220b76c0d4e84e1fd22c61d # [email protected].0
55-
with:
56-
hugo-version: '0.113.0'
57-
extended: true
48+
- name: "Copy markdown files to docs/"
49+
run: |
50+
python -m pip install --upgrade pip
51+
python -m pip install pyyaml==6.0.2 fire==0.7.0
52+
# heir-opt is needed to generate the doctest examples
53+
bazel build --//:enable_openmp=0 -c opt //tools:heir-opt
54+
python -m scripts.docs.copy_tblgen_files
5855
59-
# Please update the local install instructions at docs/README.md if
60-
# changing node version
61-
- name: Setup Node
62-
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
63-
with:
64-
node-version: '18'
65-
cache: 'npm'
66-
# The action defaults to search for the dependency file (package-lock.json,
67-
# npm-shrinkwrap.json or yarn.lock) in the repository root, and uses its
68-
# hash as a part of the cache key.
69-
# https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-data
70-
cache-dependency-path: '**/package-lock.json'
56+
# Please update the local install instructions at docs/README.md if
57+
# changing hugo version
58+
- name: Setup Hugo
59+
uses: peaceiris/actions-hugo@16361eb4acea8698b220b76c0d4e84e1fd22c61d # [email protected]
60+
with:
61+
hugo-version: '0.113.0'
62+
extended: true
7163

72-
- name: Install Docsy dependencies
73-
working-directory: ./docs
74-
run: npm ci
64+
# Please update the local install instructions at docs/README.md if
65+
# changing node version
66+
- name: Setup Node
67+
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
68+
with:
69+
node-version: '18'
70+
cache: 'npm'
71+
# The action defaults to search for the dependency file (package-lock.json,
72+
# npm-shrinkwrap.json or yarn.lock) in the repository root, and uses its
73+
# hash as a part of the cache key.
74+
# https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-data
75+
cache-dependency-path: '**/package-lock.json'
7576

76-
- name: Build
77-
working-directory: ./docs
78-
run: hugo --minify
77+
- name: Install Docsy dependencies
78+
working-directory: ./docs
79+
run: npm ci
7980

80-
- name: Copy CNAME to hugo public dir
81-
working-directory: ./docs
82-
run: cp CNAME public/CNAME
81+
- name: Build
82+
working-directory: ./docs
83+
run: hugo --minify
8384

84-
- name: Deploy
85-
uses: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # [email protected]
86-
if: github.ref == 'refs/heads/main'
87-
with:
88-
github_token: ${{ secrets.GITHUB_TOKEN }}
89-
publish_dir: ./docs/public
85+
- name: Copy CNAME to hugo public dir
86+
working-directory: ./docs
87+
run: cp CNAME public/CNAME
88+
89+
- name: Deploy
90+
uses: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # [email protected]
91+
if: github.ref == 'refs/heads/main'
92+
with:
93+
github_token: ${{ secrets.GITHUB_TOKEN }}
94+
publish_dir: ./docs/public

.github/workflows/nightly.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@ jobs:
1313
# Packages write permission required to update a release
1414
packages: write
1515
runs-on:
16-
labels: ubuntu-22.04-8core
16+
labels: ubuntu-24.04-16core
1717
steps:
1818
- name: Install dependencies
1919
run: |
20-
sudo apt-get update
21-
sudo apt-get install -y libomp-dev
20+
./.github/install_clang_version.sh 19
2221
2322
- name: Check out repository code
2423
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # pin@v3

.github/workflows/wheels.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ jobs:
3838
- name: Check out HEIR
3939
uses: actions/checkout@v4
4040

41-
- name: Install dependencies
42-
run: |
43-
sudo apt-get update
44-
sudo apt-get install -y libomp-dev
45-
4641
- uses: actions/setup-python@v5
4742
name: Install Python 3.12
4843
with:

0 commit comments

Comments
 (0)