Skip to content

Commit 92bd350

Browse files
author
Eric Holk
committed
Step 2 of cdecl task transition.
1 parent 6a3f4ab commit 92bd350

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

src/rt/main.ll.in

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
@_rust_crate_map_toplevel = external global %0
1111

1212
declare fastcc void @_rust_main(i1* nocapture, %task*, %2* nocapture, %5*);
13-
declare i32 @rust_start(i32, i32, i32, i32, i32)
13+
declare i32 @rust_start(i32, i32, i32, i32)
1414

1515
%tydesc = type { %tydesc**, i32, i32, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*, i8*, i8)* }
1616

@@ -23,7 +23,6 @@ define void @_rust_main_wrap(i1* nocapture, %task *, %2* nocapture, %5 *)
2323
}
2424

2525
define i32 @"MAIN"(i32, i32) {
26-
; %3 = tail call i32 @rust_start(i32 ptrtoint (void (i1*, %task*, %2*, %5*)* @_rust_main_wrap to i32), i32 %0, i32 %1, i32 ptrtoint (%0* @_rust_crate_map_toplevel to i32))
27-
%3 = tail call i32 @rust_start(i32 0, i32 %0, i32 %1, i32 ptrtoint (%0* @_rust_crate_map_toplevel to i32), i32 ptrtoint (void (i1*, %task*, %2*, %5*)* @_rust_main_wrap to i32))
26+
%3 = tail call i32 @rust_start(i32 ptrtoint (void (i1*, %task*, %2*, %5*)* @_rust_main_wrap to i32), i32 %0, i32 %1, i32 ptrtoint (%0* @_rust_crate_map_toplevel to i32))
2827
ret i32 %3
2928
}

src/rt/rust.cpp

+3-13
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,6 @@ command_line_args : public dom_owned<command_line_args>
7171
}
7272
};
7373

74-
// THIS IS AN UGLY HACK TO MAKE rust_start STILL WORK WITH STAGE0 WHILE WE
75-
// TRANSITION TO ALL-CDECL TASK STARTUP FUNCTIONS.
76-
void FASTCALL
77-
(*real_main)(uintptr_t a, uintptr_t b, uintptr_t c, uintptr_t d) = NULL;
78-
79-
void CDECL fake_main(uintptr_t a, uintptr_t b, uintptr_t c, uintptr_t d)
80-
{
81-
real_main(a, b, c, d);
82-
}
83-
8474
/**
8575
* Main entry point into the Rust runtime. Here we create a Rust service,
8676
* initialize the kernel, create the root domain and run it.
@@ -104,9 +94,9 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map,
10494
DLOG(dom, dom, "startup: arg[%d] = '%s'", i, args->argv[i]);
10595
}
10696

107-
real_main = (typeof(real_main))main_fn;
108-
if(main_fn) { printf("using fastcall main\n"); }
109-
dom->root_task->start(main_fn ? (uintptr_t)fake_main : main_fn_cdecl,
97+
if(main_fn) { printf("using new cdecl main\n"); }
98+
else { printf("using old cdecl main\n"); }
99+
dom->root_task->start(main_fn ? main_fn : main_fn_cdecl,
110100
(uintptr_t)args->args, sizeof(args->args));
111101

112102
int ret = dom->start_main_loop();

0 commit comments

Comments
 (0)