提交 de6060b0 编写于 作者: B bors

Auto merge of #72458 - RalfJung:rollup-g1w1vws, r=RalfJung

Rollup of 6 pull requests

Successful merges:

 - #71607 (clarify interaction of pin drop guarantee and panics)
 - #72125 (remove broken link)
 - #72133 (Add target thumbv7a-uwp-windows-msvc)
 - #72304 (rustc_target: Avoid an inappropriate use of `post_link_objects`)
 - #72309 (Some renaming and minor refactoring for `NativeLibraryKind`)
 - #72438 (Enable ARM TME (Transactional Memory Extensions))

Failed merges:

r? @ghost
......@@ -139,10 +139,12 @@
//! otherwise invalidating the memory used to store the data is restricted, too.
//! Concretely, for pinned data you have to maintain the invariant
//! that *its memory will not get invalidated or repurposed from the moment it gets pinned until
//! when [`drop`] is called*. Memory can be invalidated by deallocation, but also by
//! when [`drop`] is called*. Only once [`drop`] returns or panics, the memory may be reused.
//!
//! Memory can be "invalidated" by deallocation, but also by
//! replacing a [`Some(v)`] by [`None`], or calling [`Vec::set_len`] to "kill" some elements
//! off of a vector. It can be repurposed by using [`ptr::write`] to overwrite it without
//! calling the destructor first.
//! calling the destructor first. None of this is allowed for pinned data without calling [`drop`].
//!
//! This is exactly the kind of guarantee that the intrusive linked list from the previous
//! section needs to function correctly.
......
......@@ -367,8 +367,8 @@ pub fn provide(providers: &mut Providers<'_>) {
pub fn provide_extern(providers: &mut Providers<'_>) {
providers.wasm_import_module_map = |tcx, cnum| {
// Build up a map from DefId to a `NativeLibrary` structure, where
// `NativeLibrary` internally contains information about
// Build up a map from DefId to a `NativeLib` structure, where
// `NativeLib` internally contains information about
// `#[link(wasm_import_module = "...")]` for example.
let native_libs = tcx.native_libraries(cnum);
......
......@@ -170,6 +170,7 @@ pub fn time_trace_profiler_finish(file_name: &str) {
("fp16", Some(sym::aarch64_target_feature)),
("rcpc", Some(sym::aarch64_target_feature)),
("dotprod", Some(sym::aarch64_target_feature)),
("tme", Some(sym::aarch64_target_feature)),
("v8.1a", Some(sym::aarch64_target_feature)),
("v8.2a", Some(sym::aarch64_target_feature)),
("v8.3a", Some(sym::aarch64_target_feature)),
......
use rustc_data_structures::fx::FxHashSet;
use rustc_fs_util::fix_windows_verbatim_for_gcc;
use rustc_hir::def_id::CrateNum;
use rustc_middle::middle::cstore::{EncodedMetadata, LibSource, NativeLibrary, NativeLibraryKind};
use rustc_middle::middle::cstore::{EncodedMetadata, LibSource, NativeLib};
use rustc_middle::middle::dependency_format::Linkage;
use rustc_session::config::{self, CFGuard, CrateType, DebugInfo};
use rustc_session::config::{OutputFilenames, OutputType, PrintRequest, Sanitizer};
use rustc_session::output::{check_file_is_writeable, invalid_output_for_target, out_filename};
use rustc_session::search_paths::PathKind;
use rustc_session::utils::NativeLibKind;
/// For all the linkers we support, and information they might
/// need out of the shared crate context before we get rid of it.
use rustc_session::{filesearch, Session};
......@@ -183,6 +184,7 @@ fn get_linker(sess: &Session, linker: &Path, flavor: LinkerFlavor) -> Command {
"x86_64" => Some("x64".to_string()),
"x86" => Some("x86".to_string()),
"aarch64" => Some("arm64".to_string()),
"arm" => Some("arm".to_string()),
_ => None,
};
if let Some(ref a) = arch {
......@@ -327,11 +329,12 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
// metadata of the rlib we're generating somehow.
for lib in codegen_results.crate_info.used_libraries.iter() {
match lib.kind {
NativeLibraryKind::NativeStatic => {}
NativeLibraryKind::NativeStaticNobundle
| NativeLibraryKind::NativeFramework
| NativeLibraryKind::NativeRawDylib
| NativeLibraryKind::NativeUnknown => continue,
NativeLibKind::StaticBundle => {}
NativeLibKind::StaticNoBundle
| NativeLibKind::Dylib
| NativeLibKind::Framework
| NativeLibKind::RawDylib
| NativeLibKind::Unspecified => continue,
}
if let Some(name) = lib.name {
ab.add_native_library(name);
......@@ -430,7 +433,7 @@ fn link_staticlib<'a, B: ArchiveBuilder<'a>>(
// object files come from where and selectively skip them.
let skip_object_files = native_libs
.iter()
.any(|lib| lib.kind == NativeLibraryKind::NativeStatic && !relevant_lib(sess, lib));
.any(|lib| lib.kind == NativeLibKind::StaticBundle && !relevant_lib(sess, lib));
ab.add_rlib(
path,
&name.as_str(),
......@@ -907,26 +910,28 @@ enum RlibFlavor {
StaticlibBase,
}
fn print_native_static_libs(sess: &Session, all_native_libs: &[NativeLibrary]) {
fn print_native_static_libs(sess: &Session, all_native_libs: &[NativeLib]) {
let lib_args: Vec<_> = all_native_libs
.iter()
.filter(|l| relevant_lib(sess, l))
.filter_map(|lib| {
let name = lib.name?;
match lib.kind {
NativeLibraryKind::NativeStaticNobundle | NativeLibraryKind::NativeUnknown => {
NativeLibKind::StaticNoBundle
| NativeLibKind::Dylib
| NativeLibKind::Unspecified => {
if sess.target.target.options.is_like_msvc {
Some(format!("{}.lib", name))
} else {
Some(format!("-l{}", name))
}
}
NativeLibraryKind::NativeFramework => {
NativeLibKind::Framework => {
// ld-only syntax, since there are no frameworks in MSVC
Some(format!("-framework {}", name))
}
// These are included, no need to print them
NativeLibraryKind::NativeStatic | NativeLibraryKind::NativeRawDylib => None,
NativeLibKind::StaticBundle | NativeLibKind::RawDylib => None,
}
})
.collect();
......@@ -1696,11 +1701,11 @@ fn add_local_native_libraries(
None => continue,
};
match lib.kind {
NativeLibraryKind::NativeUnknown => cmd.link_dylib(name),
NativeLibraryKind::NativeFramework => cmd.link_framework(name),
NativeLibraryKind::NativeStaticNobundle => cmd.link_staticlib(name),
NativeLibraryKind::NativeStatic => cmd.link_whole_staticlib(name, &search_path),
NativeLibraryKind::NativeRawDylib => {
NativeLibKind::Dylib | NativeLibKind::Unspecified => cmd.link_dylib(name),
NativeLibKind::Framework => cmd.link_framework(name),
NativeLibKind::StaticNoBundle => cmd.link_staticlib(name),
NativeLibKind::StaticBundle => cmd.link_whole_staticlib(name, &search_path),
NativeLibKind::RawDylib => {
// FIXME(#58713): Proper handling for raw dylibs.
bug!("raw_dylib feature not yet implemented");
}
......@@ -1890,7 +1895,7 @@ fn add_static_crate<'a, B: ArchiveBuilder<'a>>(
let native_libs = &codegen_results.crate_info.native_libraries[&cnum];
let skip_native = native_libs
.iter()
.any(|lib| lib.kind == NativeLibraryKind::NativeStatic && !relevant_lib(sess, lib));
.any(|lib| lib.kind == NativeLibKind::StaticBundle && !relevant_lib(sess, lib));
if (!are_upstream_rust_objects_already_included(sess)
|| ignored_for_lto(sess, &codegen_results.crate_info, cnum))
......@@ -2032,9 +2037,9 @@ fn add_upstream_native_libraries(
continue;
}
match lib.kind {
NativeLibraryKind::NativeUnknown => cmd.link_dylib(name),
NativeLibraryKind::NativeFramework => cmd.link_framework(name),
NativeLibraryKind::NativeStaticNobundle => {
NativeLibKind::Dylib | NativeLibKind::Unspecified => cmd.link_dylib(name),
NativeLibKind::Framework => cmd.link_framework(name),
NativeLibKind::StaticNoBundle => {
// Link "static-nobundle" native libs only if the crate they originate from
// is being linked statically to the current crate. If it's linked dynamically
// or is an rlib already included via some other dylib crate, the symbols from
......@@ -2046,8 +2051,8 @@ fn add_upstream_native_libraries(
// ignore statically included native libraries here as we've
// already included them when we included the rust library
// previously
NativeLibraryKind::NativeStatic => {}
NativeLibraryKind::NativeRawDylib => {
NativeLibKind::StaticBundle => {}
NativeLibKind::RawDylib => {
// FIXME(#58713): Proper handling for raw dylibs.
bug!("raw_dylib feature not yet implemented");
}
......@@ -2056,7 +2061,7 @@ fn add_upstream_native_libraries(
}
}
fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool {
fn relevant_lib(sess: &Session, lib: &NativeLib) -> bool {
match lib.cfg {
Some(ref cfg) => rustc_attr::cfg_matches(cfg, &sess.parse_sess, None),
None => true,
......
......@@ -44,6 +44,7 @@
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
use rustc_session::cgu_reuse_tracker::CguReuse;
use rustc_session::config::{self, EntryFnType};
use rustc_session::utils::NativeLibKind;
use rustc_session::Session;
use rustc_span::Span;
use rustc_symbol_mangling::test as symbol_names_test;
......@@ -895,7 +896,7 @@ pub fn provide_both(providers: &mut Providers<'_>) {
.native_libraries(krate)
.iter()
.filter(|lib| {
if lib.kind != cstore::NativeLibraryKind::NativeUnknown {
if !matches!(lib.kind, NativeLibKind::Dylib | NativeLibKind::Unspecified) {
return false;
}
let cfg = match lib.cfg {
......
......@@ -24,7 +24,7 @@
use rustc_hir::def_id::CrateNum;
use rustc_hir::LangItem;
use rustc_middle::dep_graph::WorkProduct;
use rustc_middle::middle::cstore::{CrateSource, LibSource, NativeLibrary};
use rustc_middle::middle::cstore::{CrateSource, LibSource, NativeLib};
use rustc_middle::middle::dependency_format::Dependencies;
use rustc_middle::ty::query::Providers;
use rustc_session::config::{OutputFilenames, OutputType, RUST_CGU_EXT};
......@@ -112,9 +112,9 @@ pub struct CrateInfo {
pub compiler_builtins: Option<CrateNum>,
pub profiler_runtime: Option<CrateNum>,
pub is_no_builtins: FxHashSet<CrateNum>,
pub native_libraries: FxHashMap<CrateNum, Lrc<Vec<NativeLibrary>>>,
pub native_libraries: FxHashMap<CrateNum, Lrc<Vec<NativeLib>>>,
pub crate_name: FxHashMap<CrateNum, String>,
pub used_libraries: Lrc<Vec<NativeLibrary>>,
pub used_libraries: Lrc<Vec<NativeLib>>,
pub link_args: Lrc<Vec<String>>,
pub used_crate_source: FxHashMap<CrateNum, Lrc<CrateSource>>,
pub used_crates_static: Vec<(CrateNum, LibSource)>,
......
......@@ -784,7 +784,7 @@ pub fn vars_since_snapshot(
)
}
/// See [`RegionInference::region_constraints_added_in_snapshot`].
/// See `InferCtxt::region_constraints_added_in_snapshot`.
pub fn region_constraints_added_in_snapshot(&self, mark: &Snapshot<'tcx>) -> Option<bool> {
self.undo_log
.region_constraints_in_snapshot(mark)
......
......@@ -2,7 +2,6 @@
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{emitter::HumanReadableErrorType, registry, ColorConfig};
use rustc_middle::middle::cstore;
use rustc_session::config::Strip;
use rustc_session::config::{build_configuration, build_session_options, to_crate_config};
use rustc_session::config::{rustc_optgroups, ErrorOutputType, ExternLocation, Options, Passes};
......@@ -11,6 +10,7 @@
use rustc_session::getopts;
use rustc_session::lint::Level;
use rustc_session::search_paths::SearchPath;
use rustc_session::utils::NativeLibKind;
use rustc_session::{build_session, Session};
use rustc_span::edition::{Edition, DEFAULT_EDITION};
use rustc_span::symbol::sym;
......@@ -300,30 +300,30 @@ fn test_native_libs_tracking_hash_different_values() {
// Reference
v1.libs = vec![
(String::from("a"), None, Some(cstore::NativeStatic)),
(String::from("b"), None, Some(cstore::NativeFramework)),
(String::from("c"), None, Some(cstore::NativeUnknown)),
(String::from("a"), None, NativeLibKind::StaticBundle),
(String::from("b"), None, NativeLibKind::Framework),
(String::from("c"), None, NativeLibKind::Unspecified),
];
// Change label
v2.libs = vec![
(String::from("a"), None, Some(cstore::NativeStatic)),
(String::from("X"), None, Some(cstore::NativeFramework)),
(String::from("c"), None, Some(cstore::NativeUnknown)),
(String::from("a"), None, NativeLibKind::StaticBundle),
(String::from("X"), None, NativeLibKind::Framework),
(String::from("c"), None, NativeLibKind::Unspecified),
];
// Change kind
v3.libs = vec![
(String::from("a"), None, Some(cstore::NativeStatic)),
(String::from("b"), None, Some(cstore::NativeStatic)),
(String::from("c"), None, Some(cstore::NativeUnknown)),
(String::from("a"), None, NativeLibKind::StaticBundle),
(String::from("b"), None, NativeLibKind::StaticBundle),
(String::from("c"), None, NativeLibKind::Unspecified),
];
// Change new-name
v4.libs = vec![
(String::from("a"), None, Some(cstore::NativeStatic)),
(String::from("b"), Some(String::from("X")), Some(cstore::NativeFramework)),
(String::from("c"), None, Some(cstore::NativeUnknown)),
(String::from("a"), None, NativeLibKind::StaticBundle),
(String::from("b"), Some(String::from("X")), NativeLibKind::Framework),
(String::from("c"), None, NativeLibKind::Unspecified),
];
assert!(v1.dep_tracking_hash() != v2.dep_tracking_hash());
......@@ -345,21 +345,21 @@ fn test_native_libs_tracking_hash_different_order() {
// Reference
v1.libs = vec![
(String::from("a"), None, Some(cstore::NativeStatic)),
(String::from("b"), None, Some(cstore::NativeFramework)),
(String::from("c"), None, Some(cstore::NativeUnknown)),
(String::from("a"), None, NativeLibKind::StaticBundle),
(String::from("b"), None, NativeLibKind::Framework),
(String::from("c"), None, NativeLibKind::Unspecified),
];
v2.libs = vec![
(String::from("b"), None, Some(cstore::NativeFramework)),
(String::from("a"), None, Some(cstore::NativeStatic)),
(String::from("c"), None, Some(cstore::NativeUnknown)),
(String::from("b"), None, NativeLibKind::Framework),
(String::from("a"), None, NativeLibKind::StaticBundle),
(String::from("c"), None, NativeLibKind::Unspecified),
];
v3.libs = vec![
(String::from("c"), None, Some(cstore::NativeUnknown)),
(String::from("a"), None, Some(cstore::NativeStatic)),
(String::from("b"), None, Some(cstore::NativeFramework)),
(String::from("c"), None, NativeLibKind::Unspecified),
(String::from("a"), None, NativeLibKind::StaticBundle),
(String::from("b"), None, NativeLibKind::Framework),
];
assert!(v1.dep_tracking_hash() == v2.dep_tracking_hash());
......
......@@ -3,22 +3,23 @@
use rustc_errors::struct_span_err;
use rustc_hir as hir;
use rustc_hir::itemlikevisit::ItemLikeVisitor;
use rustc_middle::middle::cstore::{self, NativeLibrary};
use rustc_middle::middle::cstore::NativeLib;
use rustc_middle::ty::TyCtxt;
use rustc_session::parse::feature_err;
use rustc_session::utils::NativeLibKind;
use rustc_session::Session;
use rustc_span::source_map::Span;
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_target::spec::abi::Abi;
crate fn collect(tcx: TyCtxt<'_>) -> Vec<NativeLibrary> {
crate fn collect(tcx: TyCtxt<'_>) -> Vec<NativeLib> {
let mut collector = Collector { tcx, libs: Vec::new() };
tcx.hir().krate().visit_all_item_likes(&mut collector);
collector.process_command_line();
collector.libs
}
crate fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool {
crate fn relevant_lib(sess: &Session, lib: &NativeLib) -> bool {
match lib.cfg {
Some(ref cfg) => attr::cfg_matches(cfg, &sess.parse_sess, None),
None => true,
......@@ -27,7 +28,7 @@
struct Collector<'tcx> {
tcx: TyCtxt<'tcx>,
libs: Vec<NativeLibrary>,
libs: Vec<NativeLib>,
}
impl ItemLikeVisitor<'tcx> for Collector<'tcx> {
......@@ -47,9 +48,9 @@ fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) {
Some(item) => item,
None => continue,
};
let mut lib = NativeLibrary {
let mut lib = NativeLib {
name: None,
kind: cstore::NativeUnknown,
kind: NativeLibKind::Unspecified,
cfg: None,
foreign_module: Some(self.tcx.hir().local_def_id(it.hir_id).to_def_id()),
wasm_import_module: None,
......@@ -64,11 +65,11 @@ fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) {
None => continue, // skip like historical compilers
};
lib.kind = match &*kind.as_str() {
"static" => cstore::NativeStatic,
"static-nobundle" => cstore::NativeStaticNobundle,
"dylib" => cstore::NativeUnknown,
"framework" => cstore::NativeFramework,
"raw-dylib" => cstore::NativeRawDylib,
"static" => NativeLibKind::StaticBundle,
"static-nobundle" => NativeLibKind::StaticNoBundle,
"dylib" => NativeLibKind::Dylib,
"framework" => NativeLibKind::Framework,
"raw-dylib" => NativeLibKind::RawDylib,
k => {
struct_span_err!(
self.tcx.sess,
......@@ -80,7 +81,7 @@ fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) {
.span_label(item.span(), "unknown kind")
.span_label(m.span, "")
.emit();
cstore::NativeUnknown
NativeLibKind::Unspecified
}
};
} else if item.check_name(sym::name) {
......@@ -134,7 +135,7 @@ fn visit_impl_item(&mut self, _it: &'tcx hir::ImplItem<'tcx>) {}
}
impl Collector<'tcx> {
fn register_native_lib(&mut self, span: Option<Span>, lib: NativeLibrary) {
fn register_native_lib(&mut self, span: Option<Span>, lib: NativeLib) {
if lib.name.as_ref().map(|&s| s == kw::Invalid).unwrap_or(false) {
match span {
Some(span) => {
......@@ -154,7 +155,7 @@ fn register_native_lib(&mut self, span: Option<Span>, lib: NativeLibrary) {
return;
}
let is_osx = self.tcx.sess.target.target.options.is_like_osx;
if lib.kind == cstore::NativeFramework && !is_osx {
if lib.kind == NativeLibKind::Framework && !is_osx {
let msg = "native frameworks are only available on macOS targets";
match span {
Some(span) => struct_span_err!(self.tcx.sess, span, E0455, "{}", msg).emit(),
......@@ -170,7 +171,7 @@ fn register_native_lib(&mut self, span: Option<Span>, lib: NativeLibrary) {
)
.emit();
}
if lib.kind == cstore::NativeStaticNobundle && !self.tcx.features().static_nobundle {
if lib.kind == NativeLibKind::StaticNoBundle && !self.tcx.features().static_nobundle {
feature_err(
&self.tcx.sess.parse_sess,
sym::static_nobundle,
......@@ -179,7 +180,7 @@ fn register_native_lib(&mut self, span: Option<Span>, lib: NativeLibrary) {
)
.emit();
}
if lib.kind == cstore::NativeRawDylib && !self.tcx.features().raw_dylib {
if lib.kind == NativeLibKind::RawDylib && !self.tcx.features().raw_dylib {
feature_err(
&self.tcx.sess.parse_sess,
sym::raw_dylib,
......@@ -240,8 +241,8 @@ fn process_command_line(&mut self) {
.drain_filter(|lib| {
if let Some(lib_name) = lib.name {
if lib_name.as_str() == *name {
if let Some(k) = kind {
lib.kind = k;
if kind != NativeLibKind::Unspecified {
lib.kind = kind;
}
if let &Some(ref new_name) = new_name {
lib.name = Some(Symbol::intern(new_name));
......@@ -255,9 +256,9 @@ fn process_command_line(&mut self) {
if existing.is_empty() {
// Add if not found
let new_name = new_name.as_ref().map(|s| &**s); // &Option<String> -> Option<&str>
let lib = NativeLibrary {
let lib = NativeLib {
name: Some(Symbol::intern(new_name.unwrap_or(name))),
kind: if let Some(k) = kind { k } else { cstore::NativeUnknown },
kind,
cfg: None,
foreign_module: None,
wasm_import_module: None,
......
......@@ -23,7 +23,7 @@
use rustc_middle::dep_graph::{self, DepNode, DepNodeExt, DepNodeIndex};
use rustc_middle::hir::exports::Export;
use rustc_middle::middle::cstore::{CrateSource, ExternCrate};
use rustc_middle::middle::cstore::{ForeignModule, LinkagePreference, NativeLibrary};
use rustc_middle::middle::cstore::{ForeignModule, LinkagePreference, NativeLib};
use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel};
use rustc_middle::mir::interpret::{AllocDecodingSession, AllocDecodingState};
use rustc_middle::mir::{self, interpret, Body, Promoted};
......@@ -1278,7 +1278,7 @@ fn get_trait_of_item(&self, id: DefIndex) -> Option<DefId> {
})
}
fn get_native_libraries(&self, sess: &Session) -> Vec<NativeLibrary> {
fn get_native_libraries(&self, sess: &Session) -> Vec<NativeLib> {
if self.root.is_proc_macro_crate() {
// Proc macro crates do not have any *target* native libraries.
vec![]
......
......@@ -13,12 +13,13 @@
use rustc_hir::definitions::DefPathTable;
use rustc_hir::definitions::{DefKey, DefPath, DefPathHash};
use rustc_middle::hir::exports::Export;
use rustc_middle::middle::cstore::{CrateSource, CrateStore, EncodedMetadata, NativeLibraryKind};
use rustc_middle::middle::cstore::{CrateSource, CrateStore, EncodedMetadata};
use rustc_middle::middle::exported_symbols::ExportedSymbol;
use rustc_middle::middle::stability::DeprecationEntry;
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::query::QueryConfig;
use rustc_middle::ty::{self, TyCtxt};
use rustc_session::utils::NativeLibKind;
use rustc_session::{CrateDisambiguator, Session};
use rustc_span::source_map::{self, Span, Spanned};
use rustc_span::symbol::{Ident, Symbol};
......@@ -246,11 +247,13 @@ pub fn provide(providers: &mut Providers<'_>) {
// resolve! Does this work? Unsure! That's what the issue is about
*providers = Providers {
is_dllimport_foreign_item: |tcx, id| match tcx.native_library_kind(id) {
Some(NativeLibraryKind::NativeUnknown | NativeLibraryKind::NativeRawDylib) => true,
Some(NativeLibKind::Dylib | NativeLibKind::RawDylib | NativeLibKind::Unspecified) => {
true
}
_ => false,
},
is_statically_included_foreign_item: |tcx, id| match tcx.native_library_kind(id) {
Some(NativeLibraryKind::NativeStatic | NativeLibraryKind::NativeStaticNobundle) => true,
Some(NativeLibKind::StaticBundle | NativeLibKind::StaticNoBundle) => true,
_ => false,
},
native_library_kind: |tcx, id| {
......
......@@ -18,9 +18,7 @@
use rustc_hir::{AnonConst, GenericParamKind};
use rustc_index::vec::Idx;
use rustc_middle::hir::map::Map;
use rustc_middle::middle::cstore::{
EncodedMetadata, ForeignModule, LinkagePreference, NativeLibrary,
};
use rustc_middle::middle::cstore::{EncodedMetadata, ForeignModule, LinkagePreference, NativeLib};
use rustc_middle::middle::dependency_format::Linkage;
use rustc_middle::middle::exported_symbols::{
metadata_symbol_name, ExportedSymbol, SymbolExportLevel,
......@@ -1355,7 +1353,7 @@ fn encode_info_for_anon_const(&mut self, def_id: LocalDefId) {
self.encode_promoted_mir(def_id);
}
fn encode_native_libraries(&mut self) -> Lazy<[NativeLibrary]> {
fn encode_native_libraries(&mut self) -> Lazy<[NativeLib]> {
let used_libraries = self.tcx.native_libraries(LOCAL_CRATE);
self.lazy(used_libraries.iter().cloned())
}
......
......@@ -11,7 +11,7 @@
use rustc_hir::lang_items;
use rustc_index::vec::IndexVec;
use rustc_middle::hir::exports::Export;
use rustc_middle::middle::cstore::{DepKind, ForeignModule, LinkagePreference, NativeLibrary};
use rustc_middle::middle::cstore::{DepKind, ForeignModule, LinkagePreference, NativeLib};
use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel};
use rustc_middle::mir;
use rustc_middle::ty::{self, ReprOptions, Ty};
......@@ -190,7 +190,7 @@ enum LazyState {
lang_items: Lazy<[(DefIndex, usize)]>,
lang_items_missing: Lazy<[lang_items::LangItem]>,
diagnostic_items: Lazy<[(Symbol, DefIndex)]>,
native_libraries: Lazy<[NativeLibrary]>,
native_libraries: Lazy<[NativeLib]>,
foreign_modules: Lazy<[ForeignModule]>,
source_map: Lazy<[rustc_span::SourceFile]>,
def_path_table: Lazy<rustc_hir::definitions::DefPathTable>,
......
......@@ -2,8 +2,6 @@
//! are *mostly* used as a part of that interface, but these should
//! probably get a better home if someone can find one.
pub use self::NativeLibraryKind::*;
use crate::ty::TyCtxt;
use rustc_ast::ast;
......@@ -14,7 +12,7 @@
use rustc_hir::definitions::{DefKey, DefPath, DefPathHash, DefPathTable};
use rustc_macros::HashStable;
use rustc_session::search_paths::PathKind;
pub use rustc_session::utils::NativeLibraryKind;
use rustc_session::utils::NativeLibKind;
use rustc_session::CrateDisambiguator;
use rustc_span::symbol::Symbol;
use rustc_span::Span;
......@@ -89,8 +87,8 @@ pub enum LinkagePreference {
}
#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
pub struct NativeLibrary {
pub kind: NativeLibraryKind,
pub struct NativeLib {
pub kind: NativeLibKind,
pub name: Option<Symbol>,
pub cfg: Option<ast::MetaItem>,
pub foreign_module: Option<DefId>,
......
......@@ -131,7 +131,7 @@ fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String {
cache_on_disk_if { key.is_local() }
}
query native_libraries(_: CrateNum) -> Lrc<Vec<NativeLibrary>> {
query native_libraries(_: CrateNum) -> Lrc<Vec<NativeLib>> {
desc { "looking up the native libraries of a linked crate" }
}
......@@ -937,7 +937,7 @@ fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String {
query is_dllimport_foreign_item(_: DefId) -> bool {}
query is_statically_included_foreign_item(_: DefId) -> bool {}
query native_library_kind(_: DefId)
-> Option<NativeLibraryKind> {}
-> Option<NativeLibKind> {}
}
Linking {
......
......@@ -4,8 +4,8 @@
use crate::infer::canonical::{self, Canonical};
use crate::lint::LintLevelMap;
use crate::middle::codegen_fn_attrs::CodegenFnAttrs;
use crate::middle::cstore::{CrateSource, DepKind, NativeLibraryKind};
use crate::middle::cstore::{ExternCrate, ForeignModule, LinkagePreference, NativeLibrary};
use crate::middle::cstore::{CrateSource, DepKind};
use crate::middle::cstore::{ExternCrate, ForeignModule, LinkagePreference, NativeLib};
use crate::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel};
use crate::middle::lib_features::LibFeatures;
use crate::middle::privacy::AccessLevels;
......@@ -46,6 +46,7 @@
use rustc_hir::{Crate, HirIdSet, ItemLocalId, TraitCandidate};
use rustc_index::vec::IndexVec;
use rustc_session::config::{EntryFnType, OptLevel, OutputFilenames, SymbolManglingVersion};
use rustc_session::utils::NativeLibKind;
use rustc_session::CrateDisambiguator;
use rustc_target::spec::PanicStrategy;
......
......@@ -5,7 +5,7 @@
use crate::lint;
use crate::search_paths::SearchPath;
use crate::utils::NativeLibraryKind;
use crate::utils::NativeLibKind;
use crate::{early_error, early_warn, Session};
use rustc_data_structures::fx::FxHashSet;
......@@ -1452,7 +1452,7 @@ fn select_debuginfo(
fn parse_libs(
matches: &getopts::Matches,
error_format: ErrorOutputType,
) -> Vec<(String, Option<String>, Option<NativeLibraryKind>)> {
) -> Vec<(String, Option<String>, NativeLibKind)> {
matches
.opt_strs("l")
.into_iter()
......@@ -1462,13 +1462,11 @@ fn parse_libs(
let mut parts = s.splitn(2, '=');
let kind = parts.next().unwrap();
let (name, kind) = match (parts.next(), kind) {
(None, name) => (name, None),
(Some(name), "dylib") => (name, Some(NativeLibraryKind::NativeUnknown)),
(Some(name), "framework") => (name, Some(NativeLibraryKind::NativeFramework)),
(Some(name), "static") => (name, Some(NativeLibraryKind::NativeStatic)),
(Some(name), "static-nobundle") => {
(name, Some(NativeLibraryKind::NativeStaticNobundle))
}
(None, name) => (name, NativeLibKind::Unspecified),
(Some(name), "dylib") => (name, NativeLibKind::Dylib),
(Some(name), "framework") => (name, NativeLibKind::Framework),
(Some(name), "static") => (name, NativeLibKind::StaticBundle),
(Some(name), "static-nobundle") => (name, NativeLibKind::StaticNoBundle),
(_, s) => {
early_error(
error_format,
......@@ -1480,9 +1478,7 @@ fn parse_libs(
);
}
};
if kind == Some(NativeLibraryKind::NativeStaticNobundle)
&& !nightly_options::is_nightly_build()
{
if kind == NativeLibKind::StaticNoBundle && !nightly_options::is_nightly_build() {
early_error(
error_format,
"the library kind 'static-nobundle' is only \
......@@ -2003,7 +1999,7 @@ pub fn needs_analysis(&self) -> bool {
SymbolManglingVersion,
};
use crate::lint;
use crate::utils::NativeLibraryKind;
use crate::utils::NativeLibKind;
use rustc_feature::UnstableFeatures;
use rustc_span::edition::Edition;
use rustc_target::spec::{CodeModel, MergeFunctions, PanicStrategy, RelocModel};
......@@ -2062,7 +2058,6 @@ fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType) {
impl_dep_tracking_hash_via_hash!(Option<RelroLevel>);
impl_dep_tracking_hash_via_hash!(Option<lint::Level>);
impl_dep_tracking_hash_via_hash!(Option<PathBuf>);
impl_dep_tracking_hash_via_hash!(Option<NativeLibraryKind>);
impl_dep_tracking_hash_via_hash!(CrateType);
impl_dep_tracking_hash_via_hash!(MergeFunctions);
impl_dep_tracking_hash_via_hash!(PanicStrategy);
......@@ -2073,7 +2068,7 @@ fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType) {
impl_dep_tracking_hash_via_hash!(DebugInfo);
impl_dep_tracking_hash_via_hash!(UnstableFeatures);
impl_dep_tracking_hash_via_hash!(OutputTypes);
impl_dep_tracking_hash_via_hash!(NativeLibraryKind);
impl_dep_tracking_hash_via_hash!(NativeLibKind);
impl_dep_tracking_hash_via_hash!(Sanitizer);
impl_dep_tracking_hash_via_hash!(Option<Sanitizer>);
impl_dep_tracking_hash_via_hash!(CFGuard);
......@@ -2088,11 +2083,7 @@ fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType) {
impl_dep_tracking_hash_for_sortable_vec_of!(PathBuf);
impl_dep_tracking_hash_for_sortable_vec_of!(CrateType);
impl_dep_tracking_hash_for_sortable_vec_of!((String, lint::Level));
impl_dep_tracking_hash_for_sortable_vec_of!((
String,
Option<String>,
Option<NativeLibraryKind>
));
impl_dep_tracking_hash_for_sortable_vec_of!((String, Option<String>, NativeLibKind));
impl_dep_tracking_hash_for_sortable_vec_of!((String, u64));
impl_dep_tracking_hash_for_sortable_vec_of!(Sanitizer);
......
......@@ -3,7 +3,7 @@
use crate::early_error;
use crate::lint;
use crate::search_paths::SearchPath;
use crate::utils::NativeLibraryKind;
use crate::utils::NativeLibKind;
use rustc_target::spec::{CodeModel, LinkerFlavor, MergeFunctions, PanicStrategy};
use rustc_target::spec::{RelocModel, RelroLevel, TargetTriple, TlsModel};
......@@ -93,7 +93,7 @@ pub struct Options {
describe_lints: bool [UNTRACKED],
output_types: OutputTypes [TRACKED],
search_paths: Vec<SearchPath> [UNTRACKED],
libs: Vec<(String, Option<String>, Option<NativeLibraryKind>)> [TRACKED],
libs: Vec<(String, Option<String>, NativeLibKind)> [TRACKED],
maybe_sysroot: Option<PathBuf> [UNTRACKED],
target_triple: TargetTriple [TRACKED],
......
......@@ -11,17 +11,22 @@ pub fn time<R>(&self, what: &'static str, f: impl FnOnce() -> R) -> R {
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
pub enum NativeLibraryKind {
/// native static library (.a archive)
NativeStatic,
/// native static library, which doesn't get bundled into .rlibs
NativeStaticNobundle,
/// macOS-specific
NativeFramework,
/// Windows dynamic library without import library.
NativeRawDylib,
/// default way to specify a dynamic library
NativeUnknown,
pub enum NativeLibKind {
/// Static library (e.g. `libfoo.a` on Linux or `foo.lib` on Windows/MSVC) included
/// when linking a final binary, but not when archiving an rlib.
StaticNoBundle,
/// Static library (e.g. `libfoo.a` on Linux or `foo.lib` on Windows/MSVC) included
/// when linking a final binary, but also included when archiving an rlib.
StaticBundle,
/// Dynamic library (e.g. `libfoo.so` on Linux)
/// or an import library corresponding to a dynamic library (e.g. `foo.lib` on Windows/MSVC).
Dylib,
/// Dynamic library (e.g. `foo.dll` on Windows) without a corresponding import library.
RawDylib,
/// A macOS-specific kind of dynamic libraries.
Framework,
/// The library kind wasn't specified, `Dylib` is currently used as a default.
Unspecified,
}
rustc_data_structures::impl_stable_hash_via_hash!(NativeLibraryKind);
rustc_data_structures::impl_stable_hash_via_hash!(NativeLibKind);
......@@ -618,6 +618,7 @@ fn $module() {
("i686-uwp-windows-msvc", i686_uwp_windows_msvc),
("i586-pc-windows-msvc", i586_pc_windows_msvc),
("thumbv7a-pc-windows-msvc", thumbv7a_pc_windows_msvc),
("thumbv7a-uwp-windows-msvc", thumbv7a_uwp_windows_msvc),
("asmjs-unknown-emscripten", asmjs_unknown_emscripten),
("wasm32-unknown-emscripten", wasm32_unknown_emscripten),
......
use crate::spec::{LinkerFlavor, PanicStrategy, Target, TargetOptions, TargetResult};
pub fn target() -> TargetResult {
let mut base = super::windows_uwp_msvc_base::opts();
base.max_atomic_width = Some(64);
base.has_elf_tls = true;
// FIXME(jordanrh): use PanicStrategy::Unwind when SEH is
// implemented for windows/arm in LLVM
base.panic_strategy = PanicStrategy::Abort;
Ok(Target {
llvm_target: "thumbv7a-pc-windows-msvc".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
target_c_int_width: "32".to_string(),
data_layout: "e-m:w-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
arch: "arm".to_string(),
target_os: "windows".to_string(),
target_env: "msvc".to_string(),
target_vendor: "uwp".to_string(),
linker_flavor: LinkerFlavor::Msvc,
options: TargetOptions {
features: "+vfp3,+neon".to_string(),
cpu: "generic".to_string(),
abi_blacklist: super::arm_base::abi_blacklist(),
..base
},
})
}
use std::iter;
use super::{crt_objects, LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions};
use super::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions};
pub fn target() -> Result<Target, String> {
const PRE_LINK_ARGS: &[&str] = &[
......@@ -68,8 +68,6 @@ pub fn target() -> Result<Target, String> {
PRE_LINK_ARGS.iter().cloned().map(String::from).collect(),
))
.collect(),
// FIXME: libunwind is certainly not a CRT object, use some other option instead.
post_link_objects: crt_objects::all("libunwind.a"),
override_export_symbols: Some(EXPORT_SYMBOLS.iter().cloned().map(String::from).collect()),
relax_elf_relocations: true,
..Default::default()
......
......@@ -32,6 +32,7 @@ fn aarch64_linux() {
println!("rdm: {}", is_aarch64_feature_detected!("rdm"));
println!("rcpc: {}", is_aarch64_feature_detected!("rcpc"));
println!("dotprod: {}", is_aarch64_feature_detected!("dotprod"));
println!("tme: {}", is_aarch64_feature_detected!("tme"));
}
#[test]
......
......@@ -27,3 +27,7 @@
#[link(name = "gcc_eh", kind = "static-nobundle", cfg(target_feature = "crt-static"))]
#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
extern "C" {}
#[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
#[link(name = "unwind", kind = "static-nobundle")]
extern "C" {}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册