Skip to content

Commit e2d30ae

Browse files
committed
---
yaml --- r: 82432 b: refs/heads/auto c: 8f65529 h: refs/heads/master v: v3
1 parent 047530f commit e2d30ae

File tree

7 files changed

+19
-113
lines changed

7 files changed

+19
-113
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 133200a6e293f6e74b14ddb6334fab11b13e0f46
16+
refs/heads/auto: 8f6552962772c40a9d18d9ec46419a99a123ad16
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc/middle/trans/base.rs

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2388,38 +2388,12 @@ pub fn create_entry_wrapper(ccx: @mut CrateContext,
23882388
let et = ccx.sess.entry_type.unwrap();
23892389
match et {
23902390
session::EntryMain => {
2391-
let llfn = create_main(ccx, main_llfn);
2392-
create_entry_fn(ccx, llfn, true);
2391+
create_entry_fn(ccx, main_llfn, true);
23932392
}
23942393
session::EntryStart => create_entry_fn(ccx, main_llfn, false),
23952394
session::EntryNone => {} // Do nothing.
23962395
}
23972396

2398-
fn create_main(ccx: @mut CrateContext, main_llfn: ValueRef) -> ValueRef {
2399-
let nt = ty::mk_nil();
2400-
let llfty = type_of_rust_fn(ccx, [], nt);
2401-
let llfdecl = decl_fn(ccx.llmod, "_rust_main",
2402-
lib::llvm::CCallConv, llfty);
2403-
2404-
let fcx = new_fn_ctxt(ccx, ~[], llfdecl, nt, None);
2405-
2406-
// the args vector built in create_entry_fn will need
2407-
// be updated if this assertion starts to fail.
2408-
assert!(!fcx.caller_expects_out_pointer);
2409-
2410-
let bcx = fcx.entry_bcx.unwrap();
2411-
// Call main.
2412-
let llenvarg = unsafe {
2413-
let env_arg = fcx.env_arg_pos();
2414-
llvm::LLVMGetParam(llfdecl, env_arg as c_uint)
2415-
};
2416-
let args = ~[llenvarg];
2417-
Call(bcx, main_llfn, args, []);
2418-
2419-
finish_fn(fcx, bcx);
2420-
return llfdecl;
2421-
}
2422-
24232397
fn create_entry_fn(ccx: @mut CrateContext,
24242398
rust_main: ValueRef,
24252399
use_start_lang_item: bool) {
@@ -2442,6 +2416,11 @@ pub fn create_entry_wrapper(ccx: @mut CrateContext,
24422416
unsafe {
24432417
llvm::LLVMPositionBuilderAtEnd(bld, llbb);
24442418

2419+
let crate_map = ccx.crate_map;
2420+
let opaque_crate_map = do "crate_map".with_c_str |buf| {
2421+
llvm::LLVMBuildPointerCast(bld, crate_map, Type::i8p().to_ref(), buf)
2422+
};
2423+
24452424
let (start_fn, args) = if use_start_lang_item {
24462425
let start_def_id = match ccx.tcx.lang_items.require(StartFnLangItem) {
24472426
Ok(id) => id,
@@ -2464,7 +2443,8 @@ pub fn create_entry_wrapper(ccx: @mut CrateContext,
24642443
C_null(Type::opaque_box(ccx).ptr_to()),
24652444
opaque_rust_main,
24662445
llvm::LLVMGetParam(llfn, 0),
2467-
llvm::LLVMGetParam(llfn, 1)
2446+
llvm::LLVMGetParam(llfn, 1),
2447+
opaque_crate_map
24682448
]
24692449
};
24702450
(start_fn, args)
@@ -2473,7 +2453,8 @@ pub fn create_entry_wrapper(ccx: @mut CrateContext,
24732453
let args = ~[
24742454
C_null(Type::opaque_box(ccx).ptr_to()),
24752455
llvm::LLVMGetParam(llfn, 0 as c_uint),
2476-
llvm::LLVMGetParam(llfn, 1 as c_uint)
2456+
llvm::LLVMGetParam(llfn, 1 as c_uint),
2457+
opaque_crate_map
24772458
];
24782459

24792460
(rust_main, args)
@@ -2654,16 +2635,13 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::NodeId) -> ValueRef {
26542635
}
26552636
ast::foreign_item_static(*) => {
26562637
let ident = foreign::link_name(ccx, ni);
2657-
unsafe {
2658-
let g = do ident.with_c_str |buf| {
2638+
let g = do ident.with_c_str |buf| {
2639+
unsafe {
26592640
let ty = type_of(ccx, ty);
26602641
llvm::LLVMAddGlobal(ccx.llmod, ty.to_ref(), buf)
2661-
};
2662-
if attr::contains_name(ni.attrs, "weak_linkage") {
2663-
lib::llvm::SetLinkage(g, lib::llvm::ExternalWeakLinkage);
26642642
}
2665-
g
2666-
}
2643+
};
2644+
g
26672645
}
26682646
}
26692647
}

branches/auto/src/librustc/middle/typeck/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,8 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
402402
bound_lifetime_names: opt_vec::Empty,
403403
inputs: ~[
404404
ty::mk_int(),
405-
ty::mk_imm_ptr(tcx, ty::mk_imm_ptr(tcx, ty::mk_u8()))
405+
ty::mk_imm_ptr(tcx, ty::mk_imm_ptr(tcx, ty::mk_u8())),
406+
ty::mk_imm_ptr(tcx, ty::mk_u8())
406407
],
407408
output: ty::mk_int()
408409
}

branches/auto/src/libstd/rt/crate_map.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,7 @@ use vec;
1616
use hashmap::HashSet;
1717
use container::MutableSet;
1818

19-
extern {
20-
#[cfg(not(stage0))]
21-
#[weak_linkage]
22-
#[link_name = "_rust_crate_map_toplevel"]
23-
static CRATE_MAP: CrateMap;
24-
}
25-
26-
pub struct ModEntry {
19+
pub struct ModEntry{
2720
name: *c_char,
2821
log_level: *mut u32
2922
}
@@ -41,11 +34,6 @@ struct CrateMap {
4134
children: [*CrateMap, ..1]
4235
}
4336

44-
#[cfg(not(stage0))]
45-
pub fn get_crate_map() -> *CrateMap {
46-
&'static CRATE_MAP as *CrateMap
47-
}
48-
4937
unsafe fn version(crate_map: *CrateMap) -> i32 {
5038
match (*crate_map).version {
5139
1 => return 1,

branches/auto/src/libstd/rt/logging.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use libc::{uintptr_t, exit, STDERR_FILENO};
1212
use option::{Some, None, Option};
1313
use rt::util::dumb_println;
1414
use rt::crate_map::{ModEntry, iter_crate_map};
15-
#[cfg(not(stage0))] use rt::crate_map::get_crate_map;
1615
use str::StrSlice;
1716
use str::raw::from_c_str;
1817
use u32;
@@ -212,7 +211,6 @@ impl Logger for StdErrLogger {
212211
/// Configure logging by traversing the crate map and setting the
213212
/// per-module global logging flags based on the logging spec
214213
#[fixed_stack_segment] #[inline(never)]
215-
#[cfg(stage0)]
216214
pub fn init(crate_map: *u8) {
217215
use os;
218216

@@ -226,22 +224,6 @@ pub fn init(crate_map: *u8) {
226224
}
227225
}
228226
}
229-
#[cfg(not(stage0))]
230-
pub fn init() {
231-
use os;
232-
233-
let crate_map = get_crate_map() as *u8;
234-
235-
let log_spec = os::getenv("RUST_LOG");
236-
match log_spec {
237-
Some(spec) => {
238-
update_log_settings(crate_map, spec);
239-
}
240-
None => {
241-
update_log_settings(crate_map, ~"");
242-
}
243-
}
244-
}
245227

246228
#[fixed_stack_segment] #[inline(never)]
247229
pub fn console_on() { unsafe { rust_log_console_on() } }

branches/auto/src/libstd/rt/mod.rs

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,11 @@ pub mod borrowck;
171171
///
172172
/// * `argc` & `argv` - The argument vector. On Unix this information is used
173173
/// by os::args.
174+
/// * `crate_map` - Runtime information about the executing crate, mostly for logging
174175
///
175176
/// # Return value
176177
///
177178
/// The return value is used as the process return code. 0 on success, 101 on error.
178-
#[cfg(stage0)]
179179
pub fn start(argc: int, argv: **u8, crate_map: *u8, main: ~fn()) -> int {
180180

181181
init(argc, argv, crate_map);
@@ -184,44 +184,25 @@ pub fn start(argc: int, argv: **u8, crate_map: *u8, main: ~fn()) -> int {
184184

185185
return exit_code;
186186
}
187-
#[cfg(not(stage0))]
188-
pub fn start(argc: int, argv: **u8, main: ~fn()) -> int {
189-
190-
init(argc, argv);
191-
let exit_code = run(main);
192-
cleanup();
193-
194-
return exit_code;
195-
}
196187

197188
/// Like `start` but creates an additional scheduler on the current thread,
198189
/// which in most cases will be the 'main' thread, and pins the main task to it.
199190
///
200191
/// This is appropriate for running code that must execute on the main thread,
201192
/// such as the platform event loop and GUI.
202-
#[cfg(stage0)]
203193
pub fn start_on_main_thread(argc: int, argv: **u8, crate_map: *u8, main: ~fn()) -> int {
204194
init(argc, argv, crate_map);
205195
let exit_code = run_on_main_thread(main);
206196
cleanup();
207197

208198
return exit_code;
209199
}
210-
#[cfg(not(stage0))]
211-
pub fn start_on_main_thread(argc: int, argv: **u8, main: ~fn()) -> int {
212-
init(argc, argv);
213-
let exit_code = run_on_main_thread(main);
214-
cleanup();
215-
216-
return exit_code;
217-
}
218200

219201
/// One-time runtime initialization.
220202
///
221203
/// Initializes global state, including frobbing
222204
/// the crate's logging flags, registering GC
223205
/// metadata, and storing the process arguments.
224-
#[cfg(stage0)]
225206
pub fn init(argc: int, argv: **u8, crate_map: *u8) {
226207
// XXX: Derefing these pointers is not safe.
227208
// Need to propagate the unsafety to `start`.
@@ -231,16 +212,6 @@ pub fn init(argc: int, argv: **u8, crate_map: *u8) {
231212
logging::init(crate_map);
232213
}
233214
}
234-
#[cfg(not(stage0))]
235-
pub fn init(argc: int, argv: **u8) {
236-
// XXX: Derefing these pointers is not safe.
237-
// Need to propagate the unsafety to `start`.
238-
unsafe {
239-
args::init(argc, argv);
240-
env::init();
241-
logging::init();
242-
}
243-
}
244215

245216
/// One-time runtime cleanup.
246217
pub fn cleanup() {

branches/auto/src/libstd/unstable/lang.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ pub unsafe fn check_not_borrowed(a: *u8,
9393
borrowck::check_not_borrowed(a, file, line)
9494
}
9595

96-
#[cfg(stage0)]
9796
#[lang="start"]
9897
pub fn start(main: *u8, argc: int, argv: **c_char,
9998
crate_map: *u8) -> int {
@@ -106,16 +105,3 @@ pub fn start(main: *u8, argc: int, argv: **c_char,
106105
};
107106
}
108107
}
109-
110-
#[cfg(not(stage0))]
111-
#[lang="start"]
112-
pub fn start(main: *u8, argc: int, argv: **c_char) -> int {
113-
use rt;
114-
115-
unsafe {
116-
return do rt::start(argc, argv as **u8) {
117-
let main: extern "Rust" fn() = transmute(main);
118-
main();
119-
};
120-
}
121-
}

0 commit comments

Comments
 (0)