diff options
| author | Patrick Walton <[email protected]> | 2011-05-05 12:45:34 -0700 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2011-05-05 12:46:22 -0700 |
| commit | a74feaf1594673bcec77ed45bd4b6766289a25b3 (patch) | |
| tree | 0e9ae545b866d22b99d6d22424fed528a76b6796 | |
| parent | Put out burning tinderbox. (diff) | |
| download | rust-a74feaf1594673bcec77ed45bd4b6766289a25b3.tar.xz rust-a74feaf1594673bcec77ed45bd4b6766289a25b3.zip | |
rustc: Link with intrinsics.bc; change intrinsics linkage to linkonce_odr
| -rw-r--r-- | src/comp/back/Link.rs | 26 | ||||
| -rw-r--r-- | src/comp/back/x86.rs | 4 | ||||
| -rw-r--r-- | src/rt/intrinsics/intrinsics.cpp | 3 | ||||
| -rw-r--r-- | src/rt/intrinsics/intrinsics.ll.in | 2 |
4 files changed, 32 insertions, 3 deletions
diff --git a/src/comp/back/Link.rs b/src/comp/back/Link.rs index da165787..ebeda8dc 100644 --- a/src/comp/back/Link.rs +++ b/src/comp/back/Link.rs @@ -2,12 +2,14 @@ import driver.session; import lib.llvm.llvm; import middle.trans; import std._str; +import std.fs; import lib.llvm.llvm.ModuleRef; import lib.llvm.llvm.ValueRef; import lib.llvm.mk_pass_manager; import lib.llvm.mk_target_data; import lib.llvm.mk_type_names; +import lib.llvm.False; tag output_type { output_type_none; @@ -16,8 +18,30 @@ tag output_type { output_type_object; } +fn llvm_err(session.session sess, str msg) { + sess.err(msg + ": " + _str.str_from_cstr(llvm.LLVMRustGetLastError())); + fail; +} + fn link_intrinsics(session.session sess, ModuleRef llmod) { - // TODO + auto path = fs.connect(sess.get_opts().sysroot, "intrinsics.bc"); + auto membuf = + llvm.LLVMRustCreateMemoryBufferWithContentsOfFile(_str.buf(path)); + if ((membuf as uint) == 0u) { + llvm_err(sess, "installation problem: couldn't open intrinstics.bc"); + fail; + } + + auto llintrinsicsmod = llvm.LLVMRustParseBitcode(membuf); + if ((llintrinsicsmod as uint) == 0u) { + llvm_err(sess, "installation problem: couldn't parse intrinstics.bc"); + fail; + } + + if (llvm.LLVMLinkModules(llmod, llintrinsicsmod) == False) { + llvm_err(sess, "couldn't link the module with the intrinsics"); + fail; + } } mod Write { diff --git a/src/comp/back/x86.rs b/src/comp/back/x86.rs index 063afe03..a40592d5 100644 --- a/src/comp/back/x86.rs +++ b/src/comp/back/x86.rs @@ -336,7 +336,9 @@ fn get_meta_sect_name() -> str { fn get_data_layout() -> str { if (_str.eq(target_os(), "macos")) { - ret "e-p:32:32-f64:32:64-i64:32:64-f80:128:128-n8:16:32"; + ret "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64" + + "-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" + + "-n8:16:32"; } if (_str.eq(target_os(), "win32")) { ret "e-p:32:32-f64:64:64-i64:64:64-f80:32:32-n8:16:32"; diff --git a/src/rt/intrinsics/intrinsics.cpp b/src/rt/intrinsics/intrinsics.cpp index 7c4b5450..b327c0f1 100644 --- a/src/rt/intrinsics/intrinsics.cpp +++ b/src/rt/intrinsics/intrinsics.cpp @@ -1,3 +1,6 @@ +// Use `clang++ -emit-llvm -S -arch i386 -O3 -I../isaac -I../uthash -o +// intrinsics.ll intrinsics.cpp` + #include "../rust_internal.h" extern "C" size_t diff --git a/src/rt/intrinsics/intrinsics.ll.in b/src/rt/intrinsics/intrinsics.ll.in index 2a05555e..ab78bab7 100644 --- a/src/rt/intrinsics/intrinsics.ll.in +++ b/src/rt/intrinsics/intrinsics.ll.in @@ -51,7 +51,7 @@ target triple = "@CFG_LLVM_TRIPLE@" %struct.stk_seg = type { i32, i32, [0 x i8] } %struct.type_desc = type { %struct.type_desc**, i32, i32, i32, i32, i32, i32, i32, i32, i32, %struct.UT_hash_handle, i32, [0 x %struct.type_desc*] } -define i32 @rust_intrinsic_vec_len(%struct.rust_task* nocapture %task, %struct.type_desc* nocapture %ty, %struct.rust_vec* nocapture %v) nounwind readonly ssp { +define linkonce_odr i32 @rust_intrinsic_vec_len(%struct.rust_task* nocapture %task, %struct.type_desc* nocapture %ty, %struct.rust_vec* nocapture %v) nounwind readonly ssp { entry: %fill = getelementptr inbounds %struct.rust_vec* %v, i32 0, i32 2 %tmp1 = load i32* %fill, align 4, !tbaa !0 |