Skip to content

Commit de6060b

Browse files
committed
Auto merge of rust-lang#72458 - RalfJung:rollup-g1w1vws, r=RalfJung
Rollup of 6 pull requests Successful merges: - rust-lang#71607 (clarify interaction of pin drop guarantee and panics) - rust-lang#72125 (remove broken link) - rust-lang#72133 (Add target thumbv7a-uwp-windows-msvc) - rust-lang#72304 (rustc_target: Avoid an inappropriate use of `post_link_objects`) - rust-lang#72309 (Some renaming and minor refactoring for `NativeLibraryKind`) - rust-lang#72438 (Enable ARM TME (Transactional Memory Extensions)) Failed merges: r? @ghost
2 parents c60b675 + 64beaff commit de6060b

File tree

24 files changed

+171
-131
lines changed

24 files changed

+171
-131
lines changed

src/libcore/pin.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,12 @@
139139
//! otherwise invalidating the memory used to store the data is restricted, too.
140140
//! Concretely, for pinned data you have to maintain the invariant
141141
//! that *its memory will not get invalidated or repurposed from the moment it gets pinned until
142-
//! when [`drop`] is called*. Memory can be invalidated by deallocation, but also by
142+
//! when [`drop`] is called*. Only once [`drop`] returns or panics, the memory may be reused.
143+
//!
144+
//! Memory can be "invalidated" by deallocation, but also by
143145
//! replacing a [`Some(v)`] by [`None`], or calling [`Vec::set_len`] to "kill" some elements
144146
//! off of a vector. It can be repurposed by using [`ptr::write`] to overwrite it without
145-
//! calling the destructor first.
147+
//! calling the destructor first. None of this is allowed for pinned data without calling [`drop`].
146148
//!
147149
//! This is exactly the kind of guarantee that the intrusive linked list from the previous
148150
//! section needs to function correctly.

