@@ -48,19 +48,38 @@ jobs:
4848 run : cargo fmt --all -- --check
4949
5050 build :
51- # We don't use ubuntu-latest because we care about the apt packages available.
52- runs-on : ubuntu-22.04
51+ runs-on : ${{ matrix.target.os }}
5352 strategy :
5453 fail-fast : false
5554 matrix :
5655 rust :
5756 - stable
5857 - beta
5958 - nightly
60- llvm :
61- - 19
62- - source
63- name : rustc=${{ matrix.rust }} llvm=${{ matrix.llvm }}
59+ # We don't use ubuntu-latest because we care about the apt packages available.
60+ target :
61+ - os : macos-14
62+ target : aarch64-apple-darwin
63+ build-type : native
64+ - os : macos-13
65+ target : x86_64-apple-darwin
66+ build-type : native
67+ - os : ubuntu-22.04
68+ target : aarch64-unknown-linux-gnu
69+ build-type : cross
70+ - os : ubuntu-22.04
71+ target : aarch64-unknown-linux-musl
72+ build-type : cross
73+ - os : ubuntu-22.04
74+ target : riscv64gc-unknown-linux-gnu
75+ build-type : cross
76+ - os : ubuntu-22.04
77+ target : x86_64-unknown-linux-gnu
78+ build-type : native
79+ - os : ubuntu-22.04
80+ target : x86_64-unknown-linux-musl
81+ build-type : cross
82+ name : rustc=${{ matrix.rust }} target=${{ matrix.target.target }}
6483 needs : llvm
6584
6685 env :
@@ -85,61 +104,48 @@ jobs:
85104 - uses : Swatinem/rust-cache@v2
86105
87106 - name : Check (default features, no system LLVM)
107+ if : matrix.build-type == 'native'
88108 run : cargo check
89109
90110 - name : Build (default features, no system LLVM)
111+ if : matrix.build-type == 'native'
91112 run : cargo build
92113
93114 - name : Install btfdump
94115 if : matrix.rust == 'nightly'
95116 run : cargo install btfdump
96117
97118 - name : Install prerequisites
98- if : matrix.rust == 'nightly'
119+ if : matrix.rust == 'nightly' && runner.os == 'Linux' && startsWith(matrix.target.target, 'x86_64')
99120 # ubuntu-22.04 comes with clang 13-15[0]; support for signed and 64bit
100121 # enum values was added in clang 15[1] which isn't in `$PATH`.
101122 #
102123 # gcc-multilib provides at least <asm/types.h> which is referenced by libbpf.
103124 #
125+ # libelf is a dependency of libbpf.
126+ #
104127 # [0] https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md
105128 #
106129 # [1] https://github.com/llvm/llvm-project/commit/dc1c43d
107130 run : |
108131 set -euxo pipefail
109132 sudo apt update
110- sudo apt -y install gcc-multilib
133+ sudo apt -y install gcc-multilib libelf-dev
111134 echo /usr/lib/llvm-15/bin >> $GITHUB_PATH
112135
113- - name : Install LLVM
114- if : matrix.llvm != 'source'
136+ - name : Install prerequisites
137+ if : runner.os == 'macOS'
138+ # We need system-wide LLVM only for FileCheck.
115139 run : |
116140 set -euxo pipefail
117- wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
118- echo -e deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-${{ matrix.llvm }} main | sudo tee /etc/apt/sources.list.d/llvm.list
119-
120- sudo apt update
121- # TODO(vadorovsky): Remove the requirement of libpolly.
122- #
123- # Packages from apt.llvm.org are being built all at once, with one
124- # cmake build with superset of options, then different binaries and
125- # libraries are being included in different packages.
126- #
127- # That results in `llvm-config --libname --link-static` mentioning
128- # libpolly, even if it's not installed. The output of that command is
129- # being used in build.rs of llvm-sys, so building llvm-sys on such
130- # system is complaining about lack of libpolly.
131- #
132- # Hopefully that nightmare goes away once we switch to binstalls and
133- # ditch the system LLVM option.
134- sudo apt -y install llvm-${{ matrix.llvm }}-dev libpolly-${{ matrix.llvm }}-dev
135- echo /usr/lib/llvm-${{ matrix.llvm }}/bin >> $GITHUB_PATH
141+ brew install llvm
142+ echo $(brew --prefix)/opt/llvm/bin >> $GITHUB_PATH
136143
137144 - name : Restore LLVM
138- if : matrix.llvm == 'source'
139145 uses : actions/cache/restore@v4
140146 with :
141147 path : llvm-install
142- key : ${{ needs.llvm.outputs. cache-key }}
148+ key : ${{ needs.llvm.outputs[format(' cache-key-{0}', matrix.target.target)] }}
143149 fail-on-cache-miss : true
144150
145151 - name : Add LLVM to PATH && LD_LIBRARY_PATH
@@ -160,17 +166,51 @@ jobs:
160166 cargo clean -p llvm-sys --release
161167
162168 - uses : taiki-e/install-action@cargo-hack
169+ if : matrix.build-type == 'native'
170+
171+ # Run cargo commands with `cargo hack` for native targets.
172+ # Run cargo commands with `xtask` for all targets.
163173
164174 - name : Check
175+ if : matrix.build-type == 'native'
165176 run : cargo hack check --feature-powerset
166177
178+ - name : Check (xtask)
179+ run : |
180+ cargo xtask check \
181+ --container-engine podman \
182+ --container-tag initial \
183+ --llvm-install-dir "${{ github.workspace }}/llvm-install" \
184+ --pull always \
185+ --target ${{ matrix.target.target }}
186+
167187 - name : Build
188+ if : matrix.build-type == 'native'
168189 run : cargo hack build --feature-powerset
169190
191+ - name : Build (xtask)
192+ run : |
193+ cargo xtask build \
194+ --container-engine podman \
195+ --container-tag initial \
196+ --llvm-install-dir "${{ github.workspace }}/llvm-install" \
197+ --pull always \
198+ --target ${{ matrix.target.target }}
199+
170200 - name : Test
171- if : matrix.rust == 'nightly'
201+ if : matrix.build-type == 'native' && matrix. rust == 'nightly'
172202 run : cargo hack test --feature-powerset
173203
204+ - name : Test (xtask)
205+ if : matrix.rust == 'nightly'
206+ run : |
207+ cargo xtask test \
208+ --container-engine podman \
209+ --container-tag initial \
210+ --llvm-install-dir "${{ github.workspace }}/llvm-install" \
211+ --pull always \
212+ --target ${{ matrix.target.target }}
213+
174214 - uses : actions/checkout@v4
175215 if : matrix.rust == 'nightly'
176216 with :
@@ -179,10 +219,16 @@ jobs:
179219 submodules : recursive
180220
181221 - name : Install
182- if : matrix.rust == 'nightly'
183- run : cargo install --path . --no-default-features
222+ if : matrix.rust == 'nightly' && runner.os == 'Linux' && startsWith(matrix.target.target, 'x86_64')
223+ run : |
224+ cargo xtask install \
225+ --container-engine podman \
226+ --container-tag initial \
227+ --llvm-install-dir "${{ github.workspace }}/llvm-install" \
228+ --pull always \
229+ --target ${{ matrix.target.target }}
184230
185231 - name : Run aya integration tests
186- if : matrix.rust == 'nightly'
232+ if : matrix.rust == 'nightly' && runner.os == 'Linux' && startsWith(matrix.target.target, 'x86_64')
187233 working-directory : aya
188234 run : cargo xtask integration-test local
0 commit comments