auto merge of #9548 : thestinger/rust/internal, r=alexcrichton
Closes #9494
This commit is contained in:
commit
01313a131b
|
@ -2544,6 +2544,10 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::NodeId) -> ValueRef {
|
||||||
llvm::LLVMAddGlobal(ccx.llmod, llty, buf)
|
llvm::LLVMAddGlobal(ccx.llmod, llty, buf)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if !*ccx.sess.building_library {
|
||||||
|
lib::llvm::SetLinkage(g, lib::llvm::InternalLinkage);
|
||||||
|
}
|
||||||
|
|
||||||
// Apply the `unnamed_addr` attribute if
|
// Apply the `unnamed_addr` attribute if
|
||||||
// requested
|
// requested
|
||||||
if attr::contains_name(i.attrs,
|
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,
|
// Writes the current ABI version into the crate.
|
||||||
name: &str,
|
pub fn write_abi_version(ccx: &mut CrateContext) {
|
||||||
llval: ValueRef,
|
|
||||||
internal: bool)
|
|
||||||
-> ValueRef {
|
|
||||||
unsafe {
|
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::LLVMAddGlobal(ccx.llmod, val_ty(llval).to_ref(), buf)
|
||||||
};
|
};
|
||||||
llvm::LLVMSetInitializer(llglobal, llval);
|
llvm::LLVMSetInitializer(llglobal, llval);
|
||||||
llvm::LLVMSetGlobalConstant(llglobal, True);
|
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,
|
pub fn trans_crate(sess: session::Session,
|
||||||
crate: &ast::Crate,
|
crate: &ast::Crate,
|
||||||
analysis: &CrateAnalysis,
|
analysis: &CrateAnalysis,
|
||||||
|
|
Loading…
Reference in New Issue