Skip to content

Commit d47fac7

Browse files
committed
Auto merge of rust-lang#140690 - Zalathar:rollup-f8sxwp1, r=Zalathar
Rollup of 12 pull requests Successful merges: - rust-lang#139550 (Fix `-Zremap-path-scope` rmeta handling) - rust-lang#139773 (Implement `Iterator::last` for `vec::IntoIter`) - rust-lang#140035 (Implement RFC 3503: frontmatters) - rust-lang#140176 (Fix linking statics on Arm64EC) - rust-lang#140251 (coverage-dump: Resolve global file IDs to filenames) - rust-lang#140393 (std: get rid of `sys_common::process`) - rust-lang#140532 (Fix RustAnalyzer discovery of rustc's `stable_mir` crate) - rust-lang#140598 (Steer docs to `utf8_chunks` and `Iterator::take`) - rust-lang#140634 (Use more accurate ELF flags on MIPS) - rust-lang#140673 (Clean rustdoc tests folder) - rust-lang#140678 (Be a bit more relaxed about not yet constrained infer vars in closure upvar analysis) - rust-lang#140687 (Update mdbook to 0.4.49) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7295b08 + 1e27a12 commit d47fac7

File tree

563 files changed

+2472
-769
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

563 files changed

+2472
-769
lines changed

Cargo.lock

