Skip to content

Commit 0451222

Browse files
authored
Merge pull request #2 from nervosnetwork/zhangsoledad/fix-action
fix detaching fork
2 parents 3fa3f36 + dba5d94 commit 0451222

File tree

22 files changed

+149
-139
lines changed

22 files changed

+149
-139
lines changed

.github/workflows/rust.yml

Lines changed: 40 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -9,59 +9,41 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout sources
12-
uses: actions/checkout@v2
12+
uses: actions/checkout@v6
1313
- name: Install rust
14-
uses: actions-rs/toolchain@v1
14+
uses: dtolnay/rust-toolchain@stable
1515
with:
16-
toolchain: 1.85.0
16+
toolchain: 1.89.0
1717
components: rustfmt
18-
profile: minimal
19-
override: true
20-
- name: Run rustfmt
21-
uses: actions-rs/cargo@v1
22-
with:
23-
command: fmt
24-
args: --all -- --check
18+
- name: Check formatting
19+
run: |
20+
cargo fmt --all -- --check
2521
2622
clippy:
2723
name: Clippy
2824
runs-on: ubuntu-latest
2925
steps:
3026
- name: Checkout sources
31-
uses: actions/checkout@v2
27+
uses: actions/checkout@v6
3228
with:
3329
submodules: true
3430
- name: Install rust
35-
uses: actions-rs/toolchain@v1
31+
uses: dtolnay/rust-toolchain@stable
3632
with:
37-
toolchain: 1.85.0
38-
components: clippy
39-
profile: minimal
40-
override: true
33+
toolchain: 1.89.0
34+
components: clippy rustfmt
4135
- run: sudo apt update && sudo apt install -y libclang-dev
4236
- name: Run clippy
43-
uses: actions-rs/clippy-check@v1
44-
with:
45-
token: ${{ secrets.GITHUB_TOKEN }}
46-
args: --all --tests -- -A clippy::upper-case-acronyms -A clippy::missing_safety_doc -D warnings
47-
48-
audit:
49-
name: Security audit
50-
runs-on: ubuntu-latest
51-
steps:
52-
- uses: actions/checkout@v2
53-
- uses: actions-rs/audit-check@v1
54-
with:
55-
token: ${{ secrets.GITHUB_TOKEN }}
56-
37+
run: |
38+
make clippy
5739
5840
valgrind:
5941
name: valgrind
6042
runs-on: ubuntu-latest
6143
steps:
6244
- run: sudo apt update && sudo apt install -y valgrind libclang-dev
6345
- name: Checkout sources
64-
uses: actions/checkout@v2
46+
uses: actions/checkout@v6
6547
with:
6648
submodules: true
6749
- name: run test
@@ -79,7 +61,7 @@ jobs:
7961
- build: Linux
8062
os: ubuntu-22.04
8163
- build: macOS
82-
os: macos-12
64+
os: macos-latest
8365
- build: windows-2022
8466
os: windows-2022
8567
steps:
@@ -92,67 +74,57 @@ jobs:
9274
remove-dotnet: 'true'
9375
remove-android: 'true'
9476
remove-haskell: 'true'
77+
remove-codeql: 'true'
78+
remove-docker-images: 'true'
79+
- name: Delete huge unnecessary tools folder
80+
if: runner.os == 'Linux'
81+
run: rm -rf /opt/hostedtoolcache
9582
- name: Checkout sources
96-
uses: actions/checkout@v2
83+
uses: actions/checkout@v6
9784
with:
9885
submodules: true
9986
- name: Install rust
100-
uses: actions-rs/toolchain@v1
87+
uses: dtolnay/rust-toolchain@stable
10188
with:
102-
toolchain: 1.85.0
89+
toolchain: 1.89.0
10390
target: ${{ matrix.target }}
104-
profile: minimal
105-
override: true
91+
components: rustfmt
10692
- name: Remove msys64 # Workaround to resolve link error with C:\msys64\mingw64\bin\libclang.dll
10793
if: runner.os == 'Windows'
10894
run: Remove-Item -LiteralPath "C:\msys64\" -Force -Recurse
10995
- name: Install dependencies
11096
if: runner.os == 'Windows'
11197
run: choco install llvm -y
112-
- name: Install libclang-dev
98+
- name: Install dependencies (macOS)
99+
if: runner.os == 'macOS'
100+
run: brew install llvm lld
101+
- name: Install dependencies (Linux)
113102
if: runner.os == 'Linux'
114-
run: sudo apt install libclang-dev
115-
- name: Install jemalloc
116-
if: runner.os == 'Linux'
117-
run: sudo apt install libjemalloc-dev
118-
- name: Install liburing
119-
if: runner.os == 'Linux'
120-
run: sudo apt install liburing-dev
103+
run: sudo apt-get update && sudo apt-get install -y libclang-dev libjemalloc-dev liburing-dev
121104
- name: Debug librocksdb-sys tests
122105
if: runner.os == 'Linux' || runner.os == 'Windows'
123106
run: clang --version && env
124107
- name: Run librocksdb-sys tests
125108
if: runner.os == 'Linux' || runner.os == 'Windows'
126-
uses: actions-rs/cargo@v1
127-
with:
128-
command: test
129-
args: --manifest-path=librocksdb-sys/Cargo.toml -vvvvv
109+
run: |
110+
cargo test --manifest-path=librocksdb-sys/Cargo.toml -vvvvv
130111
- name: Run rocksdb tests
131112
if: runner.os == 'Linux' || runner.os == 'Windows'
132-
uses: actions-rs/cargo@v1
133-
with:
134-
command: test
113+
run: |
114+
cargo test
135115
- name: Run rocksdb tests (jemalloc)
136116
if: runner.os == 'Linux'
137-
uses: actions-rs/cargo@v1
138-
with:
139-
command: test
140-
args: --features jemalloc
117+
run: |
118+
cargo test --features jemalloc
141119
- name: Run rocksdb tests (io-uring)
142120
if: runner.os == 'Linux'
143-
uses: actions-rs/cargo@v1
144-
with:
145-
command: test
146-
args: --features io-uring
121+
run: |
122+
cargo test --features io-uring
147123
- name: Run rocksdb tests (portable)
148124
if: runner.os == 'Linux' || runner.os == 'macOS'
149-
uses: actions-rs/cargo@v1
150-
with:
151-
command: test
152-
args: --features portable
125+
run: |
126+
cargo test --features portable
153127
- name: Run rocksdb tests (march-native)
154128
if: runner.os == 'Linux'
155-
uses: actions-rs/cargo@v1
156-
with:
157-
command: test
158-
args: --features march-native
129+
run: |
130+
cargo test --features march-native

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
url = https://github.com/lz4/lz4.git
1010
[submodule "librocksdb-sys/zstd"]
1111
path = librocksdb-sys/zstd
12-
url = https://github.com/facebook/zstd
12+
url = https://github.com/facebook/zstd.git
1313
[submodule "librocksdb-sys/zlib"]
1414
path = librocksdb-sys/zlib
1515
url = https://github.com/madler/zlib.git

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ edition = "2024"
66
authors = ["Tyler Neely <t@jujit.su>", "David Greenberg <dsg123456789@gmail.com>", "Nervos Core Dev <dev@nervos.org>"]
77
license = "Apache-2.0"
88
keywords = ["database", "embedded", "LSM-tree", "persistence"]
9-
repository = "https://github.com/nervosnetwork/rust-rocksdb"
9+
repository = "https://github.com/nervosnetwork/ckb-rocksdb"
1010
exclude = [
1111
".gitignore",
1212
"*.yml",
1313
"tests",
1414
"*.md",
1515
"benches",
1616
]
17-
rust-version = "1.85.0"
17+
rust-version = "1.89.0"
1818

