Skip to content

Commit d7bb40c

Browse files
committed
auto merge of #9470 : luqmana/rust/bba, r=brson
#8431 ~~@brson: do we need to bump up the cratemap version for this change?~~ Tis a no.
2 parents 512f778 + 90e009f commit d7bb40c

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

src/librustc/middle/trans/base.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -2950,7 +2950,7 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta,
29502950
};
29512951
let sym_name = ~"_rust_crate_map_" + mapname;
29522952
let arrtype = Type::array(&int_type, n_subcrates as u64);
2953-
let maptype = Type::struct_([Type::i32(), Type::i8p(), int_type, arrtype], false);
2953+
let maptype = Type::struct_([Type::i32(), int_type, arrtype], false);
29542954
let map = do sym_name.with_c_str |buf| {
29552955
unsafe {
29562956
llvm::LLVMAddGlobal(llmod, maptype.to_ref(), buf)
@@ -2991,8 +2991,6 @@ pub fn fill_crate_map(ccx: @mut CrateContext, map: ValueRef) {
29912991
let mod_map = create_module_map(ccx);
29922992
llvm::LLVMSetInitializer(map, C_struct(
29932993
[C_i32(1),
2994-
// FIXME #8431 This used to be the annihilate function, now it's nothing
2995-
C_null(Type::i8p()),
29962994
p2i(ccx, mod_map),
29972995
C_array(ccx.int_type, subcrates)]));
29982996
}

src/libstd/rt/crate_map.rs

+14-17
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
// except according to those terms.
1010

1111

12-
use libc::{c_void, c_char};
12+
use libc::c_char;
13+
#[cfg(stage0)] use libc::c_void;
1314
use ptr;
1415
use ptr::RawPtr;
1516
use vec;
@@ -39,6 +40,7 @@ struct CrateMapV0 {
3940
children: [*CrateMap, ..1]
4041
}
4142

43+
#[cfg(stage0)]
4244
struct CrateMap {
4345
version: i32,
4446
annihilate_fn: *c_void,
@@ -48,6 +50,15 @@ struct CrateMap {
4850
children: [*CrateMap, ..1]
4951
}
5052

53+
#[cfg(not(stage0))]
54+
struct CrateMap {
55+
version: i32,
56+
entries: *ModEntry,
57+
/// a dynamically sized struct, where all pointers to children are listed adjacent
58+
/// to the struct, terminated with NULL
59+
children: [*CrateMap, ..1]
60+
}
61+
5162
#[cfg(not(windows))]
5263
pub fn get_crate_map() -> *CrateMap {
5364
&'static CRATE_MAP as *CrateMap
@@ -79,15 +90,6 @@ unsafe fn version(crate_map: *CrateMap) -> i32 {
7990
}
8091
}
8192

82-
/// Returns a pointer to the annihilate function of the CrateMap
83-
pub unsafe fn annihilate_fn(crate_map: *CrateMap) -> *c_void {
84-
match version(crate_map) {
85-
0 => return ptr::null(),
86-
1 => return (*crate_map).annihilate_fn,
87-
_ => fail!("Unknown crate map version!")
88-
}
89-
}
90-
9193
unsafe fn entries(crate_map: *CrateMap) -> *ModEntry {
9294
match version(crate_map) {
9395
0 => {
@@ -145,7 +147,6 @@ fn iter_crate_map_duplicates() {
145147

146148
struct CrateMapT3 {
147149
version: i32,
148-
annihilate_fn: *c_void,
149150
entries: *ModEntry,
150151
children: [*CrateMap, ..3]
151152
}
@@ -160,13 +161,12 @@ fn iter_crate_map_duplicates() {
160161
];
161162
let child_crate = CrateMap {
162163
version: 1,
163-
annihilate_fn: ptr::null(),
164164
entries: vec::raw::to_ptr(entries),
165165
children: [ptr::null()]
166166
};
167167

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

188188
struct CrateMapT2 {
189189
version: i32,
190-
annihilate_fn: *c_void,
191190
entries: *ModEntry,
192191
children: [*CrateMap, ..2]
193192
}
@@ -199,7 +198,6 @@ fn iter_crate_map_follow_children() {
199198
let mut level3: u32 = 3;
200199
let child_crate2 = CrateMap {
201200
version: 1,
202-
annihilate_fn: ptr::null(),
203201
entries: vec::raw::to_ptr([
204202
ModEntry { name: mod_name1.with_ref(|buf| buf), log_level: &mut level2},
205203
ModEntry { name: mod_name2.with_ref(|buf| buf), log_level: &mut level3},
@@ -210,7 +208,6 @@ fn iter_crate_map_follow_children() {
210208

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

221218
let child_crate1_ptr: *CrateMap = transmute(&child_crate1);
222219
let root_crate = CrateMapT2 {
223-
version: 1, annihilate_fn: ptr::null(),
220+
version: 1,
224221
entries: vec::raw::to_ptr([
225222
ModEntry { name: "t::f1".to_c_str().with_ref(|buf| buf), log_level: &mut 0},
226223
ModEntry { name: ptr::null(), log_level: ptr::mut_null()}

0 commit comments

Comments
 (0)