@@ -48,19 +48,38 @@ jobs:
48
48
run : cargo fmt --all -- --check
49
49
50
50
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 }}
53
52
strategy :
54
53
fail-fast : false
55
54
matrix :
56
55
rust :
57
56
- stable
58
57
- beta
59
58
- 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 }}
64
83
needs : llvm
65
84
66
85
env :
@@ -85,61 +104,48 @@ jobs:
85
104
- uses : Swatinem/rust-cache@v2
86
105
87
106
- name : Check (default features, no system LLVM)
107
+ if : matrix.build-type == 'native'
88
108
run : cargo check
89
109
90
110
- name : Build (default features, no system LLVM)
111
+ if : matrix.build-type == 'native'
91
112
run : cargo build
92
113
93
114
- name : Install btfdump
94
115
if : matrix.rust == 'nightly'
95
116
run : cargo install btfdump
96
117
97
118
- name : Install prerequisites
98
- if : matrix.rust == 'nightly'
119
+ if : matrix.rust == 'nightly' && runner.os == 'Linux' && startsWith(matrix.target.target, 'x86_64')
99
120
# ubuntu-22.04 comes with clang 13-15[0]; support for signed and 64bit
100
121
# enum values was added in clang 15[1] which isn't in `$PATH`.
101
122
#
102
123
# gcc-multilib provides at least <asm/types.h> which is referenced by libbpf.
103
124
#
125
+ # libelf is a dependency of libbpf.
126
+ #
104
127
# [0] https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md
105
128
#
106
129
# [1] https://github.com/llvm/llvm-project/commit/dc1c43d
107
130
run : |
108
131
set -euxo pipefail
109
132
sudo apt update
110
- sudo apt -y install gcc-multilib
133
+ sudo apt -y install gcc-multilib libelf-dev
111
134
echo /usr/lib/llvm-15/bin >> $GITHUB_PATH
112
135
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.
115
139
run : |
116
140
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
136
143
137
144
- name : Restore LLVM
138
- if : matrix.llvm == 'source'
139
145
uses : actions/cache/restore@v4
140
146
with :
141
147
path : llvm-install
142
- key : ${{ needs.llvm.outputs. cache-key }}
148
+ key : ${{ needs.llvm.outputs[format(' cache-key-{0}', matrix.target.target)] }}
143
149
fail-on-cache-miss : true
144
150
145
151
- name : Add LLVM to PATH && LD_LIBRARY_PATH
@@ -160,17 +166,51 @@ jobs:
160
166
cargo clean -p llvm-sys --release
161
167
162
168
- 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.
163
173
164
174
- name : Check
175
+ if : matrix.build-type == 'native'
165
176
run : cargo hack check --feature-powerset
166
177
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
+
167
187
- name : Build
188
+ if : matrix.build-type == 'native'
168
189
run : cargo hack build --feature-powerset
169
190
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
+
170
200
- name : Test
171
- if : matrix.rust == 'nightly'
201
+ if : matrix.build-type == 'native' && matrix. rust == 'nightly'
172
202
run : cargo hack test --feature-powerset
173
203
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
+
174
214
- uses : actions/checkout@v4
175
215
if : matrix.rust == 'nightly'
176
216
with :
@@ -179,10 +219,16 @@ jobs:
179
219
submodules : recursive
180
220
181
221
- 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 }}
184
230
185
231
- name : Run aya integration tests
186
- if : matrix.rust == 'nightly'
232
+ if : matrix.rust == 'nightly' && runner.os == 'Linux' && startsWith(matrix.target.target, 'x86_64')
187
233
working-directory : aya
188
234
run : cargo xtask integration-test local
0 commit comments