From 1a37fdb98720541968ef12eddb39739daa4fed0d Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Thu, 2 Jan 2025 14:08:05 -0800 Subject: [PATCH] ruzstd: Make optional for now --- .github/workflows/main.yml | 2 +- Cargo.toml | 4 +++- src/symbolize/gimli/elf.rs | 8 +++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 04a8c46f..fb3374c0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -92,7 +92,7 @@ jobs: if: contains(matrix.os, 'ubuntu') env: RUSTFLAGS: "-C link-arg=-Wl,--compress-debug-sections=zlib" - - run: cargo test + - run: cargo test --features "zstd" if: contains(matrix.os, 'ubuntu-24.04') || (contains(matrix.os, 'ubuntu') && contains(matrix.rust, 'nightly')) env: diff --git a/Cargo.toml b/Cargo.toml index 46ee959a..d11da11f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,7 +43,7 @@ windows-targets = "0.52.6" [target.'cfg(not(all(windows, target_env = "msvc", not(target_vendor = "uwp"))))'.dependencies] miniz_oxide = { version = "0.8", default-features = false } -ruzstd = { version = "0.7.2", default-features = false } +ruzstd = { version = "0.7.2", default-features = false, optional = true } addr2line = { version = "0.24.0", default-features = false } libc = { version = "0.2.156", default-features = false } @@ -65,6 +65,8 @@ std = [] serialize-serde = ["serde"] +zstd = ["dep:ruzstd"] + #======================================= # Deprecated/internal features # diff --git a/src/symbolize/gimli/elf.rs b/src/symbolize/gimli/elf.rs index b73f6aac..8a6d03d5 100644 --- a/src/symbolize/gimli/elf.rs +++ b/src/symbolize/gimli/elf.rs @@ -9,9 +9,9 @@ use super::{gimli, Context, Endian, EndianSlice, Mapping, Stash, Vec}; use alloc::sync::Arc; use core::convert::{TryFrom, TryInto}; use core::str; -use object::elf::{ - ELFCOMPRESS_ZLIB, ELFCOMPRESS_ZSTD, ELF_NOTE_GNU, NT_GNU_BUILD_ID, SHF_COMPRESSED, -}; +#[cfg(any(feature = "zstd", backtrace_ruzstd))] +use object::elf::ELFCOMPRESS_ZSTD; +use object::elf::{ELFCOMPRESS_ZLIB, ELF_NOTE_GNU, NT_GNU_BUILD_ID, SHF_COMPRESSED}; use object::read::elf::{CompressionHeader, FileHeader, SectionHeader, SectionTable, Sym}; use object::read::StringTable; use object::{BigEndian, Bytes, NativeEndian}; @@ -231,6 +231,7 @@ impl<'a> Object<'a> { decompress_zlib(data.0, buf)?; return Some(buf); } + #[cfg(any(feature = "zstd", backtrace_ruzstd))] ELFCOMPRESS_ZSTD => { let size = usize::try_from(header.ch_size(self.endian)).ok()?; let buf = stash.allocate(size); @@ -357,6 +358,7 @@ fn decompress_zlib(input: &[u8], output: &mut [u8]) -> Option<()> { } } +#[cfg(any(feature = "zstd", backtrace_ruzstd))] fn decompress_zstd(mut input: &[u8], mut output: &mut [u8]) -> Option<()> { use ruzstd::frame::ReadFrameHeaderError; use ruzstd::frame_decoder::FrameDecoderError;