Mark the metadata symbol as reachable to fix OSX not finding dylibs.
This commit is contained in:
parent
07d373f3d6
commit
0d2c26c261
@ -2508,9 +2508,7 @@ pub fn write_metadata<'a, 'tcx>(cx: &SharedCrateContext<'a, 'tcx>,
|
|||||||
|
|
||||||
let llmeta = C_bytes_in_context(cx.metadata_llcx(), &compressed[..]);
|
let llmeta = C_bytes_in_context(cx.metadata_llcx(), &compressed[..]);
|
||||||
let llconst = C_struct_in_context(cx.metadata_llcx(), &[llmeta], false);
|
let llconst = C_struct_in_context(cx.metadata_llcx(), &[llmeta], false);
|
||||||
let name = format!("rust_metadata_{}_{}",
|
let name = cx.metadata_symbol_name();
|
||||||
cx.link_meta().crate_name,
|
|
||||||
cx.link_meta().crate_hash);
|
|
||||||
let buf = CString::new(name).unwrap();
|
let buf = CString::new(name).unwrap();
|
||||||
let llglobal = unsafe {
|
let llglobal = unsafe {
|
||||||
llvm::LLVMAddGlobal(cx.metadata_llmod(), val_ty(llconst).to_ref(), buf.as_ptr())
|
llvm::LLVMAddGlobal(cx.metadata_llmod(), val_ty(llconst).to_ref(), buf.as_ptr())
|
||||||
@ -2812,6 +2810,10 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||||||
reachable_symbols.push("main".to_string());
|
reachable_symbols.push("main".to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if sess.crate_types.borrow().contains(&config::CrateTypeDylib) {
|
||||||
|
reachable_symbols.push(shared_ccx.metadata_symbol_name());
|
||||||
|
}
|
||||||
|
|
||||||
// For the purposes of LTO or when creating a cdylib, we add to the
|
// For the purposes of LTO or when creating a cdylib, we add to the
|
||||||
// reachable set all of the upstream reachable extern fns. These functions
|
// reachable set all of the upstream reachable extern fns. These functions
|
||||||
// are all part of the public ABI of the final product, so we need to
|
// are all part of the public ABI of the final product, so we need to
|
||||||
|
@ -503,6 +503,12 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
|
|||||||
Substs::new(VecPerParamSpace::empty(),
|
Substs::new(VecPerParamSpace::empty(),
|
||||||
scheme.generics.regions.map(|_| ty::ReStatic)))
|
scheme.generics.regions.map(|_| ty::ReStatic)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn metadata_symbol_name(&self) -> String {
|
||||||
|
format!("rust_metadata_{}_{}",
|
||||||
|
self.link_meta().crate_name,
|
||||||
|
self.link_meta().crate_hash)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> LocalCrateContext<'tcx> {
|
impl<'tcx> LocalCrateContext<'tcx> {
|
||||||
|
Loading…
Reference in New Issue
Block a user