diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 944e1a78..cd11bcf7 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -19,7 +19,7 @@ jobs: uses: actions-rs/toolchain@v1.0.7 with: profile: minimal - toolchain: 1.66.0 + toolchain: 1.74.0 override: true components: rustfmt, clippy @@ -56,7 +56,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest] - toolchain: [stable, nightly, 1.66.0] + toolchain: [stable, nightly, 1.74.0] target: [ x86_64-unknown-linux-gnu, diff --git a/Cargo.lock b/Cargo.lock index 49cc6957..b3ae7f40 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -725,13 +725,13 @@ dependencies = [ "prost-build", "prost-derive", "protobuf", - "protobuf-codegen-pure", + "protobuf-codegen", "rand", "sha2", "smallvec", "symbolic-demangle", "tempfile", - "thiserror", + "thiserror 2.0.12", ] [[package]] @@ -815,27 +815,53 @@ dependencies = [ [[package]] name = "protobuf" -version = "2.28.0" +version = "3.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94" +checksum = "d65a1d4ddae7d8b5de68153b48f6aa3bba8cb002b243dbdbc55a5afbc98f99f4" +dependencies = [ + "once_cell", + "protobuf-support", + "thiserror 1.0.69", +] [[package]] name = "protobuf-codegen" -version = "2.28.0" +version = "3.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "033460afb75cf755fcfc16dfaed20b86468082a2ea24e05ac35ab4a099a017d6" +checksum = "5d3976825c0014bbd2f3b34f0001876604fe87e0c86cd8fa54251530f1544ace" dependencies = [ + "anyhow", + "once_cell", "protobuf", + "protobuf-parse", + "regex", + "tempfile", + "thiserror 1.0.69", ] [[package]] -name = "protobuf-codegen-pure" -version = "2.28.0" +name = "protobuf-parse" +version = "3.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a29399fc94bcd3eeaa951c715f7bea69409b2445356b00519740bcd6ddd865" +checksum = "b4aeaa1f2460f1d348eeaeed86aea999ce98c1bded6f089ff8514c9d9dbdc973" dependencies = [ + "anyhow", + "indexmap", + "log", "protobuf", - "protobuf-codegen", + "protobuf-support", + "tempfile", + "thiserror 1.0.69", + "which", +] + +[[package]] +name = "protobuf-support" +version = "3.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e36c2f31e0a47f9280fb347ef5e461ffcd2c52dd520d8e216b52f93b0b0d7d6" +dependencies = [ + "thiserror 1.0.69", ] [[package]] @@ -1100,13 +1126,33 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + [[package]] name = "thiserror" version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ - "thiserror-impl", + "thiserror-impl 2.0.12", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 99670538..e6840812 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ description = "An internal perf tools for rust programs." repository = "https://github.com/tikv/pprof-rs" documentation = "https://docs.rs/pprof/" readme = "README.md" -rust-version = "1.66.0" # MSRV +rust-version = "1.74.0" # MSRV [features] default = ["cpp"] @@ -19,7 +19,7 @@ frame-pointer = [] # A private feature to indicate either prost-codec or protobuf-codec is enabled. _protobuf = [] prost-codec = ["prost", "prost-derive", "prost-build", "sha2", "_protobuf"] -protobuf-codec = ["protobuf", "protobuf-codegen-pure", "_protobuf"] +protobuf-codec = ["protobuf", "protobuf-codegen", "_protobuf"] [dependencies] backtrace = { version = "0.3" } @@ -37,7 +37,7 @@ smallvec = "1.7" inferno = { version = "0.11", default-features = false, features = ["nameattr"], optional = true } prost = { version = "0.12", optional = true } prost-derive = { version = "0.12", optional = true } -protobuf = { version = "2.0", optional = true } +protobuf = { version = ">=3.7.2", optional = true } criterion = {version = "0.5", optional = true} aligned-vec = "0.6" @@ -53,7 +53,7 @@ rand = "0.8.0" [build-dependencies] prost-build = { version = "0.12", optional = true } sha2 = { version = "0.10", optional = true } -protobuf-codegen-pure = { version = "2.0", optional = true } +protobuf-codegen = { version = "3.7.2", optional = true } [[example]] name = "flamegraph" diff --git a/README.md b/README.md index a5be80b0..e270b516 100644 --- a/README.md +++ b/README.md @@ -247,7 +247,7 @@ Unit tests have been added to guarantee there is no `malloc` in sample functions ## Minimum Supported Rust Version -Rust 1.64 or higher. +Rust 1.74 or higher. Minimum supported Rust version can be changed in the future, but it will be done with a minor version bump. diff --git a/build.rs b/build.rs index 829274f4..90d52c9d 100644 --- a/build.rs +++ b/build.rs @@ -1,23 +1,21 @@ // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. - #[cfg(feature = "protobuf-codec")] // Allow deprecated as TiKV pin versions to a outdated one. -#[allow(deprecated)] fn generate_protobuf() { use std::io::Write; - + let customize = ::default(); + // Set the output directory for generated files let out_dir = std::env::var("OUT_DIR").unwrap(); - protobuf_codegen_pure::run(protobuf_codegen_pure::Args { - out_dir: &out_dir, - includes: &["proto"], - input: &["proto/profile.proto"], - customize: protobuf_codegen_pure::Customize { - generate_accessors: Some(false), - lite_runtime: Some(true), - ..Default::default() - }, - }) - .unwrap(); + + let mut cg = protobuf_codegen::Codegen::new(); + cg.pure(); + + cg.inputs(["proto/profile.proto"]).includes(["proto"]); + + cg.customize(customize); + cg.out_dir(&out_dir).run().unwrap(); + + // Optionally, write a mod.rs file for module inclusion let mut f = std::fs::File::create(format!("{}/mod.rs", out_dir)).unwrap(); write!(f, "pub mod profile;").unwrap(); } diff --git a/src/backtrace/backtrace_rs.rs b/src/backtrace/backtrace_rs.rs index 1b7e3663..d0cee1fe 100644 --- a/src/backtrace/backtrace_rs.rs +++ b/src/backtrace/backtrace_rs.rs @@ -23,6 +23,3 @@ impl super::Trace for Trace { unsafe { backtrace::trace_unsynchronized(cb) } } } - -pub use backtrace::Frame; -pub use backtrace::Symbol; diff --git a/src/backtrace/mod.rs b/src/backtrace/mod.rs index 5a79e86a..903d3120 100644 --- a/src/backtrace/mod.rs +++ b/src/backtrace/mod.rs @@ -32,7 +32,11 @@ pub trait Frame: Sized + Clone { type S: Symbol; fn resolve_symbol(&self, cb: F); + + #[allow(dead_code)] fn symbol_address(&self) -> *mut c_void; + + #[allow(dead_code)] fn ip(&self) -> usize; }