Auto merge of #103196 - Nilstrieb:no-meta-query, r=cjgillot
Get rid of native_library projection queries They don't seem particularly useful as I don't expect native libraries to change frequently. Maybe they do provide significant value of keeping incremental compilation green though, I'm not sure.
This commit is contained in:
commit
3022afe3d1
7 changed files with 18 additions and 25 deletions
|
@ -179,7 +179,8 @@ pub fn get_fn<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) ->
|
||||||
// MinGW: For backward compatibility we rely on the linker to decide whether it
|
// MinGW: For backward compatibility we rely on the linker to decide whether it
|
||||||
// should use dllimport for functions.
|
// should use dllimport for functions.
|
||||||
if cx.use_dll_storage_attrs
|
if cx.use_dll_storage_attrs
|
||||||
&& tcx.is_dllimport_foreign_item(instance_def_id)
|
&& let Some(library) = tcx.native_library(instance_def_id)
|
||||||
|
&& library.kind.is_dllimport()
|
||||||
&& !matches!(tcx.sess.target.env.as_ref(), "gnu" | "uclibc")
|
&& !matches!(tcx.sess.target.env.as_ref(), "gnu" | "uclibc")
|
||||||
{
|
{
|
||||||
llvm::LLVMSetDLLStorageClass(llfn, llvm::DLLStorageClass::DllImport);
|
llvm::LLVMSetDLLStorageClass(llfn, llvm::DLLStorageClass::DllImport);
|
||||||
|
|
|
@ -332,7 +332,10 @@ impl<'ll> CodegenCx<'ll, '_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.use_dll_storage_attrs && self.tcx.is_dllimport_foreign_item(def_id) {
|
if self.use_dll_storage_attrs
|
||||||
|
&& let Some(library) = self.tcx.native_library(def_id)
|
||||||
|
&& library.kind.is_dllimport()
|
||||||
|
{
|
||||||
// For foreign (native) libs we know the exact storage type to use.
|
// For foreign (native) libs we know the exact storage type to use.
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMSetDLLStorageClass(g, llvm::DLLStorageClass::DllImport);
|
llvm::LLVMSetDLLStorageClass(g, llvm::DLLStorageClass::DllImport);
|
||||||
|
|
|
@ -76,7 +76,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, cnum: CrateNum) -> DefIdMap<
|
||||||
// let it through if it's included statically.
|
// let it through if it's included statically.
|
||||||
match tcx.hir().get_by_def_id(def_id) {
|
match tcx.hir().get_by_def_id(def_id) {
|
||||||
Node::ForeignItem(..) => {
|
Node::ForeignItem(..) => {
|
||||||
tcx.is_statically_included_foreign_item(def_id).then_some(def_id)
|
tcx.native_library(def_id).map_or(false, |library| library.kind.is_statically_included()).then_some(def_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only consider nodes that actually have exported symbols.
|
// Only consider nodes that actually have exported symbols.
|
||||||
|
|
|
@ -15,7 +15,6 @@ use rustc_middle::ty::fast_reject::SimplifiedType;
|
||||||
use rustc_middle::ty::query::{ExternProviders, Providers};
|
use rustc_middle::ty::query::{ExternProviders, Providers};
|
||||||
use rustc_middle::ty::{self, TyCtxt, Visibility};
|
use rustc_middle::ty::{self, TyCtxt, Visibility};
|
||||||
use rustc_session::cstore::{CrateSource, CrateStore};
|
use rustc_session::cstore::{CrateSource, CrateStore};
|
||||||
use rustc_session::utils::NativeLibKind;
|
|
||||||
use rustc_session::{Session, StableCrateId};
|
use rustc_session::{Session, StableCrateId};
|
||||||
use rustc_span::hygiene::{ExpnHash, ExpnId};
|
use rustc_span::hygiene::{ExpnHash, ExpnId};
|
||||||
use rustc_span::source_map::{Span, Spanned};
|
use rustc_span::source_map::{Span, Spanned};
|
||||||
|
@ -340,20 +339,10 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
|
||||||
// resolve! Does this work? Unsure! That's what the issue is about
|
// resolve! Does this work? Unsure! That's what the issue is about
|
||||||
*providers = Providers {
|
*providers = Providers {
|
||||||
allocator_kind: |tcx, ()| CStore::from_tcx(tcx).allocator_kind(),
|
allocator_kind: |tcx, ()| CStore::from_tcx(tcx).allocator_kind(),
|
||||||
is_dllimport_foreign_item: |tcx, id| match tcx.native_library_kind(id) {
|
|
||||||
Some(
|
|
||||||
NativeLibKind::Dylib { .. } | NativeLibKind::RawDylib | NativeLibKind::Unspecified,
|
|
||||||
) => true,
|
|
||||||
_ => false,
|
|
||||||
},
|
|
||||||
is_statically_included_foreign_item: |tcx, id| {
|
|
||||||
matches!(tcx.native_library_kind(id), Some(NativeLibKind::Static { .. }))
|
|
||||||
},
|
|
||||||
is_private_dep: |_tcx, cnum| {
|
is_private_dep: |_tcx, cnum| {
|
||||||
assert_eq!(cnum, LOCAL_CRATE);
|
assert_eq!(cnum, LOCAL_CRATE);
|
||||||
false
|
false
|
||||||
},
|
},
|
||||||
native_library_kind: |tcx, id| tcx.native_library(id).map(|l| l.kind),
|
|
||||||
native_library: |tcx, id| {
|
native_library: |tcx, id| {
|
||||||
tcx.native_libraries(id.krate)
|
tcx.native_libraries(id.krate)
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
@ -1587,16 +1587,6 @@ rustc_queries! {
|
||||||
separate_provide_extern
|
separate_provide_extern
|
||||||
}
|
}
|
||||||
|
|
||||||
query is_dllimport_foreign_item(def_id: DefId) -> bool {
|
|
||||||
desc { |tcx| "checking if `{}` is a a dylib", tcx.def_path_str(def_id) }
|
|
||||||
}
|
|
||||||
query is_statically_included_foreign_item(def_id: DefId) -> bool {
|
|
||||||
desc { |tcx| "checking if `{}` is a staticlib", tcx.def_path_str(def_id) }
|
|
||||||
}
|
|
||||||
query native_library_kind(def_id: DefId)
|
|
||||||
-> Option<NativeLibKind> {
|
|
||||||
desc { |tcx| "getting the native library kind of `{}`", tcx.def_path_str(def_id) }
|
|
||||||
}
|
|
||||||
query native_library(def_id: DefId) -> Option<&'tcx NativeLib> {
|
query native_library(def_id: DefId) -> Option<&'tcx NativeLib> {
|
||||||
desc { |tcx| "getting the native library for `{}`", tcx.def_path_str(def_id) }
|
desc { |tcx| "getting the native library for `{}`", tcx.def_path_str(def_id) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,6 @@ use rustc_session::config::{EntryFnType, OptLevel, OutputFilenames, SymbolMangli
|
||||||
use rustc_session::cstore::{CrateDepKind, CrateSource};
|
use rustc_session::cstore::{CrateDepKind, CrateSource};
|
||||||
use rustc_session::cstore::{ExternCrate, ForeignModule, LinkagePreference, NativeLib};
|
use rustc_session::cstore::{ExternCrate, ForeignModule, LinkagePreference, NativeLib};
|
||||||
use rustc_session::lint::LintExpectationId;
|
use rustc_session::lint::LintExpectationId;
|
||||||
use rustc_session::utils::NativeLibKind;
|
|
||||||
use rustc_session::Limits;
|
use rustc_session::Limits;
|
||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
use rustc_span::{Span, DUMMY_SP};
|
use rustc_span::{Span, DUMMY_SP};
|
||||||
|
|
|
@ -53,6 +53,17 @@ impl NativeLibKind {
|
||||||
NativeLibKind::RawDylib | NativeLibKind::Unspecified | NativeLibKind::LinkArg => false,
|
NativeLibKind::RawDylib | NativeLibKind::Unspecified | NativeLibKind::LinkArg => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_statically_included(&self) -> bool {
|
||||||
|
matches!(self, NativeLibKind::Static { .. })
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_dllimport(&self) -> bool {
|
||||||
|
matches!(
|
||||||
|
self,
|
||||||
|
NativeLibKind::Dylib { .. } | NativeLibKind::RawDylib | NativeLibKind::Unspecified
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue