Skip to content

Commit e06897d

Browse files
committed
chore: upgrade criterion to 0.7
1 parent 4bff765 commit e06897d

File tree

17 files changed

+5353
-25
lines changed

17 files changed

+5353
-25
lines changed

.github/workflows/rust.yml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ jobs:
1515
with:
1616
toolchain: 1.89.0
1717
components: rustfmt
18-
override: true
1918
- name: Check formatting
2019
run: |
2120
cargo fmt --all -- --check
@@ -32,8 +31,7 @@ jobs:
3231
uses: dtolnay/rust-toolchain@stable
3332
with:
3433
toolchain: 1.89.0
35-
components: clippy
36-
override: true
34+
components: clippy rustfmt
3735
- run: sudo apt update && sudo apt install -y libclang-dev
3836
- name: Run clippy
3937
run: |
@@ -90,23 +88,19 @@ jobs:
9088
with:
9189
toolchain: 1.89.0
9290
target: ${{ matrix.target }}
93-
profile: minimal
94-
override: true
91+
components: rustfmt
9592
- name: Remove msys64 # Workaround to resolve link error with C:\msys64\mingw64\bin\libclang.dll
9693
if: runner.os == 'Windows'
9794
run: Remove-Item -LiteralPath "C:\msys64\" -Force -Recurse
9895
- name: Install dependencies
9996
if: runner.os == 'Windows'
100-
run: choco install llvm -y
101-
- name: Install libclang-dev
102-
if: runner.os == 'Linux'
103-
run: sudo apt install libclang-dev
104-
- name: Install jemalloc
105-
if: runner.os == 'Linux'
106-
run: sudo apt install libjemalloc-dev
107-
- name: Install liburing
97+
run: vcpkg install llvm
98+
- name: Install dependencies (macOS)
99+
if: runner.os == 'macOS'
100+
run: brew install llvm lld
101+
- name: Install dependencies (Linux)
108102
if: runner.os == 'Linux'
109-
run: sudo apt install liburing-dev
103+
run: sudo apt-get update && sudo apt-get install -y libclang-dev libjemalloc-dev liburing-dev
110104
- name: Debug librocksdb-sys tests
111105
if: runner.os == 'Linux' || runner.os == 'Windows'
112106
run: clang --version && env

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@
77
[submodule "librocksdb-sys/lz4"]
88
path = librocksdb-sys/lz4
99
url = https://github.com/lz4/lz4.git
10+
[submodule "librocksdb-sys/zstd"]
11+
path = librocksdb-sys/zstd
12+
url = https://github.com/facebook/zstd.git
13+
[submodule "librocksdb-sys/zlib"]
14+
path = librocksdb-sys/zlib
15+
url = https://github.com/madler/zlib.git

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ serde = { version = "1", features = ["derive"], optional = true }
4141

4242
[dev-dependencies]
4343
trybuild = "1.0"
44-
criterion = "0.5"
44+
criterion = "0.7"
4545

4646
[[bench]]
4747
name = "transaction"

librocksdb-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ uuid = { version = "1.0", features = ["v4"] }
5050

5151
[build-dependencies]
5252
cc = { version = "1.0", features = ["parallel"] }
53-
bindgen = { version = "0.72.1", default-features = false }
53+
bindgen = { version = "0.72.1" }
5454
glob = "0.3.2"
5555
pkg-config = "0.3"
5656
rust-ini = "0.21"

librocksdb-sys/build.rs

Lines changed: 119 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
compile_error!("feature 'portable' and feature 'march-native' cannot be enabled at the same time");
33

