Skip to content

Commit 2aadd36

Browse files
committed
mark globals as internal when not building a library
Closes #9494
1 parent f210a16 commit 2aadd36

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

src/librustc/middle/trans/base.rs

+8-17
Original file line numberDiff line numberDiff line change
@@ -2544,6 +2544,10 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::NodeId) -> ValueRef {
25442544
llvm::LLVMAddGlobal(ccx.llmod, llty, buf)
25452545
};
25462546

2547+
if !*ccx.sess.building_library {
2548+
lib::llvm::SetLinkage(g, lib::llvm::InternalLinkage);
2549+
}
2550+
25472551
// Apply the `unnamed_addr` attribute if
25482552
// requested
25492553
if attr::contains_name(i.attrs,
@@ -3058,31 +3062,18 @@ pub fn write_metadata(cx: &mut CrateContext, crate: &ast::Crate) {
30583062
}
30593063
}
30603064

3061-
fn mk_global(ccx: &CrateContext,
3062-
name: &str,
3063-
llval: ValueRef,
3064-
internal: bool)
3065-
-> ValueRef {
3065+
// Writes the current ABI version into the crate.
3066+
pub fn write_abi_version(ccx: &mut CrateContext) {
30663067
unsafe {
3067-
let llglobal = do name.with_c_str |buf| {
3068+
let llval = C_uint(ccx, abi::abi_version);
3069+
let llglobal = do "rust_abi_version".with_c_str |buf| {
30683070
llvm::LLVMAddGlobal(ccx.llmod, val_ty(llval).to_ref(), buf)
30693071
};
30703072
llvm::LLVMSetInitializer(llglobal, llval);
30713073
llvm::LLVMSetGlobalConstant(llglobal, True);
3072-
3073-
if internal {
3074-
lib::llvm::SetLinkage(llglobal, lib::llvm::InternalLinkage);
3075-
}
3076-
3077-
return llglobal;
30783074
}
30793075
}
30803076

3081-
// Writes the current ABI version into the crate.
3082-
pub fn write_abi_version(ccx: &mut CrateContext) {
3083-
mk_global(ccx, "rust_abi_version", C_uint(ccx, abi::abi_version), false);
3084-
}
3085-
30863077
pub fn trans_crate(sess: session::Session,
30873078
crate: &ast::Crate,
30883079
analysis: &CrateAnalysis,

0 commit comments

Comments
 (0)