Remove the annihilate function from the crate map. Fixes #8431

This commit is contained in:
Luqman Aden 2013-09-24 13:35:42 -04:00
parent 7535479633
commit 90e009f9b6
2 changed files with 15 additions and 20 deletions

View File

@ -2949,7 +2949,7 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta,
}; };
let sym_name = ~"_rust_crate_map_" + mapname; let sym_name = ~"_rust_crate_map_" + mapname;
let arrtype = Type::array(&int_type, n_subcrates as u64); 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| { let map = do sym_name.with_c_str |buf| {
unsafe { unsafe {
llvm::LLVMAddGlobal(llmod, maptype.to_ref(), buf) llvm::LLVMAddGlobal(llmod, maptype.to_ref(), buf)
@ -2990,8 +2990,6 @@ pub fn fill_crate_map(ccx: @mut CrateContext, map: ValueRef) {
let mod_map = create_module_map(ccx); let mod_map = create_module_map(ccx);
llvm::LLVMSetInitializer(map, C_struct( llvm::LLVMSetInitializer(map, C_struct(
[C_i32(1), [C_i32(1),
// FIXME #8431 This used to be the annihilate function, now it's nothing
C_null(Type::i8p()),
p2i(ccx, mod_map), p2i(ccx, mod_map),
C_array(ccx.int_type, subcrates)])); C_array(ccx.int_type, subcrates)]));
} }

View File

@ -9,7 +9,8 @@
// except according to those terms. // 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;
use ptr::RawPtr; use ptr::RawPtr;
use vec; use vec;
@ -39,6 +40,7 @@ struct CrateMapV0 {
children: [*CrateMap, ..1] children: [*CrateMap, ..1]
} }
#[cfg(stage0)]
struct CrateMap { struct CrateMap {
version: i32, version: i32,
annihilate_fn: *c_void, annihilate_fn: *c_void,
@ -48,6 +50,15 @@ struct CrateMap {
children: [*CrateMap, ..1] 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))] #[cfg(not(windows))]
pub fn get_crate_map() -> *CrateMap { pub fn get_crate_map() -> *CrateMap {
&'static CRATE_MAP as *CrateMap &'static CRATE_MAP as *CrateMap
@ -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 { unsafe fn entries(crate_map: *CrateMap) -> *ModEntry {
match version(crate_map) { match version(crate_map) {
0 => { 0 => {
@ -145,7 +147,6 @@ fn iter_crate_map_duplicates() {
struct CrateMapT3 { struct CrateMapT3 {
version: i32, version: i32,
annihilate_fn: *c_void,
entries: *ModEntry, entries: *ModEntry,
children: [*CrateMap, ..3] children: [*CrateMap, ..3]
} }
@ -160,13 +161,12 @@ fn iter_crate_map_duplicates() {
]; ];
let child_crate = CrateMap { let child_crate = CrateMap {
version: 1, version: 1,
annihilate_fn: ptr::null(),
entries: vec::raw::to_ptr(entries), entries: vec::raw::to_ptr(entries),
children: [ptr::null()] children: [ptr::null()]
}; };
let root_crate = CrateMapT3 { 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()}]), 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()] children: [&child_crate as *CrateMap, &child_crate as *CrateMap, ptr::null()]
}; };
@ -187,7 +187,6 @@ fn iter_crate_map_follow_children() {
struct CrateMapT2 { struct CrateMapT2 {
version: i32, version: i32,
annihilate_fn: *c_void,
entries: *ModEntry, entries: *ModEntry,
children: [*CrateMap, ..2] children: [*CrateMap, ..2]
} }
@ -199,7 +198,6 @@ fn iter_crate_map_follow_children() {
let mut level3: u32 = 3; let mut level3: u32 = 3;
let child_crate2 = CrateMap { let child_crate2 = CrateMap {
version: 1, version: 1,
annihilate_fn: ptr::null(),
entries: vec::raw::to_ptr([ entries: vec::raw::to_ptr([
ModEntry { name: mod_name1.with_ref(|buf| buf), log_level: &mut level2}, ModEntry { name: mod_name1.with_ref(|buf| buf), log_level: &mut level2},
ModEntry { name: mod_name2.with_ref(|buf| buf), log_level: &mut level3}, ModEntry { name: mod_name2.with_ref(|buf| buf), log_level: &mut level3},
@ -210,7 +208,6 @@ fn iter_crate_map_follow_children() {
let child_crate1 = CrateMapT2 { let child_crate1 = CrateMapT2 {
version: 1, version: 1,
annihilate_fn: ptr::null(),
entries: vec::raw::to_ptr([ entries: vec::raw::to_ptr([
ModEntry { name: "t::f1".to_c_str().with_ref(|buf| buf), log_level: &mut 1}, ModEntry { name: "t::f1".to_c_str().with_ref(|buf| buf), log_level: &mut 1},
ModEntry { name: ptr::null(), log_level: ptr::mut_null()} ModEntry { name: ptr::null(), log_level: ptr::mut_null()}
@ -220,7 +217,7 @@ fn iter_crate_map_follow_children() {
let child_crate1_ptr: *CrateMap = transmute(&child_crate1); let child_crate1_ptr: *CrateMap = transmute(&child_crate1);
let root_crate = CrateMapT2 { let root_crate = CrateMapT2 {
version: 1, annihilate_fn: ptr::null(), version: 1,
entries: vec::raw::to_ptr([ entries: vec::raw::to_ptr([
ModEntry { name: "t::f1".to_c_str().with_ref(|buf| buf), log_level: &mut 0}, ModEntry { name: "t::f1".to_c_str().with_ref(|buf| buf), log_level: &mut 0},
ModEntry { name: ptr::null(), log_level: ptr::mut_null()} ModEntry { name: ptr::null(), log_level: ptr::mut_null()}