From b7a7120804520e621950e1ac5f86cdafec106f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Wed, 20 Jul 2011 14:52:31 -0400 Subject: [PATCH] give rust_metadata internal linkage but mark it as used. This allows multiple static crates to be used. --- src/comp/middle/trans.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index ee290dc18d5..14d102ca8ce 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -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,