+2-1
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ name = "coverage-dump"
777777
version = "0.1.0"
778778
dependencies = [
779779
"anyhow",
780+
"itertools",
780781
"leb128",
781782
"md-5",
782783
"miniz_oxide 0.7.4",
@@ -3604,13 +3605,13 @@ dependencies = [
36043605
"rustc_query_system",
36053606
"rustc_resolve",
36063607
"rustc_session",
3607-
"rustc_smir",
36083608
"rustc_span",
36093609
"rustc_target",
36103610
"rustc_trait_selection",
36113611
"rustc_ty_utils",
36123612
"serde_json",
36133613
"shlex",
3614+
"stable_mir",
36143615
"tracing",
36153616
"windows 0.59.0",
36163617
]

compiler/rustc_ast_passes/src/feature_gate.rs

+1
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
514514
gate_all!(contracts_internals, "contract internal machinery is for internal use only");
515515
gate_all!(where_clause_attrs, "attributes in `where` clause are unstable");
516516
gate_all!(super_let, "`super let` is experimental");
517+
gate_all!(frontmatter, "frontmatters are experimental");
517518

518519
if !visitor.features.never_patterns() {
519520
if let Some(spans) = spans.get(&sym::never_patterns) {

compiler/rustc_codegen_llvm/src/consts.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,8 @@ impl<'ll> CodegenCx<'ll, '_> {
364364

365365
if !def_id.is_local() {
366366
let needs_dll_storage_attr = self.use_dll_storage_attrs
367-
&& !self.tcx.is_foreign_item(def_id)
367+
&& (!self.tcx.is_foreign_item(def_id)
368+
|| fn_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL))
368369
// Local definitions can never be imported, so we must not apply
369370
// the DLLImport annotation.
370371
&& !dso_local

compiler/rustc_codegen_ssa/src/back/linker.rs

+90-30
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,12 @@ pub(crate) trait Linker {
337337
fn debuginfo(&mut self, strip: Strip, natvis_debugger_visualizers: &[PathBuf]);
338338
fn no_crt_objects(&mut self);
339339
fn no_default_libraries(&mut self);
340-
fn export_symbols(&mut self, tmpdir: &Path, crate_type: CrateType, symbols: &[String]);
340+
fn export_symbols(
341+
&mut self,
342+
tmpdir: &Path,
343+
crate_type: CrateType,
344+
symbols: &[(String, SymbolExportKind)],
345+
);
341346
fn subsystem(&mut self, subsystem: &str);
342347
fn linker_plugin_lto(&mut self);
343348
fn add_eh_frame_header(&mut self) {}
@@ -770,7 +775,12 @@ impl<'a> Linker for GccLinker<'a> {
770775
}
771776
}
772777

773-
fn export_symbols(&mut self, tmpdir: &Path, crate_type: CrateType, symbols: &[String]) {
778+
fn export_symbols(
779+
&mut self,
780+
tmpdir: &Path,
781+
crate_type: CrateType,
782+
symbols: &[(String, SymbolExportKind)],
783+
) {
774784
// Symbol visibility in object files typically takes care of this.
775785
if crate_type == CrateType::Executable {
776786
let should_export_executable_symbols =
@@ -799,7 +809,7 @@ impl<'a> Linker for GccLinker<'a> {
799809
// Write a plain, newline-separated list of symbols
800810
let res: io::Result<()> = try {
801811
let mut f = File::create_buffered(&path)?;
802-
for sym in symbols {
812+
for (sym, _) in symbols {
803813
debug!(" _{sym}");
804814
writeln!(f, "_{sym}")?;
805815
}
@@ -814,11 +824,12 @@ impl<'a> Linker for GccLinker<'a> {
814824
// .def file similar to MSVC one but without LIBRARY section
815825
// because LD doesn't like when it's empty
816826
writeln!(f, "EXPORTS")?;
817-
for symbol in symbols {
827+
for (symbol, kind) in symbols {
828+
let kind_marker = if *kind == SymbolExportKind::Data { " DATA" } else { "" };
818829
debug!(" _{symbol}");
819830
// Quote the name in case it's reserved by linker in some way
820831
// (this accounts for names with dots in particular).
821-
writeln!(f, " \"{symbol}\"")?;
832+
writeln!(f, " \"{symbol}\"{kind_marker}")?;
822833
}
823834
};
824835
if let Err(error) = res {
@@ -831,7 +842,7 @@ impl<'a> Linker for GccLinker<'a> {
831842
writeln!(f, "{{")?;
832843
if !symbols.is_empty() {
833844
writeln!(f, " global:")?;
834-
for sym in symbols {
845+
for (sym, _) in symbols {
835846
debug!(" {sym};");
836847
writeln!(f, " {sym};")?;
837848
}
@@ -1098,7 +1109,12 @@ impl<'a> Linker for MsvcLinker<'a> {
10981109
// crates. Upstream rlibs may be linked statically to this dynamic library,
10991110
// in which case they may continue to transitively be used and hence need
11001111
// their symbols exported.
1101-
fn export_symbols(&mut self, tmpdir: &Path, crate_type: CrateType, symbols: &[String]) {
1112+
fn export_symbols(
1113+
&mut self,
1114+
tmpdir: &Path,
1115+
crate_type: CrateType,
1116+
symbols: &[(String, SymbolExportKind)],
1117+
) {
11021118
// Symbol visibility takes care of this typically
11031119
if crate_type == CrateType::Executable {
11041120
let should_export_executable_symbols =
@@ -1116,9 +1132,10 @@ impl<'a> Linker for MsvcLinker<'a> {
11161132
// straight to exports.
11171133
writeln!(f, "LIBRARY")?;
11181134
writeln!(f, "EXPORTS")?;
1119-
for symbol in symbols {
1135+
for (symbol, kind) in symbols {
1136+
let kind_marker = if *kind == SymbolExportKind::Data { " DATA" } else { "" };
11201137
debug!(" _{symbol}");
1121-
writeln!(f, " {symbol}")?;
1138+
writeln!(f, " {symbol}{kind_marker}")?;
11221139
}
11231140
};
11241141
if let Err(error) = res {
@@ -1259,14 +1276,19 @@ impl<'a> Linker for EmLinker<'a> {
12591276
self.cc_arg("-nodefaultlibs");
12601277
}
12611278

1262-
fn export_symbols(&mut self, _tmpdir: &Path, _crate_type: CrateType, symbols: &[String]) {
1279+
fn export_symbols(
1280+
&mut self,
1281+
_tmpdir: &Path,
1282+
_crate_type: CrateType,
1283+
symbols: &[(String, SymbolExportKind)],
1284+
) {
12631285
debug!("EXPORTED SYMBOLS:");
12641286

12651287
self.cc_arg("-s");
12661288

12671289
let mut arg = OsString::from("EXPORTED_FUNCTIONS=");
12681290
let encoded = serde_json::to_string(
1269-
&symbols.iter().map(|sym| "_".to_owned() + sym).collect::<Vec<_>>(),
1291+
&symbols.iter().map(|(sym, _)| "_".to_owned() + sym).collect::<Vec<_>>(),
12701292
)
12711293
.unwrap();
12721294
debug!("{encoded}");
@@ -1428,8 +1450,13 @@ impl<'a> Linker for WasmLd<'a> {
14281450

14291451
fn no_default_libraries(&mut self) {}
14301452

1431-
fn export_symbols(&mut self, _tmpdir: &Path, _crate_type: CrateType, symbols: &[String]) {
1432-
for sym in symbols {
1453+
fn export_symbols(
1454+
&mut self,
1455+
_tmpdir: &Path,
1456+
_crate_type: CrateType,
1457+
symbols: &[(String, SymbolExportKind)],
1458+
) {
1459+
for (sym, _) in symbols {
14331460
self.link_args(&["--export", sym]);
14341461
}
14351462

@@ -1563,7 +1590,7 @@ impl<'a> Linker for L4Bender<'a> {
15631590
self.cc_arg("-nostdlib");
15641591
}
15651592

1566-
fn export_symbols(&mut self, _: &Path, _: CrateType, _: &[String]) {
1593+
fn export_symbols(&mut self, _: &Path, _: CrateType, _: &[(String, SymbolExportKind)]) {
15671594
// ToDo, not implemented, copy from GCC
15681595
self.sess.dcx().emit_warn(errors::L4BenderExportingSymbolsUnimplemented);
15691596
}
@@ -1720,12 +1747,17 @@ impl<'a> Linker for AixLinker<'a> {
17201747

17211748
fn no_default_libraries(&mut self) {}
17221749

1723-
fn export_symbols(&mut self, tmpdir: &Path, _crate_type: CrateType, symbols: &[String]) {
1750+
fn export_symbols(
1751+
&mut self,
1752+
tmpdir: &Path,
1753+
_crate_type: CrateType,
1754+
symbols: &[(String, SymbolExportKind)],
1755+
) {
17241756
let path = tmpdir.join("list.exp");
17251757
let res: io::Result<()> = try {
17261758
let mut f = File::create_buffered(&path)?;
17271759
// FIXME: use llvm-nm to generate export list.
1728-
for symbol in symbols {
1760+
for (symbol, _) in symbols {
17291761
debug!(" _{symbol}");
17301762
writeln!(f, " {symbol}")?;
17311763
}
@@ -1769,9 +1801,12 @@ fn for_each_exported_symbols_include_dep<'tcx>(
17691801
}
17701802
}
17711803

1772-
pub(crate) fn exported_symbols(tcx: TyCtxt<'_>, crate_type: CrateType) -> Vec<String> {
1804+
pub(crate) fn exported_symbols(
1805+
tcx: TyCtxt<'_>,
1806+
crate_type: CrateType,
1807+
) -> Vec<(String, SymbolExportKind)> {
17731808
if let Some(ref exports) = tcx.sess.target.override_export_symbols {
1774-
return exports.iter().map(ToString::to_string).collect();
1809+
return exports.iter().map(|name| (name.to_string(), SymbolExportKind::Text)).collect();
17751810
}
17761811

17771812
if let CrateType::ProcMacro = crate_type {
@@ -1781,25 +1816,29 @@ pub(crate) fn exported_symbols(tcx: TyCtxt<'_>, crate_type: CrateType) -> Vec<St
17811816
}
17821817
}
17831818

1784-
fn exported_symbols_for_non_proc_macro(tcx: TyCtxt<'_>, crate_type: CrateType) -> Vec<String> {
1819+
fn exported_symbols_for_non_proc_macro(
1820+
tcx: TyCtxt<'_>,
1821+
crate_type: CrateType,
1822+
) -> Vec<(String, SymbolExportKind)> {
17851823
let mut symbols = Vec::new();
17861824
let export_threshold = symbol_export::crates_export_threshold(&[crate_type]);
17871825
for_each_exported_symbols_include_dep(tcx, crate_type, |symbol, info, cnum| {
17881826
// Do not export mangled symbols from cdylibs and don't attempt to export compiler-builtins
17891827
// from any cdylib. The latter doesn't work anyway as we use hidden visibility for
17901828
// compiler-builtins. Most linkers silently ignore it, but ld64 gives a warning.
17911829
if info.level.is_below_threshold(export_threshold) && !tcx.is_compiler_builtins(cnum) {
1792-
symbols.push(symbol_export::exporting_symbol_name_for_instance_in_crate(
1793-
tcx, symbol, cnum,
1830+
symbols.push((
1831+
symbol_export::exporting_symbol_name_for_instance_in_crate(tcx, symbol, cnum),
1832+
info.kind,
17941833
));
1795-
symbol_export::extend_exported_symbols(&mut symbols, tcx, symbol, cnum);
1834+
symbol_export::extend_exported_symbols(&mut symbols, tcx, symbol, info, cnum);
17961835
}
17971836
});
17981837

17991838
symbols
18001839
}
18011840

1802-
fn exported_symbols_for_proc_macro_crate(tcx: TyCtxt<'_>) -> Vec<String> {
1841+
fn exported_symbols_for_proc_macro_crate(tcx: TyCtxt<'_>) -> Vec<(String, SymbolExportKind)> {
18031842
// `exported_symbols` will be empty when !should_codegen.
18041843
if !tcx.sess.opts.output_types.should_codegen() {
18051844
return Vec::new();
@@ -1809,7 +1848,10 @@ fn exported_symbols_for_proc_macro_crate(tcx: TyCtxt<'_>) -> Vec<String> {
18091848
let proc_macro_decls_name = tcx.sess.generate_proc_macro_decls_symbol(stable_crate_id);
18101849
let metadata_symbol_name = exported_symbols::metadata_symbol_name(tcx);
18111850

1812-
vec![proc_macro_decls_name, metadata_symbol_name]
1851+
vec![
1852+
(proc_macro_decls_name, SymbolExportKind::Text),
1853+
(metadata_symbol_name, SymbolExportKind::Text),
1854+
]
18131855
}
18141856

18151857
pub(crate) fn linked_symbols(
@@ -1831,7 +1873,9 @@ pub(crate) fn linked_symbols(
18311873
|| info.used
18321874
{
18331875
symbols.push((
1834-
symbol_export::linking_symbol_name_for_instance_in_crate(tcx, symbol, cnum),
1876+
symbol_export::linking_symbol_name_for_instance_in_crate(
1877+
tcx, symbol, info.kind, cnum,
1878+
),
18351879
info.kind,
18361880
));
18371881
}
@@ -1906,7 +1950,13 @@ impl<'a> Linker for PtxLinker<'a> {
19061950

19071951
fn ehcont_guard(&mut self) {}
19081952

1909-
fn export_symbols(&mut self, _tmpdir: &Path, _crate_type: CrateType, _symbols: &[String]) {}
1953+
fn export_symbols(
1954+
&mut self,
1955+
_tmpdir: &Path,
1956+
_crate_type: CrateType,
1957+
_symbols: &[(String, SymbolExportKind)],
1958+
) {
1959+
}
19101960

19111961
fn subsystem(&mut self, _subsystem: &str) {}
19121962

@@ -1975,10 +2025,15 @@ impl<'a> Linker for LlbcLinker<'a> {
19752025

19762026
fn ehcont_guard(&mut self) {}
19772027

1978-
fn export_symbols(&mut self, _tmpdir: &Path, _crate_type: CrateType, symbols: &[String]) {
2028+
fn export_symbols(
2029+
&mut self,
2030+
_tmpdir: &Path,
2031+
_crate_type: CrateType,
2032+
symbols: &[(String, SymbolExportKind)],
2033+
) {
19792034
match _crate_type {
19802035
CrateType::Cdylib => {
1981-
for sym in symbols {
2036+
for (sym, _) in symbols {
19822037
self.link_args(&["--export-symbol", sym]);
19832038
}
19842039
}
@@ -2052,11 +2107,16 @@ impl<'a> Linker for BpfLinker<'a> {
20522107

20532108
fn ehcont_guard(&mut self) {}
20542109

2055-
fn export_symbols(&mut self, tmpdir: &Path, _crate_type: CrateType, symbols: &[String]) {
2110+
fn export_symbols(
2111+
&mut self,
2112+
tmpdir: &Path,
2113+
_crate_type: CrateType,
2114+
symbols: &[(String, SymbolExportKind)],
2115+
) {
20562116
let path = tmpdir.join("symbols");
20572117
let res: io::Result<()> = try {
20582118
let mut f = File::create_buffered(&path)?;
2059-
for sym in symbols {
2119+
for (sym, _) in symbols {
20602120
writeln!(f, "{sym}")?;
20612121
}
20622122
};

0 commit comments

Comments
 (0)