diff options
| author | bors <bors@rust-lang.org> | 2013-09-27 06:21:22 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-09-27 06:21:22 -0700 |
| commit | 01313a131b1bdef0f2abfc03c5e7f00c8cb00add (patch) | |
| tree | 2464678be490c7257a4468cdd61d43310fcb6d37 | |
| parent | 74dfd93bad2a2343f330cbea38c702192095210a (diff) | |
| parent | 2aadd3652dbbfa1179eea57091b0de2dc87006a4 (diff) | |
| download | rust-01313a131b1bdef0f2abfc03c5e7f00c8cb00add.tar.gz rust-01313a131b1bdef0f2abfc03c5e7f00c8cb00add.zip | |
auto merge of #9548 : thestinger/rust/internal, r=alexcrichton
Closes #9494
| -rw-r--r-- | src/librustc/middle/trans/base.rs | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index bb793dd2155..91316618c4f 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -2544,6 +2544,10 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::NodeId) -> ValueRef { llvm::LLVMAddGlobal(ccx.llmod, llty, buf) }; + if !*ccx.sess.building_library { + lib::llvm::SetLinkage(g, lib::llvm::InternalLinkage); + } + // Apply the `unnamed_addr` attribute if // requested if attr::contains_name(i.attrs, @@ -3058,31 +3062,18 @@ pub fn write_metadata(cx: &mut CrateContext, crate: &ast::Crate) { } } -fn mk_global(ccx: &CrateContext, - name: &str, - llval: ValueRef, - internal: bool) - -> ValueRef { +// Writes the current ABI version into the crate. +pub fn write_abi_version(ccx: &mut CrateContext) { unsafe { - let llglobal = do name.with_c_str |buf| { + let llval = C_uint(ccx, abi::abi_version); + let llglobal = do "rust_abi_version".with_c_str |buf| { llvm::LLVMAddGlobal(ccx.llmod, val_ty(llval).to_ref(), buf) }; llvm::LLVMSetInitializer(llglobal, llval); llvm::LLVMSetGlobalConstant(llglobal, True); - - if internal { - lib::llvm::SetLinkage(llglobal, lib::llvm::InternalLinkage); - } - - return llglobal; } } -// Writes the current ABI version into the crate. -pub fn write_abi_version(ccx: &mut CrateContext) { - mk_global(ccx, "rust_abi_version", C_uint(ccx, abi::abi_version), false); -} - pub fn trans_crate(sess: session::Session, crate: &ast::Crate, analysis: &CrateAnalysis, |
