Skip to content

Commit 638218d

Browse files
authored
build musl wheels (#155)
* build musl wheels * try building with static bindgen * install zlib and ncurses * include gcc header search path * try again * try again * detailed isystem * fix missing bits headers * fix missing crt objects * try using soft-link for libgcc * run test in container * add test folder * fix tests * fix pip install * fix the default-features of librocksdb-sys * add all wheels back
1 parent 8bee8c6 commit 638218d

File tree

4 files changed

+210
-5
lines changed

4 files changed

+210
-5
lines changed

.github/workflows/CI.yml

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: CI musl
22

33
on:
44
release:
@@ -278,6 +278,102 @@ jobs:
278278
name: wheels-manylinux2014-${{ matrix.target }}
279279
path: dist
280280

281+
musllinux_1_2_x86_64:
282+
runs-on: ubuntu-latest
283+
strategy:
284+
fail-fast: false
285+
matrix:
286+
target: [x86_64]
287+
steps:
288+
- uses: actions/checkout@v2
289+
with:
290+
submodules: recursive
291+
- name: Build Wheels
292+
uses: messense/maturin-action@v1
293+
with:
294+
rust-toolchain: 1.82.0
295+
rustup-components: rustfmt
296+
target: ${{ matrix.target }}
297+
manylinux: musllinux_1_2
298+
args: --release --no-default-features --features bindgen-static --out dist --interpreter '3.7 3.8 3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10'
299+
container: congyuwang/musllinux_1_2_x86_64:llvm-19.1.3
300+
before-script-linux: |
301+
apk update
302+
apk add ncurses-static
303+
apk add zlib-static
304+
ln -s /usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/crtbeginS.o /usr/lib/crtbeginS.o
305+
ln -s /usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/crtendS.o /usr/lib/crtendS.o
306+
ln -s /usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/libgcc.a /usr/lib/libgcc.a
307+
env:
308+
LIBCLANG_PATH: /usr/local/lib
309+
CC: /usr/local/bin/clang
310+
CXX: /usr/local/bin/clang++
311+
AR: /usr/local/bin/llvm-ar
312+
CFLAGS: "-flto=thin -O3 -isystem/usr/include"
313+
CXXFLAGS: "-flto=thin -O3 -isystem/usr/include/c++/13.2.1/ -isystem/usr/include -isystem/usr/include/c++/13.2.1/x86_64-alpine-linux-musl"
314+
RUSTFLAGS: "-Clinker-plugin-lto -Clinker=/usr/local/bin/clang -Clink-arg=-fuse-ld=/usr/local/bin/ld.lld"
315+
LLVM_CONFIG_PATH: /root/llvm_config.sh
316+
LIBCLANG_STATIC_PATH: /usr/local/lib
317+
- name: Run Tests
318+
run: |
319+
docker run --rm -v ${{ github.workspace }}/dist:/dist:ro -v ${{ github.workspace }}/test:/test:ro congyuwang/musllinux_1_2_x86_64:llvm-19.1.3 bash -c "
320+
python3.12 -m pip install rocksdict --no-index --find-links /dist --force-reinstall || true
321+
python3.12 -m pip install speedict --no-index --find-links /dist --force-reinstall || true
322+
python3.12 -m unittest discover -v /test"
323+
- name: Upload artifacts
324+
uses: actions/upload-artifact@v4
325+
with:
326+
name: wheels-musllinux_1_2-x86_64
327+
path: dist
328+
329+
musllinux_1_2_arm64:
330+
runs-on: linux-arm64
331+
strategy:
332+
fail-fast: false
333+
matrix:
334+
target: [aarch64]
335+
steps:
336+
- uses: actions/checkout@v2
337+
with:
338+
submodules: recursive
339+
- name: Build Wheels
340+
uses: messense/maturin-action@v1
341+
with:
342+
rust-toolchain: 1.82.0
343+
rustup-components: rustfmt
344+
target: ${{ matrix.target }}
345+
manylinux: musllinux_1_2
346+
args: --release --no-default-features --features bindgen-static --out dist --interpreter '3.7 3.8 3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10'
347+
container: congyuwang/musllinux_1_2_aarch64:llvm-19.1.3
348+
before-script-linux: |
349+
apk update
350+
apk add ncurses-static
351+
apk add zlib-static
352+
ln -s /usr/lib/gcc/aarch64-alpine-linux-musl/13.2.1/crtbeginS.o /usr/lib/crtbeginS.o
353+
ln -s /usr/lib/gcc/aarch64-alpine-linux-musl/13.2.1/crtendS.o /usr/lib/crtendS.o
354+
ln -s /usr/lib/gcc/aarch64-alpine-linux-musl/13.2.1/libgcc.a /usr/lib/libgcc.a
355+
env:
356+
LIBCLANG_PATH: /usr/local/lib
357+
CC: /usr/local/bin/clang
358+
CXX: /usr/local/bin/clang++
359+
AR: /usr/local/bin/llvm-ar
360+
CFLAGS: "-flto=thin -O3 -isystem/usr/include"
361+
CXXFLAGS: "-flto=thin -O3 -isystem/usr/include/c++/13.2.1/ -isystem/usr/include -isystem/usr/include/c++/13.2.1/aarch64-alpine-linux-musl"
362+
RUSTFLAGS: "-Clinker-plugin-lto -Clinker=/usr/local/bin/clang -Clink-arg=-fuse-ld=/usr/local/bin/ld.lld"
363+
LLVM_CONFIG_PATH: /root/llvm_config.sh
364+
LIBCLANG_STATIC_PATH: /usr/local/lib
365+
- name: Run Tests
366+
run: |
367+
docker run --rm -v ${{ github.workspace }}/dist:/dist:ro -v ${{ github.workspace }}/test:/test:ro congyuwang/musllinux_1_2_aarch64:llvm-19.1.3 bash -c "
368+
python3.12 -m pip install rocksdict --no-index --find-links /dist --force-reinstall || true
369+
python3.12 -m pip install speedict --no-index --find-links /dist --force-reinstall || true
370+
python3.12 -m unittest discover -v /test"
371+
- name: Upload artifacts
372+
uses: actions/upload-artifact@v4
373+
with:
374+
name: wheels-musllinux_1_2-arm64
375+
path: dist
376+
281377
release:
282378
name: Release
283379
runs-on: ubuntu-latest
@@ -289,6 +385,8 @@ jobs:
289385
manylinux2014_x86_64,
290386
manylinux_2_28_arm64,
291387
manylinux2014_arm64,
388+
musllinux_1_2_x86_64,
389+
musllinux_1_2_arm64,
292390
]
293391
steps:
294392
- uses: actions/download-artifact@v4