src/librustc_codegen_llvm/attributes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,8 @@ pub fn provide(providers: &mut Providers<'_>) {
367367

368368
pub fn provide_extern(providers: &mut Providers<'_>) {
369369
providers.wasm_import_module_map = |tcx, cnum| {
370-
// Build up a map from DefId to a `NativeLibrary` structure, where
371-
// `NativeLibrary` internally contains information about
370+
// Build up a map from DefId to a `NativeLib` structure, where
371+
// `NativeLib` internally contains information about
372372
// `#[link(wasm_import_module = "...")]` for example.
373373
let native_libs = tcx.native_libraries(cnum);
374374

src/librustc_codegen_llvm/llvm_util.rs

+1
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ const AARCH64_WHITELIST: &[(&str, Option<Symbol>)] = &[
170170
("fp16", Some(sym::aarch64_target_feature)),
171171
("rcpc", Some(sym::aarch64_target_feature)),
172172
("dotprod", Some(sym::aarch64_target_feature)),
173+
("tme", Some(sym::aarch64_target_feature)),
173174
("v8.1a", Some(sym::aarch64_target_feature)),
174175
("v8.2a", Some(sym::aarch64_target_feature)),
175176
("v8.3a", Some(sym::aarch64_target_feature)),

src/librustc_codegen_ssa/back/link.rs

+28-23
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
use rustc_data_structures::fx::FxHashSet;
22
use rustc_fs_util::fix_windows_verbatim_for_gcc;
33
use rustc_hir::def_id::CrateNum;
4-
use rustc_middle::middle::cstore::{EncodedMetadata, LibSource, NativeLibrary, NativeLibraryKind};
4+
use rustc_middle::middle::cstore::{EncodedMetadata, LibSource, NativeLib};
55
use rustc_middle::middle::dependency_format::Linkage;
66
use rustc_session::config::{self, CFGuard, CrateType, DebugInfo};
77
use rustc_session::config::{OutputFilenames, OutputType, PrintRequest, Sanitizer};
88
use rustc_session::output::{check_file_is_writeable, invalid_output_for_target, out_filename};
99
use rustc_session::search_paths::PathKind;
10+
use rustc_session::utils::NativeLibKind;
1011
/// For all the linkers we support, and information they might
1112
/// need out of the shared crate context before we get rid of it.
1213
use rustc_session::{filesearch, Session};
@@ -183,6 +184,7 @@ fn get_linker(sess: &Session, linker: &Path, flavor: LinkerFlavor) -> Command {
183184
"x86_64" => Some("x64".to_string()),
184185
"x86" => Some("x86".to_string()),
185186
"aarch64" => Some("arm64".to_string()),
187+
"arm" => Some("arm".to_string()),
186188
_ => None,
187189
};
188190
if let Some(ref a) = arch {
@@ -327,11 +329,12 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
327329
// metadata of the rlib we're generating somehow.
328330
for lib in codegen_results.crate_info.used_libraries.iter() {
329331
match lib.kind {
330-
NativeLibraryKind::NativeStatic => {}
331-
NativeLibraryKind::NativeStaticNobundle
332-
| NativeLibraryKind::NativeFramework
333-
| NativeLibraryKind::NativeRawDylib
334-
| NativeLibraryKind::NativeUnknown => continue,
332+
NativeLibKind::StaticBundle => {}
333+
NativeLibKind::StaticNoBundle
334+
| NativeLibKind::Dylib
335+
| NativeLibKind::Framework
336+
| NativeLibKind::RawDylib
337+
| NativeLibKind::Unspecified => continue,
335338
}
336339
if let Some(name) = lib.name {
337340
ab.add_native_library(name);
@@ -430,7 +433,7 @@ fn link_staticlib<'a, B: ArchiveBuilder<'a>>(
430433
// object files come from where and selectively skip them.
431434
let skip_object_files = native_libs
432435
.iter()
433-
.any(|lib| lib.kind == NativeLibraryKind::NativeStatic && !relevant_lib(sess, lib));
436+
.any(|lib| lib.kind == NativeLibKind::StaticBundle && !relevant_lib(sess, lib));
434437
ab.add_rlib(
435438
path,
436439
&name.as_str(),
@@ -907,26 +910,28 @@ enum RlibFlavor {
907910
StaticlibBase,
908911
}
909912

910-
fn print_native_static_libs(sess: &Session, all_native_libs: &[NativeLibrary]) {
913+
fn print_native_static_libs(sess: &Session, all_native_libs: &[NativeLib]) {
911914
let lib_args: Vec<_> = all_native_libs
912915
.iter()
913916
.filter(|l| relevant_lib(sess, l))
914917
.filter_map(|lib| {
915918
let name = lib.name?;
916919
match lib.kind {
917-
NativeLibraryKind::NativeStaticNobundle | NativeLibraryKind::NativeUnknown => {
920+
NativeLibKind::StaticNoBundle
921+
| NativeLibKind::Dylib
922+
| NativeLibKind::Unspecified => {
918923
if sess.target.target.options.is_like_msvc {
919924
Some(format!("{}.lib", name))
920925
} else {
921926
Some(format!("-l{}", name))
922927
}
923928
}
924-
NativeLibraryKind::NativeFramework => {
929+
NativeLibKind::Framework => {
925930
// ld-only syntax, since there are no frameworks in MSVC
926931
Some(format!("-framework {}", name))
927932
}
928933
// These are included, no need to print them
929-
NativeLibraryKind::NativeStatic | NativeLibraryKind::NativeRawDylib => None,
934+
NativeLibKind::StaticBundle | NativeLibKind::RawDylib => None,
930935
}
931936
})
932937
.collect();
@@ -1696,11 +1701,11 @@ fn add_local_native_libraries(
16961701
None => continue,
16971702
};
16981703
match lib.kind {
1699-
NativeLibraryKind::NativeUnknown => cmd.link_dylib(name),
1700-
NativeLibraryKind::NativeFramework => cmd.link_framework(name),
1701-
NativeLibraryKind::NativeStaticNobundle => cmd.link_staticlib(name),
1702-
NativeLibraryKind::NativeStatic => cmd.link_whole_staticlib(name, &search_path),
1703-
NativeLibraryKind::NativeRawDylib => {
1704+
NativeLibKind::Dylib | NativeLibKind::Unspecified => cmd.link_dylib(name),
1705+
NativeLibKind::Framework => cmd.link_framework(name),
1706+
NativeLibKind::StaticNoBundle => cmd.link_staticlib(name),
1707+
NativeLibKind::StaticBundle => cmd.link_whole_staticlib(name, &search_path),
1708+
NativeLibKind::RawDylib => {
17041709
// FIXME(#58713): Proper handling for raw dylibs.
17051710
bug!("raw_dylib feature not yet implemented");
17061711
}
@@ -1890,7 +1895,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
18901895
let native_libs = &codegen_results.crate_info.native_libraries[&cnum];
18911896
let skip_native = native_libs
18921897
.iter()
1893-
.any(|lib| lib.kind == NativeLibraryKind::NativeStatic && !relevant_lib(sess, lib));
1898+
.any(|lib| lib.kind == NativeLibKind::StaticBundle && !relevant_lib(sess, lib));
18941899

18951900
if (!are_upstream_rust_objects_already_included(sess)
18961901
|| ignored_for_lto(sess, &codegen_results.crate_info, cnum))
@@ -2032,9 +2037,9 @@ fn add_upstream_native_libraries(
20322037
continue;
20332038
}
20342039
match lib.kind {
2035-
NativeLibraryKind::NativeUnknown => cmd.link_dylib(name),
2036-
NativeLibraryKind::NativeFramework => cmd.link_framework(name),
2037-
NativeLibraryKind::NativeStaticNobundle => {
2040+
NativeLibKind::Dylib | NativeLibKind::Unspecified => cmd.link_dylib(name),
2041+
NativeLibKind::Framework => cmd.link_framework(name),
2042+
NativeLibKind::StaticNoBundle => {
20382043
// Link "static-nobundle" native libs only if the crate they originate from
20392044
// is being linked statically to the current crate. If it's linked dynamically
20402045
// or is an rlib already included via some other dylib crate, the symbols from
@@ -2046,8 +2051,8 @@ fn add_upstream_native_libraries(
20462051
// ignore statically included native libraries here as we've
20472052
// already included them when we included the rust library
20482053
// previously
2049-
NativeLibraryKind::NativeStatic => {}
2050-
NativeLibraryKind::NativeRawDylib => {
2054+
NativeLibKind::StaticBundle => {}
2055+
NativeLibKind::RawDylib => {
20512056
// FIXME(#58713): Proper handling for raw dylibs.
20522057
bug!("raw_dylib feature not yet implemented");
20532058
}
@@ -2056,7 +2061,7 @@ fn add_upstream_native_libraries(
20562061
}
20572062
}
20582063

2059-
fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool {
2064+
fn relevant_lib(sess: &Session, lib: &NativeLib) -> bool {
20602065
match lib.cfg {
20612066
Some(ref cfg) => rustc_attr::cfg_matches(cfg, &sess.parse_sess, None),
20622067
None => true,

src/librustc_codegen_ssa/base.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ use rustc_middle::ty::query::Providers;
4444
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
4545
use rustc_session::cgu_reuse_tracker::CguReuse;
4646
use rustc_session::config::{self, EntryFnType};
47+
use rustc_session::utils::NativeLibKind;
4748
use rustc_session::Session;
4849
use rustc_span::Span;
4950
use rustc_symbol_mangling::test as symbol_names_test;
@@ -895,7 +896,7 @@ pub fn provide_both(providers: &mut Providers<'_>) {
895896
.native_libraries(krate)
896897
.iter()
897898
.filter(|lib| {
898-
if lib.kind != cstore::NativeLibraryKind::NativeUnknown {
899+
if !matches!(lib.kind, NativeLibKind::Dylib | NativeLibKind::Unspecified) {
899900
return false;
900901
}
901902
let cfg = match lib.cfg {

src/librustc_codegen_ssa/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use rustc_data_structures::sync::Lrc;
2424
use rustc_hir::def_id::CrateNum;
2525
use rustc_hir::LangItem;
2626
use rustc_middle::dep_graph::WorkProduct;
27-
use rustc_middle::middle::cstore::{CrateSource, LibSource, NativeLibrary};
27+
use rustc_middle::middle::cstore::{CrateSource, LibSource, NativeLib};
2828
use rustc_middle::middle::dependency_format::Dependencies;
2929
use rustc_middle::ty::query::Providers;
3030
use rustc_session::config::{OutputFilenames, OutputType, RUST_CGU_EXT};
@@ -112,9 +112,9 @@ pub struct CrateInfo {
112112
pub compiler_builtins: Option<CrateNum>,
113113
pub profiler_runtime: Option<CrateNum>,
114114
pub is_no_builtins: FxHashSet<CrateNum>,
115-
pub native_libraries: FxHashMap<CrateNum, Lrc<Vec<NativeLibrary>>>,
115+
pub native_libraries: FxHashMap<CrateNum, Lrc<Vec<NativeLib>>>,
116116
pub crate_name: FxHashMap<CrateNum, String>,
117-
pub used_libraries: Lrc<Vec<NativeLibrary>>,
117+
pub used_libraries: Lrc<Vec<NativeLib>>,
118118
pub link_args: Lrc<Vec<String>>,
119119
pub used_crate_source: FxHashMap<CrateNum, Lrc<CrateSource>>,
120120
pub used_crates_static: Vec<(CrateNum, LibSource)>,

src/librustc_infer/infer/region_constraints/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
784784
)
785785
}
786786

787-
/// See [`RegionInference::region_constraints_added_in_snapshot`].
787+
/// See `InferCtxt::region_constraints_added_in_snapshot`.
788788
pub fn region_constraints_added_in_snapshot(&self, mark: &Snapshot<'tcx>) -> Option<bool> {
789789
self.undo_log
790790
.region_constraints_in_snapshot(mark)

src/librustc_interface/tests.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::interface::parse_cfgspecs;
22

33
use rustc_data_structures::fx::FxHashSet;
44
use rustc_errors::{emitter::HumanReadableErrorType, registry, ColorConfig};
5-
use rustc_middle::middle::cstore;
65
use rustc_session::config::Strip;
76
use rustc_session::config::{build_configuration, build_session_options, to_crate_config};
87
use rustc_session::config::{rustc_optgroups, ErrorOutputType, ExternLocation, Options, Passes};
@@ -11,6 +10,7 @@ use rustc_session::config::{Externs, OutputType, OutputTypes, Sanitizer, SymbolM
1110
use rustc_session::getopts;
1211
use rustc_session::lint::Level;
1312
use rustc_session::search_paths::SearchPath;
13+
use rustc_session::utils::NativeLibKind;
1414
use rustc_session::{build_session, Session};
1515
use rustc_span::edition::{Edition, DEFAULT_EDITION};
1616
use rustc_span::symbol::sym;
@@ -300,30 +300,30 @@ fn test_native_libs_tracking_hash_different_values() {
300300

301301
// Reference
302302
v1.libs = vec![
303-
(String::from("a"), None, Some(cstore::NativeStatic)),
304-
(String::from("b"), None, Some(cstore::NativeFramework)),
305-
(String::from("c"), None, Some(cstore::NativeUnknown)),
303+
(String::from("a"), None, NativeLibKind::StaticBundle),
304+
(String::from("b"), None, NativeLibKind::Framework),
305+
(String::from("c"), None, NativeLibKind::Unspecified),
306306
];
307307

308308
// Change label
309309
v2.libs = vec![
310-
(String::from("a"), None, Some(cstore::NativeStatic)),
311-
(String::from("X"), None, Some(cstore::NativeFramework)),
312-
(String::from("c"), None, Some(cstore::NativeUnknown)),
310+
(String::from("a"), None, NativeLibKind::StaticBundle),
311+
(String::from("X"), None, NativeLibKind::Framework),
312+
(String::from("c"), None, NativeLibKind::Unspecified),
313313
];
314314

315315
// Change kind
316316
v3.libs = vec![
317-
(String::from("a"), None, Some(cstore::NativeStatic)),
318-
(String::from("b"), None, Some(cstore::NativeStatic)),
319-
(String::from("c"), None, Some(cstore::NativeUnknown)),
317+
(String::from("a"), None, NativeLibKind::StaticBundle),
318+
(String::from("b"), None, NativeLibKind::StaticBundle),
319+
(String::from("c"), None, NativeLibKind::Unspecified),
320320
];
321321

322322
// Change new-name
323323
v4.libs = vec![
324-
(String::from("a"), None, Some(cstore::NativeStatic)),
325-
(String::from("b"), Some(String::from("X")), Some(cstore::NativeFramework)),
326-
(String::from("c"), None, Some(cstore::NativeUnknown)),
324+
(String::from("a"), None, NativeLibKind::StaticBundle),
325+
(String::from("b"), Some(String::from("X")), NativeLibKind::Framework),
326+
(String::from("c"), None, NativeLibKind::Unspecified),
327327
];
328328

329329
assert!(v1.dep_tracking_hash() != v2.dep_tracking_hash());
@@ -345,21 +345,21 @@ fn test_native_libs_tracking_hash_different_order() {
345345

346346
// Reference
347347
v1.libs = vec![
348-
(String::from("a"), None, Some(cstore::NativeStatic)),
349-
(String::from("b"), None, Some(cstore::NativeFramework)),
350-
(String::from("c"), None, Some(cstore::NativeUnknown)),
348+
(String::from("a"), None, NativeLibKind::StaticBundle),
349+
(String::from("b"), None, NativeLibKind::Framework),
350+
(String::from("c"), None, NativeLibKind::Unspecified),
351351
];
352352

353353
v2.libs = vec![
354-
(String::from("b"), None, Some(cstore::NativeFramework)),
355-
(String::from("a"), None, Some(cstore::NativeStatic)),
356-
(String::from("c"), None, Some(cstore::NativeUnknown)),
354+
(String::from("b"), None, NativeLibKind::Framework),
355+
(String::from("a"), None, NativeLibKind::StaticBundle),
356+
(String::from("c"), None, NativeLibKind::Unspecified),
357357
];
358358

359359
v3.libs = vec![
360-
(String::from("c"), None, Some(cstore::NativeUnknown)),
361-
(String::from("a"), None, Some(cstore::NativeStatic)),
362-
(String::from("b"), None, Some(cstore::NativeFramework)),
360+
(String::from("c"), None, NativeLibKind::Unspecified),
361+
(String::from("a"), None, NativeLibKind::StaticBundle),
362+
(String::from("b"), None, NativeLibKind::Framework),
363363
];
364364

365365
assert!(v1.dep_tracking_hash() == v2.dep_tracking_hash());

0 commit comments

Comments
 (0)