Skip to content

Commit bfe1564

Browse files
committed
Auto merge of rust-lang#93202 - matthiaskrgr:rollup-rki39xg, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#85967 (add support for the l4-bender linker on the x86_64-unknown-l4re-uclibc tier 3 target) - rust-lang#92828 (Print a helpful message if unwinding aborts when it reaches a nounwind function) - rust-lang#93012 (Update pulldown-cmark version to fix markdown list issue) - rust-lang#93116 (Simplify use of `map_or`) - rust-lang#93132 (Increase the format version of rustdoc-json-types) - rust-lang#93147 (Interner cleanups) - rust-lang#93153 (Reject unsupported naked functions) - rust-lang#93170 (Add missing GUI test explanations) - rust-lang#93172 (rustdoc: remove dashed underline under main heading) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents ecf7299 + 19e414a commit bfe1564

Some content is hidden

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

49 files changed

+560
-387
lines changed

Cargo.lock

+7-18
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ dependencies = [
689689
"clippy_utils",
690690
"if_chain",
691691
"itertools 0.10.1",
692-
"pulldown-cmark 0.9.0",
692+
"pulldown-cmark",
693693
"quine-mc_cluskey",
694694
"regex-syntax",
695695
"rustc-semver",
@@ -2186,9 +2186,9 @@ dependencies = [
21862186

21872187
[[package]]
21882188
name = "mdbook"
2189-
version = "0.4.14"
2189+
version = "0.4.15"
21902190
source = "registry+https://github.com/rust-lang/crates.io-index"
2191-
checksum = "f6e77253c46a90eb7e96b2807201dab941a4db5ea05eca5aaaf7027395f352b3"
2191+
checksum = "241f10687eb3b4e0634b3b4e423f97c5f1efbd69dc9522e24a8b94583eeec3c6"
21922192
dependencies = [
21932193
"ammonia",
21942194
"anyhow",
@@ -2201,7 +2201,7 @@ dependencies = [
22012201
"log",
22022202
"memchr",
22032203
"opener",
2204-
"pulldown-cmark 0.8.0",
2204+
"pulldown-cmark",
22052205
"regex",
22062206
"serde",
22072207
"serde_derive",
@@ -2865,27 +2865,16 @@ dependencies = [
28652865

28662866
[[package]]
28672867
name = "pulldown-cmark"
2868-
version = "0.8.0"
2868+
version = "0.9.1"
28692869
source = "registry+https://github.com/rust-lang/crates.io-index"
2870-
checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8"
2870+
checksum = "34f197a544b0c9ab3ae46c359a7ec9cbbb5c7bf97054266fecb7ead794a181d6"
28712871
dependencies = [
28722872
"bitflags",
28732873
"getopts",
28742874
"memchr",
28752875
"unicase",
28762876
]
28772877

2878-
[[package]]
2879-
name = "pulldown-cmark"
2880-
version = "0.9.0"
2881-
source = "registry+https://github.com/rust-lang/crates.io-index"
2882-
checksum = "acd16514d1af5f7a71f909a44ef253cdb712a376d7ebc8ae4a471a9be9743548"
2883-
dependencies = [
2884-
"bitflags",
2885-
"memchr",
2886-
"unicase",
2887-
]
2888-
28892878
[[package]]
28902879
name = "punycode"
28912880
version = "0.4.1"
@@ -4440,7 +4429,7 @@ dependencies = [
44404429
"expect-test",
44414430
"itertools 0.9.0",
44424431
"minifier",
4443-
"pulldown-cmark 0.9.0",
4432+
"pulldown-cmark",
44444433
"rayon",
44454434
"regex",
44464435
"rustdoc-json-types",

compiler/rustc_codegen_ssa/src/back/link.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,7 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
11591159
LinkerFlavor::Lld(_) => "lld",
11601160
LinkerFlavor::PtxLinker => "rust-ptx-linker",
11611161
LinkerFlavor::BpfLinker => "bpf-linker",
1162+
LinkerFlavor::L4Bender => "l4-bender",
11621163
}),
11631164
flavor,
11641165
)),

compiler/rustc_codegen_ssa/src/back/linker.rs

+153-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ pub fn get_linker<'a>(
126126
// FIXME: Move `/LIBPATH` addition for uwp targets from the linker construction
127127
// to the linker args construction.
128128
assert!(cmd.get_args().is_empty() || sess.target.vendor == "uwp");
129-
130129
match flavor {
131130
LinkerFlavor::Lld(LldFlavor::Link) | LinkerFlavor::Msvc => {
132131
Box::new(MsvcLinker { cmd, sess }) as Box<dyn Linker>
@@ -149,6 +148,8 @@ pub fn get_linker<'a>(
149148
LinkerFlavor::PtxLinker => Box::new(PtxLinker { cmd, sess }) as Box<dyn Linker>,
150149

151150
LinkerFlavor::BpfLinker => Box::new(BpfLinker { cmd, sess }) as Box<dyn Linker>,
151+
152+
LinkerFlavor::L4Bender => Box::new(L4Bender::new(cmd, sess)) as Box<dyn Linker>,
152153
}
153154
}
154155

@@ -1355,6 +1356,157 @@ impl<'a> Linker for WasmLd<'a> {
13551356
}
13561357
}
13571358

1359+
/// Linker shepherd script for L4Re (Fiasco)
1360+
pub struct L4Bender<'a> {
1361+
cmd: Command,
1362+
sess: &'a Session,
1363+
hinted_static: bool,
1364+
}
1365+
1366+
impl<'a> Linker for L4Bender<'a> {
1367+
fn link_dylib(&mut self, _lib: Symbol, _verbatim: bool, _as_needed: bool) {
1368+
bug!("dylibs are not supported on L4Re");
1369+
}
1370+
fn link_staticlib(&mut self, lib: Symbol, _verbatim: bool) {
1371+
self.hint_static();
1372+
self.cmd.arg(format!("-PC{}", lib));
1373+
}
1374+
fn link_rlib(&mut self, lib: &Path) {
1375+
self.hint_static();
1376+
self.cmd.arg(lib);
1377+
}
1378+
fn include_path(&mut self, path: &Path) {
1379+
self.cmd.arg("-L").arg(path);
1380+
}
1381+
fn framework_path(&mut self, _: &Path) {
1382+
bug!("frameworks are not supported on L4Re");
1383+
}
1384+
fn output_filename(&mut self, path: &Path) {
1385+
self.cmd.arg("-o").arg(path);
1386+
}
1387+
1388+
fn add_object(&mut self, path: &Path) {
1389+
self.cmd.arg(path);
1390+
}
1391+
1392+
fn full_relro(&mut self) {
1393+
self.cmd.arg("-zrelro");
1394+
self.cmd.arg("-znow");
1395+
}
1396+
1397+
fn partial_relro(&mut self) {
1398+
self.cmd.arg("-zrelro");
1399+
}
1400+
1401+
fn no_relro(&mut self) {
1402+
self.cmd.arg("-znorelro");
1403+
}
1404+
1405+
fn cmd(&mut self) -> &mut Command {
1406+
&mut self.cmd
1407+
}
1408+
1409+
fn set_output_kind(&mut self, _output_kind: LinkOutputKind, _out_filename: &Path) {}
1410+
1411+
fn link_rust_dylib(&mut self, _: Symbol, _: &Path) {
1412+
panic!("Rust dylibs not supported");
1413+
}
1414+
1415+
fn link_framework(&mut self, _framework: Symbol, _as_needed: bool) {
1416+
bug!("frameworks not supported on L4Re");
1417+
}
1418+
1419+
fn link_whole_staticlib(&mut self, lib: Symbol, _verbatim: bool, _search_path: &[PathBuf]) {
1420+
self.hint_static();
1421+
self.cmd.arg("--whole-archive").arg(format!("-l{}", lib));
1422+
self.cmd.arg("--no-whole-archive");
1423+
}
1424+
1425+
fn link_whole_rlib(&mut self, lib: &Path) {
1426+
self.hint_static();
1427+
self.cmd.arg("--whole-archive").arg(lib).arg("--no-whole-archive");
1428+
}
1429+
1430+
fn gc_sections(&mut self, keep_metadata: bool) {
1431+
if !keep_metadata {
1432+
self.cmd.arg("--gc-sections");
1433+
}
1434+
}
1435+
1436+
fn no_gc_sections(&mut self) {
1437+
self.cmd.arg("--no-gc-sections");
1438+
}
1439+
1440+
fn optimize(&mut self) {
1441+
// GNU-style linkers support optimization with -O. GNU ld doesn't
1442+
// need a numeric argument, but other linkers do.
1443+
if self.sess.opts.optimize == config::OptLevel::Default
1444+
|| self.sess.opts.optimize == config::OptLevel::Aggressive
1445+
{
1446+
self.cmd.arg("-O1");
1447+
}
1448+
}
1449+
1450+
fn pgo_gen(&mut self) {}
1451+
1452+
fn debuginfo(&mut self, strip: Strip) {
1453+
match strip {
1454+
Strip::None => {}
1455+
Strip::Debuginfo => {
1456+
self.cmd().arg("--strip-debug");
1457+
}
1458+
Strip::Symbols => {
1459+
self.cmd().arg("--strip-all");
1460+
}
1461+
}
1462+
}
1463+
1464+
fn no_default_libraries(&mut self) {
1465+
self.cmd.arg("-nostdlib");
1466+
}
1467+
1468+
fn export_symbols(&mut self, _: &Path, _: CrateType, _: &[String]) {
1469+
// ToDo, not implemented, copy from GCC
1470+
self.sess.warn("exporting symbols not implemented yet for L4Bender");
1471+
return;
1472+
}
1473+
1474+
fn subsystem(&mut self, subsystem: &str) {
1475+
self.cmd.arg(&format!("--subsystem {}", subsystem));
1476+
}
1477+
1478+
fn reset_per_library_state(&mut self) {
1479+
self.hint_static(); // Reset to default before returning the composed command line.
1480+
}
1481+
1482+
fn group_start(&mut self) {
1483+
self.cmd.arg("--start-group");
1484+
}
1485+
1486+
fn group_end(&mut self) {
1487+
self.cmd.arg("--end-group");
1488+
}
1489+
1490+
fn linker_plugin_lto(&mut self) {}
1491+
1492+
fn control_flow_guard(&mut self) {}
1493+
1494+
fn no_crt_objects(&mut self) {}
1495+
}
1496+
1497+
impl<'a> L4Bender<'a> {
1498+
pub fn new(cmd: Command, sess: &'a Session) -> L4Bender<'a> {
1499+
L4Bender { cmd: cmd, sess: sess, hinted_static: false }
1500+
}
1501+
1502+
fn hint_static(&mut self) {
1503+
if !self.hinted_static {
1504+
self.cmd.arg("-static");
1505+
self.hinted_static = true;
1506+
}
1507+
}
1508+
}
1509+
13581510
pub(crate) fn exported_symbols(tcx: TyCtxt<'_>, crate_type: CrateType) -> Vec<String> {
13591511
if let Some(ref exports) = tcx.sess.target.override_export_symbols {
13601512
return exports.clone();

compiler/rustc_codegen_ssa/src/mir/block.rs

+23-4
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,28 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
477477
helper.do_call(self, &mut bx, fn_abi, llfn, &args, None, cleanup);
478478
}
479479

480+
fn codegen_abort_terminator(
481+
&mut self,
482+
helper: TerminatorCodegenHelper<'tcx>,
483+
mut bx: Bx,
484+
terminator: &mir::Terminator<'tcx>,
485+
) {
486+
let span = terminator.source_info.span;
487+
self.set_debug_loc(&mut bx, terminator.source_info);
488+
489+
// Get the location information.
490+
let location = self.get_caller_location(&mut bx, terminator.source_info).immediate();
491+
492+
// Obtain the panic entry point.
493+
let def_id = common::langcall(bx.tcx(), Some(span), "", LangItem::PanicNoUnwind);
494+
let instance = ty::Instance::mono(bx.tcx(), def_id);
495+
let fn_abi = bx.fn_abi_of_instance(instance, ty::List::empty());
496+
let llfn = bx.get_fn_addr(instance);
497+
498+
// Codegen the actual panic invoke/call.
499+
helper.do_call(self, &mut bx, fn_abi, llfn, &[location], None, None);
500+
}
501+
480502
/// Returns `true` if this is indeed a panic intrinsic and codegen is done.
481503
fn codegen_panic_intrinsic(
482504
&mut self,
@@ -1014,10 +1036,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
10141036
mir::TerminatorKind::Resume => self.codegen_resume_terminator(helper, bx),
10151037

10161038
mir::TerminatorKind::Abort => {
1017-
bx.abort();
1018-
// `abort` does not terminate the block, so we still need to generate
1019-
// an `unreachable` terminator after it.
1020-
bx.unreachable();
1039+
self.codegen_abort_terminator(helper, bx, terminator);
10211040
}
10221041

10231042
mir::TerminatorKind::Goto { target } => {

compiler/rustc_error_codes/src/error_codes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ E0783: include_str!("./error_codes/E0783.md"),
486486
E0784: include_str!("./error_codes/E0784.md"),
487487
E0785: include_str!("./error_codes/E0785.md"),
488488
E0786: include_str!("./error_codes/E0786.md"),
489+
E0787: include_str!("./error_codes/E0787.md"),
489490
;
490491
// E0006, // merged with E0005
491492
// E0008, // cannot bind by-move into a pattern guard
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
An unsupported naked function definition.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0787
6+
#![feature(naked_functions)]
7+
8+
#[naked]
9+
pub extern "C" fn f() -> u32 {
10+
42
11+
}
12+
```
13+
14+
The naked functions must be defined using a single inline assembly
15+
block.
16+
17+
The execution must never fall through past the end of the assembly
18+
code so the block must use `noreturn` option. The asm block can also
19+
use `att_syntax` and `raw` options, but others options are not allowed.
20+
21+
The asm block must not contain any operands other than `const` and
22+
`sym`.
23+
24+
### Additional information
25+
26+
For more information, please see [RFC 2972].
27+
28+
[RFC 2972]: https://github.com/rust-lang/rfcs/blob/master/text/2972-constrained-naked.md

compiler/rustc_hir/src/lang_items.rs

+1
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ language_item_table! {
283283
PanicInfo, sym::panic_info, panic_info, Target::Struct, GenericRequirement::None;
284284
PanicLocation, sym::panic_location, panic_location, Target::Struct, GenericRequirement::None;
285285
PanicImpl, sym::panic_impl, panic_impl, Target::Fn, GenericRequirement::None;
286+
PanicNoUnwind, sym::panic_no_unwind, panic_no_unwind, Target::Fn, GenericRequirement::Exact(0);
286287
/// libstd panic entry point. Necessary for const eval to be able to catch it
287288
BeginPanic, sym::begin_panic, begin_panic_fn, Target::Fn, GenericRequirement::None;
288289

compiler/rustc_lint/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,11 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
481481
<https://github.com/rust-lang/rust/issues/59014> for more information",
482482
);
483483
store.register_removed("plugin_as_library", "plugins have been deprecated and retired");
484+
store.register_removed(
485+
"unsupported_naked_functions",
486+
"converted into hard error, see RFC 2972 \
487+
<https://github.com/rust-lang/rfcs/blob/master/text/2972-constrained-naked.md> for more information",
488+
);
484489
}
485490

486491
fn register_internals(store: &mut LintStore) {

0 commit comments

Comments
 (0)