44
use std::env;
5+
use std::ffi::OsStr;
56
use std::fs;
67
use std::path::{Path, PathBuf};
78
use std::process::Command;
@@ -128,23 +129,18 @@ fn build_rocksdb() {
128129

129130
if cfg!(feature = "zstd") {
130131
config.define("ZSTD", Some("1"));
131-
if let Some(path) = env::var_os("DEP_ZSTD_INCLUDE") {
132-
config.include(path);
133-
}
132+
config.include("zstd/lib/");
133+
config.include("zstd/lib/dictBuilder/");
134134
}
135135

136136
if cfg!(feature = "zlib") {
137137
config.define("ZLIB", Some("1"));
138-
if let Some(path) = env::var_os("DEP_Z_INCLUDE") {
139-
config.include(path);
140-
}
138+
config.include("zlib/");
141139
}
142140

143141
if cfg!(feature = "bzip2") {
144142
config.define("BZIP2", Some("1"));
145-
if let Some(path) = env::var_os("DEP_BZIP2_INCLUDE") {
146-
config.include(path);
147-
}
143+
config.include("bzip2/");
148144
}
149145

150146
if cfg!(feature = "rtti") {
@@ -385,6 +381,105 @@ fn build_lz4() {
385381
compiler.compile("liblz4.a");
386382
}
387383

384+
fn build_zstd() {
385+
let mut compiler = cc::Build::new();
386+
387+
compiler.include("zstd/lib/");
388+
compiler.include("zstd/lib/common");
389+
compiler.include("zstd/lib/legacy");
390+
391+
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default();
392+
393+
for dir in &[
394+
"zstd/lib/common",
395+
"zstd/lib/compress",
396+
"zstd/lib/decompress",
397+
"zstd/lib/dictBuilder",
398+
"zstd/lib/legacy",
399+
] {
400+
let mut entries: Vec<_> = fs::read_dir(dir)
401+
.unwrap()
402+
.map(Result::unwrap)
403+
.filter_map(|entry| {
404+
let filename = entry.file_name();
405+
406+
if Path::new(&filename).extension() == Some(OsStr::new("c"))
407+
// Skip xxhash*.c files: since we are using the "PRIVATE API"
408+
// mode, it will be inlined in the headers.
409+
&& !filename.to_string_lossy().contains("xxhash")
410+
{
411+
Some(entry.path())
412+
} else {
413+
None
414+
}
415+
})
416+
.collect();
417+
entries.sort();
418+
419+
compiler.files(entries);
420+
}
421+
422+
if target_arch.contains("x86_64") {
423+
if env::var("CARGO_CFG_WINDOWS").is_ok() {
424+
compiler.define("ZSTD_DISABLE_ASM", Some(""));
425+
} else {
426+
compiler.file("zstd/lib/decompress/huf_decompress_amd64.S");
427+
}
428+
} else {
429+
compiler.define("ZSTD_DISABLE_ASM", Some(""));
430+
}
431+
432+
compiler.opt_level(3);
433+
compiler.extra_warnings(false);
434+
compiler
435+
.flag_if_supported("-ffunction-sections")
436+
.flag_if_supported("-fdata-sections")
437+
.flag_if_supported("-fmerge-all-constants");
438+
439+
compiler.define("ZSTD_LIB_DEPRECATED", Some("0"));
440+
compiler.compile("libzstd.a");
441+
}
442+
443+
fn build_zlib() {
444+
let mut compiler = cc::Build::new();
445+
446+
let globs = &["zlib/*.c"];
447+
448+
for pattern in globs {
449+
for path in glob::glob(pattern).unwrap() {
450+
let path = path.unwrap();
451+
compiler.file(path);
452+
}
453+
}
454+
455+
compiler.flag_if_supported("-Wno-implicit-function-declaration");
456+
compiler.opt_level(3);
457+
compiler.extra_warnings(false);
458+
compiler.compile("libz.a");
459+
}
460+
461+
fn build_bzip2() {
462+
let mut compiler = cc::Build::new();
463+
464+
compiler
465+
.file("bzip2/blocksort.c")
466+
.file("bzip2/bzlib.c")
467+
.file("bzip2/compress.c")
468+
.file("bzip2/crctable.c")
469+
.file("bzip2/decompress.c")
470+
.file("bzip2/huffman.c")
471+
.file("bzip2/randtable.c");
472+
473+
compiler
474+
.define("_FILE_OFFSET_BITS", Some("64"))
475+
.define("BZ_NO_STDIO", None);
476+
477+
compiler.extra_warnings(false);
478+
compiler.opt_level(3);
479+
compiler.extra_warnings(false);
480+
compiler.compile("libbz2.a");
481+
}
482+
388483
fn try_to_find_and_link_lib(lib_name: &str) -> bool {
389484
if let Ok(v) = env::var(&format!("{}_COMPILE", lib_name)) {
390485
if v.to_lowercase() == "true" || v == "1" {
@@ -433,6 +528,21 @@ fn main() {
433528
fail_on_empty_directory("lz4");
434529
build_lz4();
435530
}
531+
if cfg!(feature = "zstd") && !try_to_find_and_link_lib("ZSTD") {
532+
println!("cargo:rerun-if-changed=zstd/");
533+
fail_on_empty_directory("zstd");
534+
build_zstd();
535+
}
536+
if cfg!(feature = "zlib") && !try_to_find_and_link_lib("Z") {
537+
println!("cargo:rerun-if-changed=zlib/");
538+
fail_on_empty_directory("zlib");
539+
build_zlib();
540+
}
541+
if cfg!(feature = "bzip2") && !try_to_find_and_link_lib("BZ2") {
542+
println!("cargo:rerun-if-changed=bzip2/");
543+
fail_on_empty_directory("bzip2");
544+
build_bzip2();
545+
}
436546

437547
println!("cargo:out_dir={}", env::var("OUT_DIR").unwrap());
438548
}

librocksdb-sys/bzip2/LICENSE

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
--------------------------------------------------------------------------
3+
4+
This program, "bzip2", the associated library "libbzip2", and all
5+
documentation, are copyright (C) 1996-2019 Julian R Seward. All
6+
rights reserved.
7+
8+
Redistribution and use in source and binary forms, with or without
9+
modification, are permitted provided that the following conditions
10+
are met:
11+
12+
1. Redistributions of source code must retain the above copyright
13+
notice, this list of conditions and the following disclaimer.
14+
15+
2. The origin of this software must not be misrepresented; you must
16+
not claim that you wrote the original software. If you use this
17+
software in a product, an acknowledgment in the product
18+
documentation would be appreciated but is not required.
19+
20+
3. Altered source versions must be plainly marked as such, and must
21+
not be misrepresented as being the original software.
22+
23+
4. The name of the author may not be used to endorse or promote
24+
products derived from this software without specific prior written
25+
permission.
26+
27+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
28+
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
29+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
31+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
33+
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
35+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38+
39+
Julian Seward, jseward@acm.org
40+
bzip2/libbzip2 version 1.0.8 of 13 July 2019
41+
42+
--------------------------------------------------------------------------

0 commit comments

Comments
 (0)