Skip to content

Remove the annihilate function from the crate map. #9470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 25, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2949,7 +2949,7 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta,
};
let sym_name = ~"_rust_crate_map_" + mapname;
let arrtype = Type::array(&int_type, n_subcrates as u64);
let maptype = Type::struct_([Type::i32(), Type::i8p(), int_type, arrtype], false);
let maptype = Type::struct_([Type::i32(), int_type, arrtype], false);
let map = do sym_name.with_c_str |buf| {
unsafe {
llvm::LLVMAddGlobal(llmod, maptype.to_ref(), buf)
Expand Down Expand Up @@ -2990,8 +2990,6 @@ pub fn fill_crate_map(ccx: @mut CrateContext, map: ValueRef) {
let mod_map = create_module_map(ccx);
llvm::LLVMSetInitializer(map, C_struct(
[C_i32(1),
// FIXME #8431 This used to be the annihilate function, now it's nothing
C_null(Type::i8p()),
p2i(ccx, mod_map),
C_array(ccx.int_type, subcrates)]));
}
Expand Down
31 changes: 14 additions & 17 deletions src/libstd/rt/crate_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
// except according to those terms.


use libc::{c_void, c_char};
use libc::c_char;
#[cfg(stage0)] use libc::c_void;
use ptr;
use ptr::RawPtr;
use vec;
Expand Down Expand Up @@ -39,6 +40,7 @@ struct CrateMapV0 {
children: [*CrateMap, ..1]
}

#[cfg(stage0)]
struct CrateMap {
version: i32,
annihilate_fn: *c_void,
Expand All @@ -48,6 +50,15 @@ struct CrateMap {
children: [*CrateMap, ..1]
}

#[cfg(not(stage0))]
struct CrateMap {
version: i32,
entries: *ModEntry,
/// a dynamically sized struct, where all pointers to children are listed adjacent
/// to the struct, terminated with NULL
children: [*CrateMap, ..1]
}

#[cfg(not(windows))]
pub fn get_crate_map() -> *CrateMap {
&'static CRATE_MAP as *CrateMap
Expand Down Expand Up @@ -79,15 +90,6 @@ unsafe fn version(crate_map: *CrateMap) -> i32 {
}
}

/// Returns a pointer to the annihilate function of the CrateMap
pub unsafe fn annihilate_fn(crate_map: *CrateMap) -> *c_void {
match version(crate_map) {
0 => return ptr::null(),
1 => return (*crate_map).annihilate_fn,
_ => fail!("Unknown crate map version!")
}
}

unsafe fn entries(crate_map: *CrateMap) -> *ModEntry {
match version(crate_map) {
0 => {
Expand Down Expand Up @@ -145,7 +147,6 @@ fn iter_crate_map_duplicates() {

struct CrateMapT3 {
version: i32,
annihilate_fn: *c_void,
entries: *ModEntry,
children: [*CrateMap, ..3]
}
Expand All @@ -160,13 +161,12 @@ fn iter_crate_map_duplicates() {
];
let child_crate = CrateMap {
version: 1,
annihilate_fn: ptr::null(),
entries: vec::raw::to_ptr(entries),
children: [ptr::null()]
};

let root_crate = CrateMapT3 {
version: 1, annihilate_fn: ptr::null(),
version: 1,
entries: vec::raw::to_ptr([ModEntry { name: ptr::null(), log_level: ptr::mut_null()}]),
children: [&child_crate as *CrateMap, &child_crate as *CrateMap, ptr::null()]
};
Expand All @@ -187,7 +187,6 @@ fn iter_crate_map_follow_children() {

struct CrateMapT2 {
version: i32,
annihilate_fn: *c_void,
entries: *ModEntry,
children: [*CrateMap, ..2]
}
Expand All @@ -199,7 +198,6 @@ fn iter_crate_map_follow_children() {
let mut level3: u32 = 3;
let child_crate2 = CrateMap {
version: 1,
annihilate_fn: ptr::null(),
entries: vec::raw::to_ptr([
ModEntry { name: mod_name1.with_ref(|buf| buf), log_level: &mut level2},
ModEntry { name: mod_name2.with_ref(|buf| buf), log_level: &mut level3},
Expand All @@ -210,7 +208,6 @@ fn iter_crate_map_follow_children() {

let child_crate1 = CrateMapT2 {
version: 1,
annihilate_fn: ptr::null(),
entries: vec::raw::to_ptr([
ModEntry { name: "t::f1".to_c_str().with_ref(|buf| buf), log_level: &mut 1},
ModEntry { name: ptr::null(), log_level: ptr::mut_null()}
Expand All @@ -220,7 +217,7 @@ fn iter_crate_map_follow_children() {

let child_crate1_ptr: *CrateMap = transmute(&child_crate1);
let root_crate = CrateMapT2 {
version: 1, annihilate_fn: ptr::null(),
version: 1,
entries: vec::raw::to_ptr([
ModEntry { name: "t::f1".to_c_str().with_ref(|buf| buf), log_level: &mut 0},
ModEntry { name: ptr::null(), log_level: ptr::mut_null()}
Expand Down