diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2013-09-26 18:43:21 -0400 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2013-09-26 19:21:22 -0400 |
| commit | 2aadd3652dbbfa1179eea57091b0de2dc87006a4 (patch) | |
| tree | 3b5b88b67f62f68b2d98609a59c8d856f97c2822 | |
| parent | f210a1671883d5fe97a2b06ebbe9270fa9a6943a (diff) | |
| download | rust-2aadd3652dbbfa1179eea57091b0de2dc87006a4.tar.gz rust-2aadd3652dbbfa1179eea57091b0de2dc87006a4.zip | |
mark globals as internal when not building a library
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 479f10a3b4a..acf6cf08fdc 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, |
