Skip to content

Commit 90b3882

Browse files
committed
Auto merge of #103739 - Mark-Simulacrum:beta-next, r=Mark-Simulacrum
[beta] backport rollup * poll_fn and Unpin: fix pinning #102737 * Support raw-dylib functions being used inside inlined functions #102988 * Fix line numbers for MIR inlined code #103071 * Add architectures to fn create_object_file #103240 * Add eval hack in super_relate_consts back #103279 * Mark std::os::wasi::io::AsFd etc. as stable. #103308 * Truncate thread names on Linux and Apple targets #103379 * Do not consider repeated lifetime params for elision. #103450 * rustdoc: add missing URL redirect #103588 * Remove commit_if_ok probe from NLL type relation #103601 Also includes a copy of the release notes. r? `@ghost`
2 parents 636a78a + 108b32e commit 90b3882

File tree

38 files changed

+713
-81
lines changed

38 files changed

+713
-81
lines changed

RELEASES.md

Lines changed: 244 additions & 0 deletions
Large diffs are not rendered by default.

compiler/rustc_codegen_cranelift/src/archive.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ impl ArchiveBuilderBuilder for ArArchiveBuilderBuilder {
3838
_lib_name: &str,
3939
_dll_imports: &[rustc_session::cstore::DllImport],
4040
_tmpdir: &Path,
41+
_is_direct_dependency: bool,
4142
) -> PathBuf {
4243
bug!("creating dll imports is not supported");
4344
}

compiler/rustc_codegen_gcc/src/archive.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ impl ArchiveBuilderBuilder for ArArchiveBuilderBuilder {
4545
_lib_name: &str,
4646
_dll_imports: &[DllImport],
4747
_tmpdir: &Path,
48+
_is_direct_dependency: bool,
4849
) -> PathBuf {
4950
unimplemented!();
5051
}

