Skip to content

Commit 2df0734

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

File tree

17 files changed

+5338
-25
lines changed

17 files changed

+5338
-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: 104 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,23 +128,18 @@ fn build_rocksdb() {
128128

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

136135
if cfg!(feature = "zlib") {
137136
config.define("ZLIB", Some("1"));
138-
if let Some(path) = env::var_os("DEP_Z_INCLUDE") {
139-
config.include(path);
140-
}
137+
config.include("zlib/");
141138
}
142139

143140
if cfg!(feature = "bzip2") {
144141
config.define("BZIP2", Some("1"));
145-
if let Some(path) = env::var_os("DEP_BZIP2_INCLUDE") {
146-
config.include(path);
147-
}
142+
config.include("bzip2/");
148143
}
149144

150145
if cfg!(feature = "rtti") {
@@ -385,6 +380,91 @@ fn build_lz4() {
385380
compiler.compile("liblz4.a");
386381
}
387382

383+
fn build_zstd() {
384+
let mut compiler = cc::Build::new();
385+
386+
compiler.include("zstd/lib/");
387+
compiler.include("zstd/lib/common");
388+
compiler.include("zstd/lib/legacy");
389+
390+
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default();
391+
392+
let globs = &[
393+
"zstd/lib/common/*.c",
394+
"zstd/lib/compress/*.c",
395+
"zstd/lib/decompress/*.c",
396+
"zstd/lib/dictBuilder/*.c",
397+
"zstd/lib/legacy/*.c",
398+
];
399+
400+
for pattern in globs {
401+
for path in glob::glob(pattern).unwrap() {
402+
let path = path.unwrap();
403+
compiler.file(path);
404+
}
405+
}
406+
407+
if target_arch.contains("x86_64") {
408+
if env::var("CARGO_CFG_WINDOWS").is_ok() {
409+
compiler.define("ZSTD_DISABLE_ASM", Some(""));
410+
} else {
411+
compiler.file("zstd/lib/decompress/huf_decompress_amd64.S");
412+
}
413+
} else {
414+
compiler.define("ZSTD_DISABLE_ASM", Some(""));
415+
}
416+
417+
compiler.opt_level(3);
418+
compiler.extra_warnings(false);
419+
compiler
420+
.flag_if_supported("-ffunction-sections")
421+
.flag_if_supported("-fdata-sections")
422+
.flag_if_supported("-fmerge-all-constants");
423+
424+
compiler.define("ZSTD_LIB_DEPRECATED", Some("0"));
425+
compiler.compile("libzstd.a");
426+
}
427+
428+
fn build_zlib() {
429+
let mut compiler = cc::Build::new();
430+
431+
let globs = &["zlib/*.c"];
432+
433+
for pattern in globs {
434+
for path in glob::glob(pattern).unwrap() {
435+
let path = path.unwrap();
436+
compiler.file(path);
437+
}
438+
}
439+
440+
compiler.flag_if_supported("-Wno-implicit-function-declaration");
441+
compiler.opt_level(3);
442+
compiler.extra_warnings(false);
443+
compiler.compile("libz.a");
444+
}
445+
446+
fn build_bzip2() {
447+
let mut compiler = cc::Build::new();
448+
449+
compiler
450+
.file("bzip2/blocksort.c")
451+
.file("bzip2/bzlib.c")
452+
.file("bzip2/compress.c")
453+
.file("bzip2/crctable.c")
454+
.file("bzip2/decompress.c")
455+
.file("bzip2/huffman.c")
456+
.file("bzip2/randtable.c");
457+
458+
compiler
459+
.define("_FILE_OFFSET_BITS", Some("64"))
460+
.define("BZ_NO_STDIO", None);
461+
462+
compiler.extra_warnings(false);
463+
compiler.opt_level(3);
464+
compiler.extra_warnings(false);
465+
compiler.compile("libbz2.a");
466+
}
467+
388468
fn try_to_find_and_link_lib(lib_name: &str) -> bool {
389469
if let Ok(v) = env::var(&format!("{}_COMPILE", lib_name)) {
390470
if v.to_lowercase() == "true" || v == "1" {
@@ -433,6 +513,21 @@ fn main() {
433513
fail_on_empty_directory("lz4");
434514
build_lz4();
435515
}
516+
if cfg!(feature = "zstd") && !try_to_find_and_link_lib("ZSTD") {
517+
println!("cargo:rerun-if-changed=zstd/");
518+
fail_on_empty_directory("zstd");
519+
build_zstd();
520+
}
521+
if cfg!(feature = "zlib") && !try_to_find_and_link_lib("Z") {
522+
println!("cargo:rerun-if-changed=zlib/");
523+
fail_on_empty_directory("zlib");
524+
build_zlib();
525+
}
526+
if cfg!(feature = "bzip2") && !try_to_find_and_link_lib("BZ2") {
527+
println!("cargo:rerun-if-changed=bzip2/");
528+
fail_on_empty_directory("bzip2");
529+
build_bzip2();
530+
}
436531

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

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)