Skip to content

Commit 75851cc

Browse files
x86pupjevolk
authored andcommitted
make static linking io_uring independent from static feature
Signed-off-by: June Strawberry <june@vern.cc>
1 parent 82a1a85 commit 75851cc

3 files changed

Lines changed: 22 additions & 16 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ io-uring = ["rust-librocksdb-sys/io-uring"]
3636
# and the "Coroutines / async MultiGet" section of the README for build
3737
# prerequisites. Linux only.
3838
coroutines = ["rust-librocksdb-sys/coroutines"]
39+
io-uring-static = ["rust-librocksdb-sys/io-uring-static"]
3940
numa = ["rust-librocksdb-sys/numa"]
4041
valgrind = []
4142
snappy = ["rust-librocksdb-sys/snappy"]

librocksdb-sys/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ bindgen-runtime = ["bindgen/runtime"]
3838
bindgen-static = ["bindgen/static"]
3939
mt_static = []
4040
io-uring = []
41+
io-uring-static = []
4142
# Build RocksDB with `USE_COROUTINES=1 USE_FOLLY=1` and link against a folly
4243
# install. Enables the multi-level parallel `MultiGet` async-IO path described
4344
# in the RocksDB blog post "Asynchronous IO in RocksDB". Linux only. Requires

librocksdb-sys/build.rs

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -752,24 +752,28 @@ mod vendor {
752752
#[cfg(feature = "io-uring")]
753753
{
754754
if _target.os == "linux" {
755-
pkg_config::probe_library("liburing").unwrap_or_else(|e| {
756-
panic!(
757-
"the `io-uring` feature was requested but pkg-config probe for \
758-
`liburing` failed: {e}\n\
759-
Hints:\n\
760-
- Debian/Ubuntu: apt-get install liburing-dev\n\
761-
- Fedora/RHEL: dnf install liburing-devel\n\
762-
- Arch: pacman -S liburing\n\
763-
- Alpine: apk add liburing-dev\n\
764-
- or set PKG_CONFIG_PATH to a directory containing liburing.pc\n\
765-
- when cross-compiling, also set PKG_CONFIG_ALLOW_CROSS=1\n\
766-
and point PKG_CONFIG_PATH at the target sysroot's pkgconfig dir."
767-
)
768-
});
755+
// probe_library() only looks for shared objects, so it's
756+
// misleading when statically linking liburing.
757+
if cfg!(not(feature = "io-uring-static")) {
758+
pkg_config::probe_library("liburing").unwrap_or_else(|e| {
759+
panic!(
760+
"the `io-uring` feature was requested but pkg-config probe for \
761+
`liburing` failed: {e}\n\
762+
Hints:\n\
763+
- Debian/Ubuntu: apt-get install liburing-dev\n\
764+
- Fedora/RHEL: dnf install liburing-devel\n\
765+
- Arch: pacman -S liburing\n\
766+
- Alpine: apk add liburing-dev\n\
767+
- or set PKG_CONFIG_PATH to a directory containing liburing.pc\n\
768+
- when cross-compiling, also set PKG_CONFIG_ALLOW_CROSS=1\n\
769+
and point PKG_CONFIG_PATH at the target sysroot's pkgconfig dir."
770+
)
771+
});
772+
}
769773
_cfg.define("ROCKSDB_IOURING_PRESENT", Some("1"));
770774

771-
let mode = if cfg!(feature = "static") { "=static" } else { "" };
772-
if cfg!(feature = "static") {
775+
let mode = if cfg!(feature = "io-uring-static") { "=static" } else { "" };
776+
if cfg!(feature = "io-uring-static") {
773777
// centos uses its /usr/lib64 search path but liburing.a is installed
774778
// by dnf oddly in /usr/lib unlike other installed archives.
775779
println!("cargo:rustc-link-search=native=/usr/lib");

0 commit comments

Comments
 (0)