Skip to content

Commit 637ba81

Browse files
jyasskingraydon
authored andcommitted
---
yaml --- r: 301 b: refs/heads/master c: 22eca31 h: refs/heads/master i: 299: 18617e3 v: v3
1 parent b7311c2 commit 637ba81

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
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: 8ebf72ed29f7f6cb35051d766ba9900509f4aaa1
2+
refs/heads/master: 22eca31d98ce3e1bc5690799e669911e4d06a5aa

trunk/src/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,6 @@ TEST_XFAILS_LLVM := $(addprefix test/run-pass/, \
366366
acyclic-unwind.rs \
367367
alt-pattern-simple.rs \
368368
alt-tag.rs \
369-
argv.rs \
370369
basic.rs \
371370
bind-obj-ctor.rs \
372371
bind-thunk.rs \

trunk/src/boot/llvm/llabi.ml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ type abi = {
1111

1212
let declare_abi (llctx:Llvm.llcontext) (llmod:Llvm.llmodule) : abi =
1313
let i32 = Llvm.i32_type llctx in
14+
(* FIXME: Use Llvm_target.intptr_type for more platform support. *)
15+
let word_ty = i32 in
1416

1517
let crate_ty =
1618
(* TODO: other architectures besides x86 *)
@@ -51,19 +53,16 @@ let declare_abi (llctx:Llvm.llcontext) (llmod:Llvm.llmodule) : abi =
5153
ignore (Llvm.define_type_name "rust_task" task_ty llmod);
5254

5355
let rust_start_ty =
54-
let task_ptr_ty = Llvm.pointer_type task_ty in
55-
let llnilty = Llvm.array_type (Llvm.i1_type llctx) 0 in
56-
let main_ty = Llvm.function_type (Llvm.void_type llctx)
57-
[| Llvm.pointer_type llnilty; task_ptr_ty; |]
58-
in
59-
let args_ty = Array.map Llvm.pointer_type [| main_ty; crate_ty; |] in
60-
let args_ty = Array.append args_ty [| i32; i32 |] in
56+
(* Rust's main function can have several types, so we cast them
57+
all to uintptr_t. *)
58+
let main_ty = word_ty in
59+
let args_ty = [| main_ty; Llvm.pointer_type crate_ty; i32; i32 |] in
6160
Llvm.function_type i32 args_ty
6261
in
6362
{
6463
crate_ty = crate_ty;
6564
task_ty = task_ty;
66-
word_ty = i32;
65+
word_ty = word_ty;
6766
rust_start = Llvm.declare_function "rust_start" rust_start_ty llmod
6867
}
6968
;;

trunk/src/boot/llvm/llfinal.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ let finalize_module
7979
| Some fn -> fn
8080
in
8181
let rust_start = abi.Llabi.rust_start in
82-
let rust_start_args = [| rust_main_fn; crate_ptr; argc; argv |] in
82+
let rust_start_args = [| Llvm.const_ptrtoint rust_main_fn abi.Llabi.word_ty;
83+
crate_ptr; argc; argv |] in
8384
ignore (Llvm.build_call
8485
rust_start rust_start_args "start_rust" main_builder);
8586
ignore (Llvm.build_ret (Llvm.const_int i32 0) main_builder)

0 commit comments

Comments
 (0)