Skip to content

Commit ac8d72e

Browse files
committed
Fix musl release builds with vendored SASL and static deps
Vendor Cyrus SASL (PLAIN/SCRAM), OpenSSL, and zlib for x86_64-unknown-linux-musl so the release binary links fully statically without glibc or shared libsasl2.
1 parent b92c843 commit ac8d72e

5 files changed

Lines changed: 52 additions & 12 deletions

File tree

.github/workflows/release.yml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ on:
77
tags:
88
- 'v*.*.*'
99
workflow_dispatch:
10+
inputs:
11+
only_target:
12+
description: 'Build only this target (empty = all)'
13+
required: false
14+
type: choice
15+
options:
16+
- ''
17+
- x86_64-unknown-linux-gnu
18+
- aarch64-unknown-linux-gnu
19+
- x86_64-unknown-linux-musl
20+
- aarch64-apple-darwin
21+
default: ''
1022

1123
env:
1224
CARGO_TERM_COLOR: always
@@ -15,6 +27,7 @@ jobs:
1527
build:
1628
name: Build ${{ matrix.target }}
1729
runs-on: ${{ matrix.os }}
30+
if: ${{ github.event_name != 'workflow_dispatch' || inputs.only_target == '' || inputs.only_target == matrix.target }}
1831
continue-on-error: ${{ matrix.continue-on-error || false }}
1932
permissions:
2033
contents: read
@@ -32,7 +45,6 @@ jobs:
3245
- target: x86_64-unknown-linux-musl
3346
os: ubuntu-latest
3447
binary_name: surreal-sync
35-
continue-on-error: true
3648
# - target: aarch64-unknown-linux-musl
3749
# os: ubuntu-latest
3850
# binary_name: surreal-sync
@@ -79,12 +91,25 @@ jobs:
7991
FEATURES=""
8092
case "${{ matrix.target }}" in
8193
*-musl)
82-
FEATURES="--features vendored-openssl"
94+
FEATURES="--features static-musl"
8395
export CC=musl-gcc
8496
;;
8597
esac
8698
cargo build --release --target ${{ matrix.target }} $FEATURES
8799
100+
- name: Verify static linking (musl)
101+
if: contains(matrix.target, 'musl')
102+
run: |
103+
BIN="target/${{ matrix.target }}/release/${{ matrix.binary_name }}"
104+
file "$BIN"
105+
if readelf -d "$BIN" | grep -q 'NEEDED'; then
106+
echo "Error: musl binary has dynamic library dependencies:"
107+
readelf -d "$BIN" | grep 'NEEDED' || true
108+
ldd "$BIN" || true
109+
exit 1
110+
fi
111+
echo "OK: no dynamic NEEDED entries (fully static)"
112+
88113
- name: Create archive
89114
shell: bash
90115
run: |

Cargo.lock

Lines changed: 12 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ publish = false
4545
[features]
4646
default = []
4747
vendored-openssl = ["dep:openssl"]
48+
# Fully static musl builds: vendored OpenSSL + Kafka static-native (SASL PLAIN/SCRAM, zlib).
49+
static-musl = ["vendored-openssl", "surreal-sync-kafka/static-native"]
4850

4951
[dependencies]
5052
# CLI framework

crates/kafka/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ producer = [
4343
"dep:tempfile",
4444
"dep:tracing-subscriber",
4545
]
46+
# Static/vendored native deps for musl (and similar) builds: OpenSSL, zlib, Cyrus SASL PLAIN+SCRAM.
47+
static-native = [
48+
"rdkafka/ssl-vendored",
49+
"rdkafka/libz-static",
50+
"dep:sasl2-sys",
51+
]
4652

4753
[dependencies]
4854
# types
@@ -69,6 +75,9 @@ clap = { version = "4.5", features = ["derive", "env"], optional = true }
6975
rdkafka = { version = "0.39", features = ["tokio", "sasl"], optional = true }
7076
tokio = { version = "1.49", features = ["full"], optional = true }
7177
tempfile = { version = "3.27", optional = true }
78+
# Feature-unified with rdkafka-sys's sasl2-sys when static-native is enabled.
79+
# plain/scram imply vendored and enable the plugins Kafka SASL auth needs.
80+
sasl2-sys = { version = "0.1.22", features = ["plain", "scram"], optional = true }
7281

7382
# producer
7483
tracing-subscriber = { version = "0.3", features = ["env-filter"], optional = true }

docs/kafka.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ For secured Kafka clusters, set `--security-protocol` to `SASL_PLAINTEXT` or `SA
8282
| `--sasl-password <PASS>` | `KAFKA_SASL_PASSWORD` | SASL password |
8383
| `--sasl-mechanism <MECH>` || `SCRAM-SHA-256`, `SCRAM-SHA-512`, or `PLAIN` |
8484

85+
Kerberos (GSSAPI) is intentionally not supported.
86+
8587
### TLS / mTLS
8688

8789
When `--security-protocol` is `SSL` or `SASL_SSL`, you can configure TLS trust and optional mutual TLS (mTLS) client authentication. These flags map to librdkafka `ssl.*` settings and are ignored for `PLAINTEXT` and `SASL_PLAINTEXT`.

0 commit comments

Comments
 (0)