ci: Enable `llvm-link-static` feature for bpf-linker

Rust CI does not provide dynamic libLLVM tarballs for macOS—only static
ones. Since recent versions of bpf-linker require explicit linkage
configuration for libLLVM, enable the `llvm-link-static` feature to
ensure correct static linking.

Make sure bpf-linker's build.rs sees the downloaded LLVM by adding it
to PATH. On macOS, set the `{CXXSTDLIB,ZLIB}_PATH` variables to point
to the brew prefixes with static libraries it needs.
reviewable/pr1409/r1
Michal R 2 weeks ago
parent 7a3c03e178
commit f76a0db322

@ -279,6 +279,10 @@ jobs:
brew bundle brew bundle
echo $(brew --prefix curl)/bin >> $GITHUB_PATH echo $(brew --prefix curl)/bin >> $GITHUB_PATH
echo $(brew --prefix llvm)/bin >> $GITHUB_PATH echo $(brew --prefix llvm)/bin >> $GITHUB_PATH
# Point bpf-linker's build.rs to the brew prefixes with static
# libraries it needs.
echo "CXXSTDLIB_PATH=$(brew --prefix llvm)/lib/c++" >> $GITHUB_ENV
echo "ZLIB_PATH=$(brew --prefix zlib)/lib" >> $GITHUB_ENV
# https://github.com/actions/setup-python/issues/577 # https://github.com/actions/setup-python/issues/577
find /usr/local/bin -type l -exec sh -c 'readlink -f "$1" \ find /usr/local/bin -type l -exec sh -c 'readlink -f "$1" \
@ -324,7 +328,7 @@ jobs:
esac esac
case "${{ runner.os }}" in case "${{ runner.os }}" in
Linux) Linux)
target=${arch}-unknown-linux-gnu target=${arch}-unknown-linux-musl
;; ;;
macOS) macOS)
target=${arch}-apple-darwin target=${arch}-apple-darwin
@ -341,8 +345,13 @@ jobs:
# NB: rustc doesn't ship libLLVM.so on macOS, so disable proxying (default feature). We also # NB: rustc doesn't ship libLLVM.so on macOS, so disable proxying (default feature). We also
# --force so that bpf-linker gets always relinked against the latest LLVM downloaded above. # --force so that bpf-linker gets always relinked against the latest LLVM downloaded above.
# #
# Add the downloaded LLVM to PATH for this build step.
#
# Do this on all system (not just macOS) to avoid relying on rustc-provided libLLVM.so. # Do this on all system (not just macOS) to avoid relying on rustc-provided libLLVM.so.
- run: cargo install --git https://github.com/aya-rs/bpf-linker.git bpf-linker --no-default-features --features llvm-21 --force - run: |
PATH="/tmp/rustc-llvm/bin:$PATH" cargo install \
--git https://github.com/aya-rs/bpf-linker.git bpf-linker \
--no-default-features --features llvm-21,llvm-link-static --force
- uses: actions/cache@v4 - uses: actions/cache@v4
with: with:

Loading…
Cancel
Save