Add features for building with fuzzing but not linking libfuzzer

Signed-off-by: Victor Porof <victor.porof@gmail.com>
without.crypto
Victor Porof 5 years ago
parent 0603615a2d
commit b92f9a2053
  1. 1
      Cargo.toml
  2. 1
      lmdb-sys/Cargo.toml
  3. 13
      lmdb-sys/build.rs

@ -56,3 +56,4 @@ default = []
with-clang = ["lmdb-rkv-sys/with-clang"]
with-asan = ["lmdb-rkv-sys/with-asan"]
with-fuzzer = ["lmdb-rkv-sys/with-fuzzer"]
with-fuzzer-no-link = ["lmdb-rkv-sys/with-fuzzer-no-link"]

@ -36,6 +36,7 @@ default = []
with-clang = []
with-asan = ["with-clang"]
with-fuzzer = ["with-clang"]
with-fuzzer-no-link = ["with-clang"]
# These features configure the MDB_IDL_LOGN macro, which determines
# the size of the free and dirty page lists (and thus the amount of memory

@ -32,12 +32,23 @@ const MDB_IDL_LOGN: u8 = 15;
)))]
const MDB_IDL_LOGN: u8 = 16;
macro_rules! warn {
($message:expr) => {
println!("cargo:warning={}", $message);
};
}
fn main() {
let mut lmdb = PathBuf::from(&env::var("CARGO_MANIFEST_DIR").unwrap());
lmdb.push("lmdb");
lmdb.push("libraries");
lmdb.push("liblmdb");
if cfg!(feature = "with-fuzzer") && cfg!(feature = "with-fuzzer-no-link") {
warn!("Features `with-fuzzer` and `with-fuzzer-no-link` are mutually exclusive.");
warn!("Building with `-fsanitize=fuzzer`.");
}
if !pkg_config::find_library("liblmdb").is_ok() {
let mut builder = cc::Build::new();
@ -60,6 +71,8 @@ fn main() {
if env::var("CARGO_FEATURE_WITH_FUZZER").is_ok() {
builder.flag("-fsanitize=fuzzer");
} else if env::var("CARGO_FEATURE_WITH_FUZZER_NO_LINK").is_ok() {
builder.flag("-fsanitize=fuzzer-no-link");
}
builder.compile("liblmdb.a")

Loading…
Cancel
Save