From 03f10c0d2a2de753977b7085c5350530ff0b84ac Mon Sep 17 00:00:00 2001 From: parazyd Date: Fri, 5 Aug 2022 12:01:49 +0000 Subject: [PATCH] Add support for building with io_uring on Linux. (#621) --- Cargo.toml | 1 + librocksdb-sys/Cargo.toml | 2 ++ librocksdb-sys/build.rs | 7 +++++++ 3 files changed, 10 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index d8a8b31..ada5dba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,7 @@ members = ["librocksdb-sys"] [features] default = ["snappy", "lz4", "zstd", "zlib", "bzip2"] jemalloc = ["librocksdb-sys/jemalloc"] +io-uring = ["librocksdb-sys/io-uring"] valgrind = [] snappy = ["librocksdb-sys/snappy"] lz4 = ["librocksdb-sys/lz4"] diff --git a/librocksdb-sys/Cargo.toml b/librocksdb-sys/Cargo.toml index aa4921e..60d08a0 100644 --- a/librocksdb-sys/Cargo.toml +++ b/librocksdb-sys/Cargo.toml @@ -15,6 +15,7 @@ links = "rocksdb" default = [ "static" ] jemalloc = ["tikv-jemalloc-sys"] static = ["libz-sys?/static", "bzip2-sys?/static"] +io-uring = ["pkg-config"] snappy = [] lz4 = [] zstd = ["zstd-sys"] @@ -37,3 +38,4 @@ uuid = { version = "1.0", features = ["v4"] } cc = { version = "1.0", features = ["parallel"] } bindgen = { version = "0.60", default-features = false, features = ["runtime"] } glob = "0.3" +pkg-config = { version = "0.3", optional = true } diff --git a/librocksdb-sys/build.rs b/librocksdb-sys/build.rs index b778910..fac9abb 100644 --- a/librocksdb-sys/build.rs +++ b/librocksdb-sys/build.rs @@ -220,6 +220,13 @@ fn build_rocksdb() { config.define("WITH_JEMALLOC", "ON"); } + #[cfg(feature = "io-uring")] + if target.contains("linux") { + pkg_config::probe_library("liburing") + .expect("The io-uring feature was requested but the library is not available"); + config.define("ROCKSDB_IOURING_PRESENT", Some("1")); + } + if target.contains("msvc") { config.flag("-EHsc"); config.flag("-std:c++17");