aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Yasskin <[email protected]>2010-07-18 07:35:25 +0800
committerGraydon Hoare <[email protected]>2010-07-18 14:25:19 +0800
commit22eca31d98ce3e1bc5690799e669911e4d06a5aa (patch)
treec964fb3ca34ec34f4b9685d711c5097f7c7d0a22
parentFix the LLVM ocamlopt build. (diff)
downloadrust-22eca31d98ce3e1bc5690799e669911e4d06a5aa.tar.xz
rust-22eca31d98ce3e1bc5690799e669911e4d06a5aa.zip
Fix argv.rs under the LLVM compiler.
The call to rust_start was assuming that all rust main() functions have the same signature, but the compiler doesn't actually canonicalize them. So instead just match the C signature of rust_start, and cast.
-rw-r--r--src/Makefile1
-rw-r--r--src/boot/llvm/llabi.ml15
-rw-r--r--src/boot/llvm/llfinal.ml3
3 files changed, 9 insertions, 10 deletions
diff --git a/src/Makefile b/src/Makefile
index 8a2162eb..7b2f9f01 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 6a2c6a05..09340c53 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 fd65fa6b..7241d1ab 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)