Skip to content

Commit e5e0345

Browse files
committed
fix(ci/edriver): link against zstd-static on Alpine instead of vendored-libelf
Alpine 3.20 libelf-static IS compiled WITH zstd support, so linking system libelf.a introduces ZSTD_* symbol references. Root cause of the new error: - host == target on Alpine (both x86_64-unknown-linux-musl) - Cargo resolver=2 only separates features when host != target; when they match, libbpf-sys features are unified between [dependencies] and [build-dependencies] - static-libelf (from libbpf-rs/static) bleeds into the build-script compilation, causing the build.rs to emit cargo:rustc-link-lib=elf against the system libelf.a (which has ZSTD refs) Fix: install zstd-static on Alpine and add '-l static=zstd' to RUSTFLAGS so the linker can resolve ZSTD_* from /usr/lib/libzstd.a. vendored-libelf is not used on Alpine to avoid the elfutils configure argp/fts failure chain on musl. Changes: - matrix: add rustflags field per arch (x86_64 gets -lzstd, aarch64 doesn't) - Alpine apk: add zstd-dev zstd-static - Build/Test env: RUSTFLAGS uses matrix.rustflags - Cache key bumped to v5
1 parent 8473e1a commit e5e0345

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

.github/workflows/ci-edriver.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,13 @@ jobs:
3232
# zlib-static installs libz.a to /lib (not /usr/lib) on Alpine 3.20.
3333
lib_path: /lib:/usr/lib
3434
extra_cflags: ""
35-
# Alpine libelf-static is musl-native, no zstd dep: no vendored-libelf.
35+
# Alpine libelf-static is musl-native but IS compiled WITH zstd.
36+
# We link against system zstd-static instead of using vendored-libelf
37+
# (vendored-libelf fails on musl because elfutils configure requires
38+
# glibc-only argp/fts). The extra '-l static=zstd' tells rustc to
39+
# include /usr/lib/libzstd.a when linking.
3640
cargo_extra_features: ""
41+
rustflags: "-C target-feature=+crt-static -l static=zstd"
3742
- arch: aarch64
3843
runner: ubuntu-24.04-arm
3944
target: aarch64-unknown-linux-musl
@@ -48,7 +53,9 @@ jobs:
4853
# Ubuntu libelf is glibc-compiled: must vendored-compile elfutils.
4954
# elfutils configure needs argp+fts which exist on glibc (Ubuntu) but
5055
# not on musl (Alpine), hence this is Ubuntu-only.
56+
# vendored-libelf is compiled --without-zstd, so no -lzstd needed.
5157
cargo_extra_features: ",vendored-libelf"
58+
rustflags: "-C target-feature=+crt-static"
5259
steps:
5360
# ── Alpine (x86_64) ─────────────────────────────────────────────────
5461
# Install BEFORE actions/checkout so git/bash/curl are available for
@@ -62,6 +69,7 @@ jobs:
6269
clang llvm \
6370
elfutils-dev libelf-static \
6471
zlib-dev zlib-static \
72+
zstd-dev zstd-static \
6573
protobuf-dev \
6674
pkgconf
6775
@@ -98,8 +106,8 @@ jobs:
98106
path: |
99107
~/.cargo/registry
100108
~/.cargo/git
101-
key: ${{ matrix.arch }}-cargo-edriver-v4-${{ hashFiles('plugins/edriver/Cargo.lock') }}
102-
restore-keys: ${{ matrix.arch }}-cargo-edriver-v4-
109+
key: ${{ matrix.arch }}-cargo-edriver-v5-${{ hashFiles('plugins/edriver/Cargo.lock') }}
110+
restore-keys: ${{ matrix.arch }}-cargo-edriver-v5-
103111

104112
- name: Verify toolchain
105113
run: |
@@ -122,7 +130,7 @@ jobs:
122130
CC_aarch64_unknown_linux_musl: ${{ matrix.cc }}
123131
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER: ${{ matrix.cc }}
124132
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: ${{ matrix.cc }}
125-
RUSTFLAGS: "-C target-feature=+crt-static"
133+
RUSTFLAGS: ${{ matrix.rustflags }}
126134
# Activates vendored-libelf only on Ubuntu aarch64 (see matrix).
127135
CARGO_EXTRA_FEATURES: ${{ matrix.cargo_extra_features }}
128136

@@ -138,5 +146,5 @@ jobs:
138146
CC_aarch64_unknown_linux_musl: ${{ matrix.cc }}
139147
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER: ${{ matrix.cc }}
140148
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: ${{ matrix.cc }}
141-
RUSTFLAGS: "-C target-feature=+crt-static"
149+
RUSTFLAGS: ${{ matrix.rustflags }}
142150
CARGO_EXTRA_FEATURES: ${{ matrix.cargo_extra_features }}

0 commit comments

Comments
 (0)