Rollup merge of #136691 - bjorn3:linkage_cleanup, r=jieyouxu
Remove Linkage::Private and Linkage::Appending Neither of them has any use case. Neither known nor theoretical.
This commit is contained in:
commit
c9771e9590
10 changed files with 4 additions and 26 deletions
|
@ -49,9 +49,7 @@ pub fn global_linkage_to_gcc(linkage: Linkage) -> GlobalKind {
|
||||||
Linkage::LinkOnceODR => unimplemented!(),
|
Linkage::LinkOnceODR => unimplemented!(),
|
||||||
Linkage::WeakAny => unimplemented!(),
|
Linkage::WeakAny => unimplemented!(),
|
||||||
Linkage::WeakODR => unimplemented!(),
|
Linkage::WeakODR => unimplemented!(),
|
||||||
Linkage::Appending => unimplemented!(),
|
|
||||||
Linkage::Internal => GlobalKind::Internal,
|
Linkage::Internal => GlobalKind::Internal,
|
||||||
Linkage::Private => GlobalKind::Internal,
|
|
||||||
Linkage::ExternalWeak => GlobalKind::Imported, // TODO(antoyo): should be weak linkage.
|
Linkage::ExternalWeak => GlobalKind::Imported, // TODO(antoyo): should be weak linkage.
|
||||||
Linkage::Common => unimplemented!(),
|
Linkage::Common => unimplemented!(),
|
||||||
}
|
}
|
||||||
|
@ -66,9 +64,7 @@ pub fn linkage_to_gcc(linkage: Linkage) -> FunctionType {
|
||||||
Linkage::LinkOnceODR => unimplemented!(),
|
Linkage::LinkOnceODR => unimplemented!(),
|
||||||
Linkage::WeakAny => FunctionType::Exported, // FIXME(antoyo): should be similar to linkonce.
|
Linkage::WeakAny => FunctionType::Exported, // FIXME(antoyo): should be similar to linkonce.
|
||||||
Linkage::WeakODR => unimplemented!(),
|
Linkage::WeakODR => unimplemented!(),
|
||||||
Linkage::Appending => unimplemented!(),
|
|
||||||
Linkage::Internal => FunctionType::Internal,
|
Linkage::Internal => FunctionType::Internal,
|
||||||
Linkage::Private => FunctionType::Internal,
|
|
||||||
Linkage::ExternalWeak => unimplemented!(),
|
Linkage::ExternalWeak => unimplemented!(),
|
||||||
Linkage::Common => unimplemented!(),
|
Linkage::Common => unimplemented!(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,10 +61,7 @@ impl<'gcc, 'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
|
||||||
// compiler-rt, then we want to implicitly compile everything with hidden
|
// compiler-rt, then we want to implicitly compile everything with hidden
|
||||||
// visibility as we're going to link this object all over the place but
|
// visibility as we're going to link this object all over the place but
|
||||||
// don't want the symbols to get exported.
|
// don't want the symbols to get exported.
|
||||||
if linkage != Linkage::Internal
|
if linkage != Linkage::Internal && self.tcx.is_compiler_builtins(LOCAL_CRATE) {
|
||||||
&& linkage != Linkage::Private
|
|
||||||
&& self.tcx.is_compiler_builtins(LOCAL_CRATE)
|
|
||||||
{
|
|
||||||
#[cfg(feature = "master")]
|
#[cfg(feature = "master")]
|
||||||
decl.add_attribute(FnAttribute::Visibility(gccjit::Visibility::Hidden));
|
decl.add_attribute(FnAttribute::Visibility(gccjit::Visibility::Hidden));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -157,9 +157,7 @@ pub(crate) fn linkage_to_llvm(linkage: Linkage) -> llvm::Linkage {
|
||||||
Linkage::LinkOnceODR => llvm::Linkage::LinkOnceODRLinkage,
|
Linkage::LinkOnceODR => llvm::Linkage::LinkOnceODRLinkage,
|
||||||
Linkage::WeakAny => llvm::Linkage::WeakAnyLinkage,
|
Linkage::WeakAny => llvm::Linkage::WeakAnyLinkage,
|
||||||
Linkage::WeakODR => llvm::Linkage::WeakODRLinkage,
|
Linkage::WeakODR => llvm::Linkage::WeakODRLinkage,
|
||||||
Linkage::Appending => llvm::Linkage::AppendingLinkage,
|
|
||||||
Linkage::Internal => llvm::Linkage::InternalLinkage,
|
Linkage::Internal => llvm::Linkage::InternalLinkage,
|
||||||
Linkage::Private => llvm::Linkage::PrivateLinkage,
|
|
||||||
Linkage::ExternalWeak => llvm::Linkage::ExternalWeakLinkage,
|
Linkage::ExternalWeak => llvm::Linkage::ExternalWeakLinkage,
|
||||||
Linkage::Common => llvm::Linkage::CommonLinkage,
|
Linkage::Common => llvm::Linkage::CommonLinkage,
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,10 +71,7 @@ impl<'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> {
|
||||||
// compiler-rt, then we want to implicitly compile everything with hidden
|
// compiler-rt, then we want to implicitly compile everything with hidden
|
||||||
// visibility as we're going to link this object all over the place but
|
// visibility as we're going to link this object all over the place but
|
||||||
// don't want the symbols to get exported.
|
// don't want the symbols to get exported.
|
||||||
if linkage != Linkage::Internal
|
if linkage != Linkage::Internal && self.tcx.is_compiler_builtins(LOCAL_CRATE) {
|
||||||
&& linkage != Linkage::Private
|
|
||||||
&& self.tcx.is_compiler_builtins(LOCAL_CRATE)
|
|
||||||
{
|
|
||||||
llvm::set_visibility(lldecl, llvm::Visibility::Hidden);
|
llvm::set_visibility(lldecl, llvm::Visibility::Hidden);
|
||||||
} else {
|
} else {
|
||||||
llvm::set_visibility(lldecl, base::visibility_to_llvm(visibility));
|
llvm::set_visibility(lldecl, base::visibility_to_llvm(visibility));
|
||||||
|
|
|
@ -41,7 +41,6 @@ fn linkage_by_name(tcx: TyCtxt<'_>, def_id: LocalDefId, name: &str) -> Linkage {
|
||||||
// ghost, dllimport, dllexport and linkonce_odr_autohide are not supported
|
// ghost, dllimport, dllexport and linkonce_odr_autohide are not supported
|
||||||
// and don't have to be, LLVM treats them as no-ops.
|
// and don't have to be, LLVM treats them as no-ops.
|
||||||
match name {
|
match name {
|
||||||
"appending" => Appending,
|
|
||||||
"available_externally" => AvailableExternally,
|
"available_externally" => AvailableExternally,
|
||||||
"common" => Common,
|
"common" => Common,
|
||||||
"extern_weak" => ExternalWeak,
|
"extern_weak" => ExternalWeak,
|
||||||
|
@ -49,7 +48,6 @@ fn linkage_by_name(tcx: TyCtxt<'_>, def_id: LocalDefId, name: &str) -> Linkage {
|
||||||
"internal" => Internal,
|
"internal" => Internal,
|
||||||
"linkonce" => LinkOnceAny,
|
"linkonce" => LinkOnceAny,
|
||||||
"linkonce_odr" => LinkOnceODR,
|
"linkonce_odr" => LinkOnceODR,
|
||||||
"private" => Private,
|
|
||||||
"weak" => WeakAny,
|
"weak" => WeakAny,
|
||||||
"weak_odr" => WeakODR,
|
"weak_odr" => WeakODR,
|
||||||
_ => tcx.dcx().span_fatal(tcx.def_span(def_id), "invalid linkage specified"),
|
_ => tcx.dcx().span_fatal(tcx.def_span(def_id), "invalid linkage specified"),
|
||||||
|
|
|
@ -187,10 +187,9 @@ fn prefix_and_suffix<'tcx>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Linkage::Internal | Linkage::Private => {
|
Linkage::Internal => {
|
||||||
// write nothing
|
// write nothing
|
||||||
}
|
}
|
||||||
Linkage::Appending => emit_fatal("Only global variables can have appending linkage!"),
|
|
||||||
Linkage::Common => emit_fatal("Functions may not have common linkage"),
|
Linkage::Common => emit_fatal("Functions may not have common linkage"),
|
||||||
Linkage::AvailableExternally => {
|
Linkage::AvailableExternally => {
|
||||||
// this would make the function equal an extern definition
|
// this would make the function equal an extern definition
|
||||||
|
|
|
@ -178,7 +178,7 @@ impl CodegenFnAttrs {
|
||||||
|| match self.linkage {
|
|| match self.linkage {
|
||||||
// These are private, so make sure we don't try to consider
|
// These are private, so make sure we don't try to consider
|
||||||
// them external.
|
// them external.
|
||||||
None | Some(Linkage::Internal | Linkage::Private) => false,
|
None | Some(Linkage::Internal) => false,
|
||||||
Some(_) => true,
|
Some(_) => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -327,9 +327,7 @@ pub enum Linkage {
|
||||||
LinkOnceODR,
|
LinkOnceODR,
|
||||||
WeakAny,
|
WeakAny,
|
||||||
WeakODR,
|
WeakODR,
|
||||||
Appending,
|
|
||||||
Internal,
|
Internal,
|
||||||
Private,
|
|
||||||
ExternalWeak,
|
ExternalWeak,
|
||||||
Common,
|
Common,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1238,9 +1238,7 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> MonoItemPartitio
|
||||||
Linkage::LinkOnceODR => "OnceODR",
|
Linkage::LinkOnceODR => "OnceODR",
|
||||||
Linkage::WeakAny => "WeakAny",
|
Linkage::WeakAny => "WeakAny",
|
||||||
Linkage::WeakODR => "WeakODR",
|
Linkage::WeakODR => "WeakODR",
|
||||||
Linkage::Appending => "Appending",
|
|
||||||
Linkage::Internal => "Internal",
|
Linkage::Internal => "Internal",
|
||||||
Linkage::Private => "Private",
|
|
||||||
Linkage::ExternalWeak => "ExternalWeak",
|
Linkage::ExternalWeak => "ExternalWeak",
|
||||||
Linkage::Common => "Common",
|
Linkage::Common => "Common",
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,9 +18,6 @@ pub static TEST4: bool = true;
|
||||||
#[linkage = "linkonce_odr"]
|
#[linkage = "linkonce_odr"]
|
||||||
pub static TEST5: bool = true;
|
pub static TEST5: bool = true;
|
||||||
|
|
||||||
#[linkage = "private"]
|
|
||||||
pub static TEST6: bool = true;
|
|
||||||
|
|
||||||
#[linkage = "weak"]
|
#[linkage = "weak"]
|
||||||
pub static TEST7: bool = true;
|
pub static TEST7: bool = true;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue