Skip to content

Commit 59cbaf5

Browse files
Merge of #679 - Fix CI for lints and migrations
This doesn't fix #678 but will hopefully get CI passing again. Longer term, I would like to change our dbghelp library loading to be less eek.
2 parents 26ab4af + f696fd3 commit 59cbaf5

File tree

5 files changed

+24
-14
lines changed

5 files changed

+24
-14
lines changed

.github/workflows/main.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
if: contains(matrix.os, 'ubuntu')
9393
env:
9494
RUSTFLAGS: "-C link-arg=-Wl,--compress-debug-sections=zlib"
95-
- run: cargo test
95+
- run: cargo test --features "ruzstd"
9696
if: contains(matrix.os, 'ubuntu-24.04') ||
9797
(contains(matrix.os, 'ubuntu') && contains(matrix.rust, 'nightly'))
9898
env:
@@ -235,7 +235,7 @@ jobs:
235235
matrix:
236236
target:
237237
- wasm32-unknown-unknown
238-
- wasm32-wasi
238+
- wasm32-wasip1
239239
- x86_64-unknown-fuchsia
240240
- x86_64-fortanix-unknown-sgx
241241
- x86_64-unknown-illumos

Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ windows-targets = "0.52.6"
4343

4444
[target.'cfg(not(all(windows, target_env = "msvc", not(target_vendor = "uwp"))))'.dependencies]
4545
miniz_oxide = { version = "0.8", default-features = false }
46-
ruzstd = { version = "0.7.2", default-features = false }
46+
ruzstd = { version = "0.7.3", default-features = false, optional = true }
4747
addr2line = { version = "0.24.0", default-features = false }
4848
libc = { version = "0.2.156", default-features = false }
4949

@@ -65,6 +65,8 @@ std = []
6565

6666
serialize-serde = ["serde"]
6767

68+
ruzstd = ["dep:ruzstd"]
69+
6870
#=======================================
6971
# Deprecated/internal features
7072
#

src/dbghelp.rs