.github/workflows/PR.yml

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: PR check
1+
name: PR check musl
22

33
on:
44
pull_request:
@@ -277,3 +277,99 @@ jobs:
277277
with:
278278
name: wheels-manylinux2014-${{ matrix.target }}
279279
path: dist
280+
281+
musllinux_1_2_x86_64:
282+
runs-on: ubuntu-latest
283+
strategy:
284+
fail-fast: false
285+
matrix:
286+
target: [x86_64]
287+
steps:
288+
- uses: actions/checkout@v2
289+
with:
290+
submodules: recursive
291+
- name: Build Wheels
292+
uses: messense/maturin-action@v1
293+
with:
294+
rust-toolchain: 1.82.0
295+
rustup-components: rustfmt
296+
target: ${{ matrix.target }}
297+
manylinux: musllinux_1_2
298+
args: --release --no-default-features --features bindgen-static --out dist --interpreter '3.7 3.8 3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10'
299+
container: congyuwang/musllinux_1_2_x86_64:llvm-19.1.3
300+
before-script-linux: |
301+
apk update
302+
apk add ncurses-static
303+
apk add zlib-static
304+
ln -s /usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/crtbeginS.o /usr/lib/crtbeginS.o
305+
ln -s /usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/crtendS.o /usr/lib/crtendS.o
306+
ln -s /usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/libgcc.a /usr/lib/libgcc.a
307+
env:
308+
LIBCLANG_PATH: /usr/local/lib
309+
CC: /usr/local/bin/clang
310+
CXX: /usr/local/bin/clang++
311+
AR: /usr/local/bin/llvm-ar
312+
CFLAGS: "-flto=thin -O3 -isystem/usr/include"
313+
CXXFLAGS: "-flto=thin -O3 -isystem/usr/include/c++/13.2.1/ -isystem/usr/include -isystem/usr/include/c++/13.2.1/x86_64-alpine-linux-musl"
314+
RUSTFLAGS: "-Clinker-plugin-lto -Clinker=/usr/local/bin/clang -Clink-arg=-fuse-ld=/usr/local/bin/ld.lld"
315+
LLVM_CONFIG_PATH: /root/llvm_config.sh
316+
LIBCLANG_STATIC_PATH: /usr/local/lib
317+
- name: Run Tests
318+
run: |
319+
docker run --rm -v ${{ github.workspace }}/dist:/dist:ro -v ${{ github.workspace }}/test:/test:ro congyuwang/musllinux_1_2_x86_64:llvm-19.1.3 bash -c "
320+
python3.12 -m pip install rocksdict --no-index --find-links /dist --force-reinstall || true
321+
python3.12 -m pip install speedict --no-index --find-links /dist --force-reinstall || true
322+
python3.12 -m unittest discover -v /test"
323+
- name: Upload artifacts
324+
uses: actions/upload-artifact@v4
325+
with:
326+
name: wheels-musllinux_1_2-x86_64
327+
path: dist
328+
329+
musllinux_1_2_arm64:
330+
runs-on: linux-arm64
331+
strategy:
332+
fail-fast: false
333+
matrix:
334+
target: [aarch64]
335+
steps:
336+
- uses: actions/checkout@v2
337+
with:
338+
submodules: recursive
339+
- name: Build Wheels
340+
uses: messense/maturin-action@v1
341+
with:
342+
rust-toolchain: 1.82.0
343+
rustup-components: rustfmt
344+
target: ${{ matrix.target }}
345+
manylinux: musllinux_1_2
346+
args: --release --no-default-features --features bindgen-static --out dist --interpreter '3.7 3.8 3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10'
347+
container: congyuwang/musllinux_1_2_aarch64:llvm-19.1.3
348+
before-script-linux: |
349+
apk update
350+
apk add ncurses-static
351+
apk add zlib-static
352+
ln -s /usr/lib/gcc/aarch64-alpine-linux-musl/13.2.1/crtbeginS.o /usr/lib/crtbeginS.o
353+
ln -s /usr/lib/gcc/aarch64-alpine-linux-musl/13.2.1/crtendS.o /usr/lib/crtendS.o
354+
ln -s /usr/lib/gcc/aarch64-alpine-linux-musl/13.2.1/libgcc.a /usr/lib/libgcc.a
355+
env:
356+
LIBCLANG_PATH: /usr/local/lib
357+
CC: /usr/local/bin/clang
358+
CXX: /usr/local/bin/clang++
359+
AR: /usr/local/bin/llvm-ar
360+
CFLAGS: "-flto=thin -O3 -isystem/usr/include"
361+
CXXFLAGS: "-flto=thin -O3 -isystem/usr/include/c++/13.2.1/ -isystem/usr/include -isystem/usr/include/c++/13.2.1/aarch64-alpine-linux-musl"
362+
RUSTFLAGS: "-Clinker-plugin-lto -Clinker=/usr/local/bin/clang -Clink-arg=-fuse-ld=/usr/local/bin/ld.lld"
363+
LLVM_CONFIG_PATH: /root/llvm_config.sh
364+
LIBCLANG_STATIC_PATH: /usr/local/lib
365+
- name: Run Tests
366+
run: |
367+
docker run --rm -v ${{ github.workspace }}/dist:/dist:ro -v ${{ github.workspace }}/test:/test:ro congyuwang/musllinux_1_2_aarch64:llvm-19.1.3 bash -c "
368+
python3.12 -m pip install rocksdict --no-index --find-links /dist --force-reinstall || true
369+
python3.12 -m pip install speedict --no-index --find-links /dist --force-reinstall || true
370+
python3.12 -m unittest discover -v /test"
371+
- name: Upload artifacts
372+
uses: actions/upload-artifact@v4
373+
with:
374+
name: wheels-musllinux_1_2-arm64
375+
path: dist

Cargo.toml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,24 @@ path = "bin/create-cf-db/main.rs"
1616
test = false
1717

1818
[dependencies]
19-
rocksdb = { path = "rust-rocksdb" }
20-
librocksdb-sys = { path = "rust-rocksdb/librocksdb-sys" }
19+
rocksdb = { path = "rust-rocksdb", default-features = false, features = [
20+
"snappy",
21+
"lz4",
22+
"zstd",
23+
"zlib",
24+
"bzip2",
25+
] }
26+
librocksdb-sys = { path = "rust-rocksdb/librocksdb-sys", default-features = false }
2127
serde = { version = "1", features = ["derive"] }
2228
serde_json = "1"
2329
num-bigint = "0.4"
2430
libc = "0.2"
2531

32+
[features]
33+
default = ["bindgen-runtime"]
34+
bindgen-runtime = ["rocksdb/bindgen-runtime"]
35+
bindgen-static = ["rocksdb/bindgen-static"]
36+
2637
[dependencies.pyo3]
2738
version = "0.22"
2839
features = ["py-clone", "extension-module", "num-bigint"]

rust-rocksdb

0 commit comments

Comments
 (0)