Skip to content

Commit f9f68f8

Browse files
committed
Tweak how std is pulled in for gimli
Try to fix a namespacing conflict found when testing libstd.
1 parent 0aa3c2f commit f9f68f8

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ std = []
7070
# be affected by feature selection here. Also note that it's highly unlikely you
7171
# want to configure this. If you're having trouble getting backtraces it's
7272
# likely best to open an issue.
73-
gimli-symbolize = ["addr2line", "miniz_oxide", "object", "std"]
73+
gimli-symbolize = ["addr2line", "miniz_oxide", "object"]
7474
libbacktrace = ["backtrace-sys/backtrace-sys"]
7575

7676
#=======================================

src/symbolize/gimli.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ use core::convert::TryInto;
1616
use core::mem;
1717
use core::u32;
1818
use libc::c_void;
19-
use std::ffi::OsString;
20-
use std::fs::File;
21-
use std::path::Path;
22-
use std::prelude::v1::*;
19+
use mystd::ffi::OsString;
20+
use mystd::fs::File;
21+
use mystd::path::Path;
22+
use mystd::prelude::v1::*;
2323

2424
#[cfg(backtrace_in_libstd)]
25-
mod std {
25+
mod mystd {
2626
pub use crate::*;
2727
}
28+
#[cfg(not(backtrace_in_libstd))]
29+
extern crate std as mystd;
2830

2931
#[cfg(windows)]
3032
#[path = "gimli/mmap_windows.rs"]
@@ -97,7 +99,7 @@ cfg_if::cfg_if! {
9799
if #[cfg(windows)] {
98100
use core::mem::MaybeUninit;
99101
use super::super::windows::*;
100-
use std::os::windows::prelude::*;
102+
use mystd::os::windows::prelude::*;
101103
use alloc::vec;
102104

103105
mod coff;
@@ -187,8 +189,8 @@ cfg_if::cfg_if! {
187189
// macOS uses the Mach-O file format and uses DYLD-specific APIs to
188190
// load a list of native libraries that are part of the appplication.
189191

190-
use std::os::unix::prelude::*;
191-
use std::ffi::{OsStr, CStr};
192+
use mystd::os::unix::prelude::*;
193+
use mystd::ffi::{OsStr, CStr};
192194

193195
mod macho;
194196
use self::macho::Object;
@@ -340,8 +342,8 @@ cfg_if::cfg_if! {
340342
// and typically implement an API called `dl_iterate_phdr` to load
341343
// native libraries.
342344

343-
use std::os::unix::prelude::*;
344-
use std::ffi::{OsStr, CStr};
345+
use mystd::os::unix::prelude::*;
346+
use mystd::ffi::{OsStr, CStr};
345347

346348
mod elf;
347349
use self::elf::Object;
@@ -362,7 +364,7 @@ cfg_if::cfg_if! {
362364
let libs = &mut *(vec as *mut Vec<Library>);
363365
let name = if (*info).dlpi_name.is_null() || *(*info).dlpi_name == 0{
364366
if libs.is_empty() {
365-
std::env::current_exe().map(|e| e.into()).unwrap_or_default()
367+
mystd::env::current_exe().map(|e| e.into()).unwrap_or_default()
366368
} else {
367369
OsString::new()
368370
}
@@ -388,7 +390,7 @@ cfg_if::cfg_if! {
388390
// Everything else should use ELF, but doesn't know how to load native
389391
// libraries.
390392

391-
use std::os::unix::prelude::*;
393+
use mystd::os::unix::prelude::*;
392394
mod elf;
393395
use self::elf::Object;
394396

0 commit comments

Comments
 (0)