+12-8
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ macro_rules! dbghelp {
111111
#[allow(dead_code)]
112112
impl Init {
113113
$(pub fn $name(&self) -> $name {
114+
// FIXME: https://github.com/rust-lang/backtrace-rs/issues/678
115+
#[allow(static_mut_refs)]
114116
unsafe {
115117
DBGHELP.$name().unwrap()
116118
}
@@ -318,24 +320,26 @@ pub fn init() -> Result<Init, ()> {
318320
// functions in it, and that's detailed more below. We only do this
319321
// once, though, so we've got a global boolean indicating whether we're
320322
// done yet or not.
323+
// FIXME: https://github.com/rust-lang/backtrace-rs/issues/678
324+
#[allow(static_mut_refs)]
321325
DBGHELP.ensure_open()?;
322326

323327
static mut INITIALIZED: bool = false;
324328
if !INITIALIZED {
325-
set_optional_options();
329+
set_optional_options(ret.dbghelp());
326330
INITIALIZED = true;
327331
}
328332
Ok(ret)
329333
}
330334
}
331-
fn set_optional_options() -> Option<()> {
335+
unsafe fn set_optional_options(dbghelp: *mut Dbghelp) -> Option<()> {
332336
unsafe {
333-
let orig = DBGHELP.SymGetOptions()?();
337+
let orig = (*dbghelp).SymGetOptions()?();
334338

335339
// Ensure that the `SYMOPT_DEFERRED_LOADS` flag is set, because
336340
// according to MSVC's own docs about this: "This is the fastest, most
337341
// efficient way to use the symbol handler.", so let's do that!
338-
DBGHELP.SymSetOptions()?(orig | SYMOPT_DEFERRED_LOADS);
342+
(*dbghelp).SymSetOptions()?(orig | SYMOPT_DEFERRED_LOADS);
339343

340344
// Actually initialize symbols with MSVC. Note that this can fail, but we
341345
// ignore it. There's not a ton of prior art for this per se, but LLVM
@@ -349,7 +353,7 @@ fn set_optional_options() -> Option<()> {
349353
// the time, but now that it's using this crate it means that someone will
350354
// get to initialization first and the other will pick up that
351355
// initialization.
352-
DBGHELP.SymInitializeW()?(GetCurrentProcess(), ptr::null_mut(), TRUE);
356+
(*dbghelp).SymInitializeW()?(GetCurrentProcess(), ptr::null_mut(), TRUE);
353357

354358
// The default search path for dbghelp will only look in the current working
355359
// directory and (possibly) `_NT_SYMBOL_PATH` and `_NT_ALT_SYMBOL_PATH`.
@@ -363,7 +367,7 @@ fn set_optional_options() -> Option<()> {
363367
search_path_buf.resize(1024, 0);
364368

365369
// Prefill the buffer with the current search path.
366-
if DBGHELP.SymGetSearchPathW()?(
370+
if (*dbghelp).SymGetSearchPathW()?(
367371
GetCurrentProcess(),
368372
search_path_buf.as_mut_ptr(),
369373
search_path_buf.len() as _,
@@ -383,7 +387,7 @@ fn set_optional_options() -> Option<()> {
383387
let mut search_path = SearchPath::new(search_path_buf);
384388

385389
// Update the search path to include the directory of the executable and each DLL.
386-
DBGHELP.EnumerateLoadedModulesW64()?(
390+
(*dbghelp).EnumerateLoadedModulesW64()?(
387391
GetCurrentProcess(),
388392
Some(enum_loaded_modules_callback),
389393
((&mut search_path) as *mut SearchPath) as *mut c_void,
@@ -392,7 +396,7 @@ fn set_optional_options() -> Option<()> {
392396
let new_search_path = search_path.finalize();
393397

394398
// Set the new search path.
395-
DBGHELP.SymSetSearchPathW()?(GetCurrentProcess(), new_search_path.as_ptr());
399+
(*dbghelp).SymSetSearchPathW()?(GetCurrentProcess(), new_search_path.as_ptr());
396400
}
397401
Some(())
398402
}

src/symbolize/gimli.rs

+2
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ impl Cache {
363363
// never happen, and symbolicating backtraces would be ssssllllooooowwww.
364364
static mut MAPPINGS_CACHE: Option<Cache> = None;
365365

366+
// FIXME: https://github.com/rust-lang/backtrace-rs/issues/678
367+
#[allow(static_mut_refs)]
366368
f(MAPPINGS_CACHE.get_or_insert_with(Cache::new))
367369
}
368370

src/symbolize/gimli/elf.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use super::{gimli, Context, Endian, EndianSlice, Mapping, Stash, Vec};
99
use alloc::sync::Arc;
1010
use core::convert::{TryFrom, TryInto};
1111
use core::str;
12-
use object::elf::{
13-
ELFCOMPRESS_ZLIB, ELFCOMPRESS_ZSTD, ELF_NOTE_GNU, NT_GNU_BUILD_ID, SHF_COMPRESSED,
14-
};
12+
#[cfg(feature = "ruzstd")]
13+
use object::elf::ELFCOMPRESS_ZSTD;
14+
use object::elf::{ELFCOMPRESS_ZLIB, ELF_NOTE_GNU, NT_GNU_BUILD_ID, SHF_COMPRESSED};
1515
use object::read::elf::{CompressionHeader, FileHeader, SectionHeader, SectionTable, Sym};
1616
use object::read::StringTable;
1717
use object::{BigEndian, Bytes, NativeEndian};
@@ -231,6 +231,7 @@ impl<'a> Object<'a> {
231231
decompress_zlib(data.0, buf)?;
232232
return Some(buf);
233233
}
234+
#[cfg(feature = "ruzstd")]
234235
ELFCOMPRESS_ZSTD => {
235236
let size = usize::try_from(header.ch_size(self.endian)).ok()?;
236237
let buf = stash.allocate(size);
@@ -357,6 +358,7 @@ fn decompress_zlib(input: &[u8], output: &mut [u8]) -> Option<()> {
357358
}
358359
}
359360

361+
#[cfg(feature = "ruzstd")]
360362
fn decompress_zstd(mut input: &[u8], mut output: &mut [u8]) -> Option<()> {
361363
use ruzstd::frame::ReadFrameHeaderError;
362364
use ruzstd::frame_decoder::FrameDecoderError;

0 commit comments

Comments
 (0)