rustc: Link with intrinsics.bc; change intrinsics linkage to linkonce_odr

This commit is contained in:
Patrick Walton 2011-05-05 12:45:34 -07:00
parent 48e0de22c1
commit a74feaf159
4 changed files with 32 additions and 3 deletions

View file

@ -2,12 +2,14 @@
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 @@
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 {

View file

@ -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";

View file

@ -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

View file

@ -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