compiler/rustc_codegen_llvm/src/back/archive.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,12 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
104104
lib_name: &str,
105105
dll_imports: &[DllImport],
106106
tmpdir: &Path,
107+
is_direct_dependency: bool,
107108
) -> PathBuf {
109+
let name_suffix = if is_direct_dependency { "_imports" } else { "_imports_indirect" };
108110
let output_path = {
109111
let mut output_path: PathBuf = tmpdir.to_path_buf();
110-
output_path.push(format!("{}_imports", lib_name));
112+
output_path.push(format!("{}{}", lib_name, name_suffix));
111113
output_path.with_extension("lib")
112114
};
113115

@@ -134,7 +136,8 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
134136
// that loaded but crashed with an AV upon calling one of the imported
135137
// functions. Therefore, use binutils to create the import library instead,
136138
// by writing a .DEF file to the temp dir and calling binutils's dlltool.
137-
let def_file_path = tmpdir.join(format!("{}_imports", lib_name)).with_extension("def");
139+
let def_file_path =
140+
tmpdir.join(format!("{}{}", lib_name, name_suffix)).with_extension("def");
138141

139142
let def_file_content = format!(
140143
"EXPORTS\n{}",

compiler/rustc_codegen_ssa/src/back/archive.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub trait ArchiveBuilderBuilder {
2525
lib_name: &str,
2626
dll_imports: &[DllImport],
2727
tmpdir: &Path,
28+
is_direct_dependency: bool,
2829
) -> PathBuf;
2930

3031
fn extract_bundled_libs(

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,13 +376,14 @@ fn link_rlib<'a>(
376376
}
377377

378378
for (raw_dylib_name, raw_dylib_imports) in
379-
collate_raw_dylibs(sess, &codegen_results.crate_info.used_libraries)?
379+
collate_raw_dylibs(sess, codegen_results.crate_info.used_libraries.iter())?
380380
{
381381
let output_path = archive_builder_builder.create_dll_import_lib(
382382
sess,
383383
&raw_dylib_name,
384384
&raw_dylib_imports,
385385
tmpdir.as_ref(),
386+
true,
386387
);
387388

388389
ab.add_archive(&output_path, Box::new(|_| false)).unwrap_or_else(|e| {
@@ -434,9 +435,9 @@ fn link_rlib<'a>(
434435
/// then the CodegenResults value contains one NativeLib instance for each block. However, the
435436
/// linker appears to expect only a single import library for each library used, so we need to
436437
/// collate the symbols together by library name before generating the import libraries.
437-
fn collate_raw_dylibs(
438-
sess: &Session,
439-
used_libraries: &[NativeLib],
438+
fn collate_raw_dylibs<'a, 'b>(
439+
sess: &'a Session,
440+
used_libraries: impl IntoIterator<Item = &'b NativeLib>,
440441
) -> Result<Vec<(String, Vec<DllImport>)>, ErrorGuaranteed> {
441442
// Use index maps to preserve original order of imports and libraries.
442443
let mut dylib_table = FxIndexMap::<String, FxIndexMap<Symbol, &DllImport>>::default();
@@ -2028,13 +2029,43 @@ fn linker_with_args<'a>(
20282029

20292030
// Link with the import library generated for any raw-dylib functions.
20302031
for (raw_dylib_name, raw_dylib_imports) in
2031-
collate_raw_dylibs(sess, &codegen_results.crate_info.used_libraries)?
2032+
collate_raw_dylibs(sess, codegen_results.crate_info.used_libraries.iter())?
2033+
{
2034+
cmd.add_object(&archive_builder_builder.create_dll_import_lib(
2035+
sess,
2036+
&raw_dylib_name,
2037+
&raw_dylib_imports,
2038+
tmpdir,
2039+
true,
2040+
));
2041+
}
2042+
// As with add_upstream_native_libraries, we need to add the upstream raw-dylib symbols in case
2043+
// they are used within inlined functions or instantiated generic functions. We do this *after*
2044+
// handling the raw-dylib symbols in the current crate to make sure that those are chosen first
2045+
// by the linker.
2046+
let (_, dependency_linkage) = codegen_results
2047+
.crate_info
2048+
.dependency_formats
2049+
.iter()
2050+
.find(|(ty, _)| *ty == crate_type)
2051+
.expect("failed to find crate type in dependency format list");
2052+
let native_libraries_from_nonstatics = codegen_results
2053+
.crate_info
2054+
.native_libraries
2055+
.iter()
2056+
.filter_map(|(cnum, libraries)| {
2057+
(dependency_linkage[cnum.as_usize() - 1] != Linkage::Static).then(|| libraries)
2058+
})
2059+
.flatten();
2060+
for (raw_dylib_name, raw_dylib_imports) in
2061+
collate_raw_dylibs(sess, native_libraries_from_nonstatics)?
20322062
{
20332063
cmd.add_object(&archive_builder_builder.create_dll_import_lib(
20342064
sess,
20352065
&raw_dylib_name,
20362066
&raw_dylib_imports,
20372067
tmpdir,
2068+
false,
20382069
));
20392070
}
20402071

compiler/rustc_codegen_ssa/src/back/metadata.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
117117
"riscv32" => Architecture::Riscv32,
118118
"riscv64" => Architecture::Riscv64,
119119
"sparc64" => Architecture::Sparc64,
120+
"avr" => Architecture::Avr,
121+
"msp430" => Architecture::Msp430,
122+
"hexagon" => Architecture::Hexagon,
123+
"bpf" => Architecture::Bpf,
120124
// Unsupported architecture.
121125
_ => return None,
122126
};

compiler/rustc_const_eval/src/interpret/operand.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,16 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
591591
val: &mir::ConstantKind<'tcx>,
592592
layout: Option<TyAndLayout<'tcx>>,
593593
) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> {
594+
// FIXME(const_prop): normalization needed b/c const prop lint in
595+
// `mir_drops_elaborated_and_const_checked`, which happens before
596+
// optimized MIR. Only after optimizing the MIR can we guarantee
597+
// that the `RevealAll` pass has happened and that the body's consts
598+
// are normalized, so any call to resolve before that needs to be
599+
// manually normalized.
600+
let val = self.tcx.normalize_erasing_regions(self.param_env, *val);
594601
match val {
595-
mir::ConstantKind::Ty(ct) => self.const_to_op(*ct, layout),
596-
mir::ConstantKind::Val(val, ty) => self.const_val_to_op(*val, *ty, layout),
602+
mir::ConstantKind::Ty(ct) => self.const_to_op(ct, layout),
603+
mir::ConstantKind::Val(val, ty) => self.const_val_to_op(val, ty, layout),
597604
mir::ConstantKind::Unevaluated(uv, _) => {
598605
let instance = self.resolve(uv.def, uv.substs)?;
599606
Ok(self.eval_to_allocation(GlobalId { instance, promoted: uv.promoted })?.into())

compiler/rustc_infer/src/infer/nll_relate/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ where
596596
(&ty::Infer(ty::TyVar(vid)), _) => self.relate_ty_var((vid, b)),
597597

598598
(&ty::Opaque(a_def_id, _), &ty::Opaque(b_def_id, _)) if a_def_id == b_def_id => {
599-
infcx.commit_if_ok(|_| infcx.super_combine_tys(self, a, b)).or_else(|err| {
599+
infcx.super_combine_tys(self, a, b).or_else(|err| {
600600
self.tcx().sess.delay_span_bug(
601601
self.delegate.span(),
602602
"failure to relate an opaque to itself should result in an error later on",

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2489,7 +2489,9 @@ impl<'tcx> TyCtxt<'tcx> {
24892489
&& if self.features().collapse_debuginfo {
24902490
span.in_macro_expansion_with_collapse_debuginfo()
24912491
} else {
2492-
span.from_expansion()
2492+
// Inlined spans should not be collapsed as that leads to all of the
2493+
// inlined code being attributed to the inline callsite.
2494+
span.from_expansion() && !span.is_inlined()
24932495
}
24942496
}
24952497

0 commit comments

Comments
 (0)