Skip to content

Commit

Permalink
Tweak how std is pulled in for gimli
Browse files Browse the repository at this point in the history
Try to fix a namespacing conflict found when testing libstd.
  • Loading branch information
alexcrichton committed Jun 26, 2020
1 parent 0aa3c2f commit f9f68f8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ std = []
# be affected by feature selection here. Also note that it's highly unlikely you
# want to configure this. If you're having trouble getting backtraces it's
# likely best to open an issue.
gimli-symbolize = ["addr2line", "miniz_oxide", "object", "std"]
gimli-symbolize = ["addr2line", "miniz_oxide", "object"]
libbacktrace = ["backtrace-sys/backtrace-sys"]

#=======================================
Expand Down
26 changes: 14 additions & 12 deletions src/symbolize/gimli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ use core::convert::TryInto;
use core::mem;
use core::u32;
use libc::c_void;
use std::ffi::OsString;
use std::fs::File;
use std::path::Path;
use std::prelude::v1::*;
use mystd::ffi::OsString;
use mystd::fs::File;
use mystd::path::Path;
use mystd::prelude::v1::*;

#[cfg(backtrace_in_libstd)]
mod std {
mod mystd {
pub use crate::*;
}
#[cfg(not(backtrace_in_libstd))]
extern crate std as mystd;

#[cfg(windows)]
#[path = "gimli/mmap_windows.rs"]
Expand Down Expand Up @@ -97,7 +99,7 @@ cfg_if::cfg_if! {
if #[cfg(windows)] {
use core::mem::MaybeUninit;
use super::super::windows::*;
use std::os::windows::prelude::*;
use mystd::os::windows::prelude::*;
use alloc::vec;

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

use std::os::unix::prelude::*;
use std::ffi::{OsStr, CStr};
use mystd::os::unix::prelude::*;
use mystd::ffi::{OsStr, CStr};

mod macho;
use self::macho::Object;
Expand Down Expand Up @@ -340,8 +342,8 @@ cfg_if::cfg_if! {
// and typically implement an API called `dl_iterate_phdr` to load
// native libraries.

use std::os::unix::prelude::*;
use std::ffi::{OsStr, CStr};
use mystd::os::unix::prelude::*;
use mystd::ffi::{OsStr, CStr};

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

use std::os::unix::prelude::*;
use mystd::os::unix::prelude::*;
mod elf;
use self::elf::Object;

Expand Down

0 comments on commit f9f68f8

Please sign in to comment.