diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-03-24 10:41:43 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-03-24 11:19:28 -0700 |
| commit | 3ccad75641515b1fa62dc5378b0b139129aa9daf (patch) | |
| tree | fc5763275f6768abc30d4d35ebbe65e7ab83dca3 /src/libstd | |
| parent | b19261a7498155c20b0877e56526e5c018a48be6 (diff) | |
| download | rust-3ccad75641515b1fa62dc5378b0b139129aa9daf.tar.gz rust-3ccad75641515b1fa62dc5378b0b139129aa9daf.zip | |
rustc: Remove all crate map support
The crate map is no longer necessary now that logging and event loop factories have been moved out. Closes #11617 Closes #11731
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/rt/crate_map.rs | 104 | ||||
| -rw-r--r-- | src/libstd/rt/mod.rs | 3 |
2 files changed, 0 insertions, 107 deletions
diff --git a/src/libstd/rt/crate_map.rs b/src/libstd/rt/crate_map.rs deleted file mode 100644 index 98f4986b2c7..00000000000 --- a/src/libstd/rt/crate_map.rs +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use cast; -use option::{Some, None, Option}; -use ptr::RawPtr; -use rt::rtio::EventLoop; - -// Need to tell the linker on OS X to not barf on undefined symbols -// and instead look them up at runtime, which we need to resolve -// the crate_map properly. -#[cfg(target_os = "macos")] -#[link_args = "-Wl,-U,__rust_crate_map_toplevel"] -extern {} - -pub struct CrateMap<'a> { - version: i32, - event_loop_factory: Option<fn() -> ~EventLoop>, -} - -// When working on android, apparently weak symbols don't work so well for -// finding the crate map, and neither does dlopen + dlsym. This is mainly a -// problem when integrating a shared library with an existing application. -// Standalone binaries do not appear to have this problem. The reasons are a -// little mysterious, and more information can be found in #11731. -// -// For now we provide a way to tell libstd about the crate map manually that's -// checked before the normal weak symbol/dlopen paths. In theory this is useful -// on other platforms where our dlopen/weak linkage strategy mysteriously fails -// but the crate map can be specified manually. -static mut MANUALLY_PROVIDED_CRATE_MAP: *CrateMap<'static> = - 0 as *CrateMap<'static>; -#[no_mangle] -#[cfg(not(test))] -pub extern fn rust_set_crate_map(map: *CrateMap<'static>) { - unsafe { MANUALLY_PROVIDED_CRATE_MAP = map; } -} - -fn manual_crate_map() -> Option<&'static CrateMap<'static>> { - unsafe { - if MANUALLY_PROVIDED_CRATE_MAP.is_null() { - None - } else { - Some(cast::transmute(MANUALLY_PROVIDED_CRATE_MAP)) - } - } -} - -#[cfg(not(windows))] -pub fn get_crate_map() -> Option<&'static CrateMap<'static>> { - extern { - #[crate_map] - static CRATE_MAP: CrateMap<'static>; - } - - manual_crate_map().or_else(|| { - let ptr: (*CrateMap) = &'static CRATE_MAP; - if ptr.is_null() { - None - } else { - Some(&'static CRATE_MAP) - } - }) -} - -#[cfg(windows)] -pub fn get_crate_map() -> Option<&'static CrateMap<'static>> { - use c_str::ToCStr; - use unstable::dynamic_lib::dl; - - match manual_crate_map() { - Some(cm) => return Some(cm), - None => {} - } - - let sym = unsafe { - let module = dl::open_internal(); - let rust_crate_map_toplevel = if cfg!(target_arch = "x86") { - "__rust_crate_map_toplevel" - } else { - "_rust_crate_map_toplevel" - }; - let sym = rust_crate_map_toplevel.with_c_str(|buf| { - dl::symbol(module, buf) - }); - dl::close(module); - sym - }; - let ptr: (*CrateMap) = sym as *CrateMap; - if ptr.is_null() { - return None; - } else { - unsafe { - return Some(cast::transmute(sym)); - } - } -} diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs index 84e547619df..795281026a4 100644 --- a/src/libstd/rt/mod.rs +++ b/src/libstd/rt/mod.rs @@ -104,9 +104,6 @@ pub mod env; /// The local, managed heap pub mod local_heap; -/// Crate map -pub mod crate_map; - /// The runtime needs to be able to put a pointer into thread-local storage. mod local_ptr; |
