Skip to content

Commit bb08404

Browse files
committed
---
yaml --- r: 1407 b: refs/heads/master c: 60f97aa h: refs/heads/master i: 1405: a7a682f 1403: 65c2a8b 1399: 1377acd 1391: e20878d 1375: 5e268f1 1343: 3c060be 1279: 6706a1b v: v3
1 parent ff15967 commit bb08404

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: cbe8d222a82c14485cf416c4b85fd5e58363c0e0
2+
refs/heads/master: 60f97aa9cc73ee4e0b57abc07dc543c8fa823ee2

trunk/src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ TEST_XFAILS_RUSTC := $(filter-out \
492492
int.rs \
493493
i32-sub.rs \
494494
i8-incr.rs \
495+
import.rs \
495496
import2.rs \
496497
import3.rs \
497498
import4.rs \

trunk/src/comp/middle/trans.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4602,6 +4602,30 @@ fn create_crate_constant(@crate_ctxt cx) {
46024602
llvm.LLVMSetInitializer(cx.crate_ptr, crate_val);
46034603
}
46044604

4605+
fn find_main_fn(@crate_ctxt cx) -> ValueRef {
4606+
auto e = sep() + "main";
4607+
let ValueRef v = C_nil();
4608+
let uint n = 0u;
4609+
for each (tup(str,ValueRef) i in cx.item_names.items()) {
4610+
if (_str.ends_with(i._0, e)) {
4611+
n += 1u;
4612+
v = i._1;
4613+
}
4614+
}
4615+
alt (n) {
4616+
case (0u) {
4617+
cx.sess.err("main fn not found");
4618+
}
4619+
case (1u) {
4620+
ret v;
4621+
}
4622+
case (_) {
4623+
cx.sess.err("multiple main fns found");
4624+
}
4625+
}
4626+
fail;
4627+
}
4628+
46054629
fn trans_main_fn(@crate_ctxt cx, ValueRef llcrate) {
46064630
auto T_main_args = vec(T_int(), T_int());
46074631
auto T_rust_start_args = vec(T_int(), T_int(), T_int(), T_int());
@@ -4621,8 +4645,7 @@ fn trans_main_fn(@crate_ctxt cx, ValueRef llcrate) {
46214645

46224646
auto llargc = llvm.LLVMGetParam(llmain, 0u);
46234647
auto llargv = llvm.LLVMGetParam(llmain, 1u);
4624-
check (cx.item_names.contains_key("_rust" + sep() + "main"));
4625-
auto llrust_main = cx.item_names.get("_rust" + sep() + "main");
4648+
auto llrust_main = find_main_fn(cx);
46264649

46274650
//
46284651
// Emit the moral equivalent of:

0 commit comments

Comments
 (0)