give rust_metadata internal linkage but mark it as used. This allows

multiple static crates to be used.
This commit is contained in:
Rafael Ávila de Espíndola 2011-07-20 14:52:31 -04:00
parent a467e8e4e6
commit b7a7120804

View File

@ -8564,6 +8564,17 @@ fn write_metadata(&@trans::crate_ctxt cx, &@ast::crate crate) {
str::buf("rust_metadata"));
llvm::LLVMSetInitializer(llglobal, llconst);
llvm::LLVMSetSection(llglobal, str::buf(x86::get_meta_sect_name()));
llvm::LLVMSetLinkage(llglobal,
lib::llvm::LLVMInternalLinkage as llvm::Linkage);
auto t_ptr_i8 = T_ptr(T_i8());
llglobal = llvm::LLVMConstBitCast(llglobal, t_ptr_i8);
auto llvm_used =
llvm::LLVMAddGlobal(cx.llmod, T_array(t_ptr_i8, 1u),
str::buf("llvm_used"));
llvm::LLVMSetLinkage(llvm_used,
lib::llvm::LLVMAppendingLinkage as llvm::Linkage);
llvm::LLVMSetInitializer(llvm_used, C_array(t_ptr_i8, ~[llglobal]));
}
fn trans_crate(&session::session sess, &@ast::crate crate, &ty::ctxt tcx,