1919
[features]
2020
default = ["snappy", "lz4", "zstd", "zlib", "bzip2"]
@@ -30,6 +30,7 @@ portable = ["librocksdb-sys/portable"]
3030
march-native = ["librocksdb-sys/march-native"]
3131
serde1 = ["serde"]
3232
lto = ["librocksdb-sys/lto"]
33+
rtti = ["librocksdb-sys/rtti"]
3334

3435
[dependencies]
3536
home = "0.5"
@@ -40,7 +41,7 @@ serde = { version = "1", features = ["derive"], optional = true }
4041

4142
[dev-dependencies]
4243
trybuild = "1.0"
43-
criterion = "0.5"
44+
criterion = "0.7"
4445

4546
[[bench]]
4647
name = "transaction"

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
rust-rocksdb
1+
ckb-rocksdb
22
============
3-
[![Build Status](https://github.com/nervosnetwork/rust-rocksdb/actions/workflows/rust.yml/badge.svg?branch=txn)](https://github.com/nervosnetwork/rust-rocksdb/actions/workflows/rust.yml?query=branch%3Atxn)
3+
[![Build Status](https://github.com/nervosnetwork/ckb-rocksdb/actions/workflows/rust.yml/badge.svg)](https://github.com/nervosnetwork/ckb-rocksdb/actions/workflows/rust.yml?query=branch%3Amaster)
44
[![crates.io](https://img.shields.io/crates/v/ckb-rocksdb.svg)](https://crates.io/crates/ckb-rocksdb)
55
[![documentation](https://docs.rs/ckb-rocksdb/badge.svg)](https://docs.rs/ckb-rocksdb)
6-
[![license](https://img.shields.io/crates/l/ckb-rocksdb.svg)](https://github.com/nervosnetwork/rust-rocksdb/blob/txn/LICENSE)
6+
[![license](https://img.shields.io/crates/l/ckb-rocksdb.svg)](https://github.com/nervosnetwork/ckb-rocksdb/blob/master/LICENSE)
77
[![Discord](https://img.shields.io/badge/chat-on%20Discord-7289DA.svg)](https://discord.com/invite/nervos)
88

99

librocksdb-sys/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = ["Karl Hobley <karlhobley10@gmail.com>", "Arkadiy Paronyan <arkadiy@et
66
license = "MIT/Apache-2.0/BSD-3-Clause"
77
description = "Native bindings to librocksdb"
88
readme = "README.md"
9-
repository = "https://github.com/nervosnetwork/rust-rocksdb"
9+
repository = "https://github.com/nervosnetwork/ckb-rocksdb"
1010
keywords = [ "ffi", "rocksdb" ]
1111

1212
build = "build.rs"
@@ -37,6 +37,7 @@ zstd = []
3737
zlib = []
3838
bzip2 = []
3939
lto = []
40+
rtti = []
4041

4142

4243
[dependencies]
@@ -49,7 +50,7 @@ uuid = { version = "1.0", features = ["v4"] }
4950

5051
[build-dependencies]
5152
cc = { version = "1.0", features = ["parallel"] }
52-
bindgen = { version = "0.71.1", default-features = false }
53+
bindgen = { version = "0.72.1" }
5354
glob = "0.3.2"
5455
pkg-config = "0.3"
5556
rust-ini = "0.21"

librocksdb-sys/build.rs

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ compile_error!("feature 'portable' and feature 'march-native' cannot be enabled
33

44
use std::env;
55
use std::fs;
6-
use std::path::PathBuf;
6+
use std::path::{Path, PathBuf};
77
use std::process::Command;
88

9-
const RUST_TARGET: &str = "1.85.0";
9+
const RUST_TARGET: &str = "1.89.0";
10+
// On these platforms jemalloc-sys will use a prefixed jemalloc which cannot be linked together
11+
// with RocksDB.
12+
// See https://github.com/tikv/jemallocator/blob/tikv-jemalloc-sys-0.5.3/jemalloc-sys/src/env.rs#L25
13+
const NO_JEMALLOC_TARGETS: &[&str] = &["android", "dragonfly", "musl", "darwin"];
1014

1115
fn get_flags_from_detect_platform_script() -> Option<Vec<String>> {
1216
if !cfg!(target_os = "windows") {
@@ -138,6 +142,10 @@ fn build_rocksdb() {
138142
config.include("bzip2/");
139143
}
140144

145+
if cfg!(feature = "rtti") {
146+
config.define("USE_RTTI", Some("1"));
147+
}
148+
141149
// rust-rocksdb/rust-rocksdb:
142150
// https://github.com/rust-rocksdb/rust-rocksdb/commit/b2dab4a0915eed72741657f783118d9220d4f070
143151
//
@@ -147,8 +155,8 @@ fn build_rocksdb() {
147155
config.flag("-flto");
148156
if !config.get_compiler().is_like_clang() {
149157
panic!(
150-
"LTO is only supported with clang. Either disable the `lto` feature\
151-
or set `CC=/usr/bin/clang CXX=/usr/bin/clang++` environment variables."
158+
"LTO is only supported with clang. Either disable the `lto` feature \
159+
or set `CC=/usr/bin/clang CXX=/usr/bin/clang++` environment variables."
152160
);
153161
}
154162
}
@@ -286,25 +294,30 @@ fn build_rocksdb() {
286294
config.flag("-Wno-missing-field-initializers");
287295
config.flag("-Wno-strict-aliasing");
288296
config.flag("-Wno-invalid-offsetof");
297+
}
289298

290-
if cfg!(feature = "jemalloc") {
291-
if let Err(e) = pkg_config::probe_library("jemalloc") {
292-
panic!("pkg_config jemalloc {}", e);
293-
} else {
294-
config.define("ROCKSDB_JEMALLOC", None);
295-
config.define("JEMALLOC_NO_DEMANGLE", None);
296-
}
299+
config.define("ROCKSDB_SUPPORT_THREAD_LOCAL", None);
300+
if target.contains("linux") {
301+
if cfg!(feature = "io-uring") {
302+
pkg_config::probe_library("liburing")
303+
.expect("The io-uring feature was requested but the library is not available");
304+
config.define("ROCKSDB_IOURING_PRESENT", Some("1"));
297305
}
306+
}
298307

299-
if cfg!(feature = "io-uring") {
300-
if let Err(e) = pkg_config::probe_library("liburing") {
301-
panic!("pkg_config liburing {}", e);
302-
} else {
303-
config.define("ROCKSDB_IOURING_PRESENT", None);
304-
}
308+
if cfg!(feature = "jemalloc") && NO_JEMALLOC_TARGETS.iter().all(|i| !target.contains(i)) {
309+
config.define("ROCKSDB_JEMALLOC", Some("1"));
310+
config.define("JEMALLOC_NO_DEMANGLE", Some("1"));
311+
if let Some(jemalloc_root) = env::var_os("DEP_JEMALLOC_ROOT") {
312+
config.include(Path::new(&jemalloc_root).join("include"));
305313
}
306314
}
307315

316+
config.flag_if_supported("-std=c++17");
317+
if !target.contains("windows") {
318+
config.flag("-include").flag("cstdint");
319+
}
320+
308321
for file in lib_sources {
309322
let file = "rocksdb/".to_string() + file;
310323
config.file(&file);
@@ -315,8 +328,6 @@ fn build_rocksdb() {
315328

316329
config.cpp(true);
317330

318-
config.flag("-include").flag("cstdint");
319-
320331
config.compile("librocksdb.a");
321332
}
322333

@@ -376,6 +387,8 @@ fn build_zstd() {
376387
compiler.include("zstd/lib/common");
377388
compiler.include("zstd/lib/legacy");
378389

390+
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default();
391+
379392
let globs = &[
380393
"zstd/lib/common/*.c",
381394
"zstd/lib/compress/*.c",
@@ -391,8 +404,22 @@ fn build_zstd() {
391404
}
392405
}
393406

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+
394417
compiler.opt_level(3);
395418
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");
396423

397424
compiler.define("ZSTD_LIB_DEPRECATED", Some("0"));
398425
compiler.compile("libzstd.a");
@@ -501,4 +528,6 @@ fn main() {
501528
fail_on_empty_directory("bzip2");
502529
build_bzip2();
503530
}
531+
532+
println!("cargo:out_dir={}", env::var("OUT_DIR").unwrap());
504533
}

0 commit comments

Comments
 (0)