@@ -436,24 +436,11 @@ cfg_if::cfg_if! {
436
436
437
437
mod dladdr;
438
438
439
- /// Each resolve() implementation allocates and caches several megabytes worth of symbols,
440
- /// clear_symbol_cache tries to reclaim that cached memory.
441
- /// Note: for now, only the Gimli implementation is able to clear its cache.
442
- #[ cfg( feature = "std" ) ]
443
- pub fn clear_symbol_cache ( ) {
444
- let _guard = crate :: lock:: lock ( ) ;
445
- unsafe {
446
- clear_imp ( )
447
- }
448
- }
449
-
450
439
cfg_if:: cfg_if! {
451
440
if #[ cfg( all( windows, target_env = "msvc" , feature = "dbghelp" ) ) ] {
452
441
mod dbghelp;
453
442
use self :: dbghelp:: resolve as resolve_imp;
454
443
use self :: dbghelp:: Symbol as SymbolImp ;
455
- unsafe fn noop_clear_symbol_cache( ) { }
456
- use noop_clear_symbol_cache as clear_imp;
457
444
} else if #[ cfg( all(
458
445
feature = "std" ,
459
446
feature = "gimli-symbolize" ,
@@ -466,7 +453,6 @@ cfg_if::cfg_if! {
466
453
mod gimli;
467
454
use self :: gimli:: resolve as resolve_imp;
468
455
use self :: gimli:: Symbol as SymbolImp ;
469
- use self :: gimli:: clear_symbol_cache as clear_imp;
470
456
// Note that we only enable coresymbolication on iOS when debug assertions
471
457
// are enabled because it's helpful in debug mode but it looks like apps get
472
458
// rejected from the app store if they use this API, see #92 for more info
@@ -476,34 +462,49 @@ cfg_if::cfg_if! {
476
462
mod coresymbolication;
477
463
use self :: coresymbolication:: resolve as resolve_imp;
478
464
use self :: coresymbolication:: Symbol as SymbolImp ;
479
-
480
- unsafe fn noop_clear_symbol_cache( ) { }
481
- use noop_clear_symbol_cache as clear_imp;
482
465
} else if #[ cfg( all( feature = "libbacktrace" ,
483
466
any( unix, all( windows, not( target_vendor = "uwp" ) , target_env = "gnu" ) ) ,
484
467
not( target_os = "fuchsia" ) ,
485
468
not( target_os = "emscripten" ) ) ) ] {
486
469
mod libbacktrace;
487
470
use self :: libbacktrace:: resolve as resolve_imp;
488
471
use self :: libbacktrace:: Symbol as SymbolImp ;
489
-
490
- unsafe fn noop_clear_symbol_cache( ) { }
491
- use noop_clear_symbol_cache as clear_imp;
492
472
} else if #[ cfg( all( unix,
493
473
not( target_os = "emscripten" ) ,
494
474
feature = "dladdr" ) ) ] {
495
475
mod dladdr_resolve;
496
476
use self :: dladdr_resolve:: resolve as resolve_imp;
497
477
use self :: dladdr_resolve:: Symbol as SymbolImp ;
498
-
499
- unsafe fn noop_clear_symbol_cache( ) { }
500
- use noop_clear_symbol_cache as clear_imp;
501
478
} else {
502
479
mod noop;
503
480
use self :: noop:: resolve as resolve_imp;
504
481
use self :: noop:: Symbol as SymbolImp ;
505
-
506
- unsafe fn noop_clear_symbol_cache( ) { }
507
- use noop_clear_symbol_cache as clear_imp;
508
482
}
509
483
}
484
+
485
+ cfg_if:: cfg_if! {
486
+ if #[ cfg( all(
487
+ feature = "std" ,
488
+ feature = "gimli-symbolize" ,
489
+ any(
490
+ target_os = "linux" ,
491
+ target_os = "macos" ,
492
+ windows,
493
+ ) ,
494
+ ) ) ] {
495
+ /// clear_symbol_cache tries to reclaim that cached memory.
496
+ /// Note: for now, only the Gimli implementation is able to clear its cache.
497
+ pub fn clear_symbol_cache( ) {
498
+ let _guard = crate :: lock:: lock( ) ;
499
+ unsafe {
500
+ self :: gimli:: clear_symbol_cache( ) ;
501
+ }
502
+ }
503
+ } else if #[ cfg( feature = "std" ) ] {
504
+ /// clear_symbol_cache tries to reclaim that cached memory.
505
+ /// Note: for now, only the Gimli implementation is able to clear its cache.
506
+ pub fn clear_symbol_cache( ) {
507
+ // noop
508
+ }
509
+ }
510
+ }
0 commit comments