diff --git a/src/Makefile b/src/Makefile index 8a2162eb8cf..7b2f9f01182 100644 --- a/src/Makefile +++ b/src/Makefile @@ -366,7 +366,6 @@ TEST_XFAILS_LLVM := $(addprefix test/run-pass/, \ acyclic-unwind.rs \ alt-pattern-simple.rs \ alt-tag.rs \ - argv.rs \ basic.rs \ bind-obj-ctor.rs \ bind-thunk.rs \ diff --git a/src/boot/llvm/llabi.ml b/src/boot/llvm/llabi.ml index 6a2c6a05f69..09340c53645 100644 --- a/src/boot/llvm/llabi.ml +++ b/src/boot/llvm/llabi.ml @@ -11,6 +11,8 @@ type abi = { let declare_abi (llctx:Llvm.llcontext) (llmod:Llvm.llmodule) : abi = let i32 = Llvm.i32_type llctx in + (* FIXME: Use Llvm_target.intptr_type for more platform support. *) + let word_ty = i32 in let crate_ty = (* TODO: other architectures besides x86 *) @@ -51,19 +53,16 @@ let declare_abi (llctx:Llvm.llcontext) (llmod:Llvm.llmodule) : abi = ignore (Llvm.define_type_name "rust_task" task_ty llmod); let rust_start_ty = - let task_ptr_ty = Llvm.pointer_type task_ty in - let llnilty = Llvm.array_type (Llvm.i1_type llctx) 0 in - let main_ty = Llvm.function_type (Llvm.void_type llctx) - [| Llvm.pointer_type llnilty; task_ptr_ty; |] - in - let args_ty = Array.map Llvm.pointer_type [| main_ty; crate_ty; |] in - let args_ty = Array.append args_ty [| i32; i32 |] in + (* Rust's main function can have several types, so we cast them + all to uintptr_t. *) + let main_ty = word_ty in + let args_ty = [| main_ty; Llvm.pointer_type crate_ty; i32; i32 |] in Llvm.function_type i32 args_ty in { crate_ty = crate_ty; task_ty = task_ty; - word_ty = i32; + word_ty = word_ty; rust_start = Llvm.declare_function "rust_start" rust_start_ty llmod } ;; diff --git a/src/boot/llvm/llfinal.ml b/src/boot/llvm/llfinal.ml index fd65fa6b089..7241d1ab33e 100644 --- a/src/boot/llvm/llfinal.ml +++ b/src/boot/llvm/llfinal.ml @@ -79,7 +79,8 @@ let finalize_module | Some fn -> fn in let rust_start = abi.Llabi.rust_start in - let rust_start_args = [| rust_main_fn; crate_ptr; argc; argv |] in + let rust_start_args = [| Llvm.const_ptrtoint rust_main_fn abi.Llabi.word_ty; + crate_ptr; argc; argv |] in ignore (Llvm.build_call rust_start rust_start_args "start_rust" main_builder); ignore (Llvm.build_ret (Llvm.const_int i32 0) main_builder)