Skip to content

Commit 0a1b226

Browse files
committed
Auto merge of #56840 - pietroalbini:rollup, r=pietroalbini
Rollup of 14 pull requests Successful merges: - #56718 (Use libbacktrace pretty-printing) - #56725 (fix rust-lang/rust issue #50583) - #56731 (Add missing urls in ffi module docs) - #56738 (Fix private_no_mangle_fns message grammar) - #56746 (Add test of current behavior (infer free region within closure body)) - #56747 (target: remove Box returned by get_targets) - #56751 (Allow ptr::hash to accept fat pointers) - #56755 (Account for `impl Trait` when suggesting lifetime) - #56758 (Add short emoji status to toolstate updates) - #56760 (Deduplicate unsatisfied trait bounds) - #56769 (Add x86_64-unknown-uefi target) - #56792 (Bootstrap: Add testsuite for compiletest tool) - #56808 (Fixes broken links) - #56809 (Fix docs path to PermissionsExt) Failed merges: r? @ghost
2 parents 747a5e5 + ae3882c commit 0a1b226

File tree

27 files changed

+419
-96
lines changed

27 files changed

+419
-96
lines changed

Cargo.lock

+6-6
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ dependencies = [
8181

8282
[[package]]
8383
name = "backtrace"
84-
version = "0.3.9"
84+
version = "0.3.11"
8585
source = "registry+https://github.com/rust-lang/crates.io-index"
8686
dependencies = [
8787
"backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -728,15 +728,15 @@ name = "error-chain"
728728
version = "0.11.0"
729729
source = "registry+https://github.com/rust-lang/crates.io-index"
730730
dependencies = [
731-
"backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
731+
"backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
732732
]
733733

734734
[[package]]
735735
name = "error-chain"
736736
version = "0.12.0"
737737
source = "registry+https://github.com/rust-lang/crates.io-index"
738738
dependencies = [
739-
"backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
739+
"backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
740740
]
741741

742742
[[package]]
@@ -751,7 +751,7 @@ name = "failure"
751751
version = "0.1.3"
752752
source = "registry+https://github.com/rust-lang/crates.io-index"
753753
dependencies = [
754-
"backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
754+
"backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
755755
"failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
756756
]
757757

@@ -2060,7 +2060,7 @@ name = "rustc"
20602060
version = "0.0.0"
20612061
dependencies = [
20622062
"arena 0.0.0",
2063-
"backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
2063+
"backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
20642064
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
20652065
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
20662066
"chalk-engine 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3380,7 +3380,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
33803380
"checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef"
33813381
"checksum assert_cli 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "98589b0e465a6c510d95fceebd365bb79bedece7f6e18a480897f2015f85ec51"
33823382
"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652"
3383-
"checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a"
3383+
"checksum backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "18b65ea1161bfb2dd6da6fade5edd4dbd08fba85012123dd333d2fd1b90b2782"
33843384
"checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0"
33853385
"checksum bit-set 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f1efcc46c18245a69c38fcc5cc650f16d3a59d034f3106e9ed63748f695730a"
33863386
"checksum bit-vec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4440d5cb623bb7390ae27fec0bb6c61111969860f8e3ae198bfa0663645e67cf"

src/bootstrap/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ impl<'a> Builder<'a> {
416416
test::Rustfmt,
417417
test::Miri,
418418
test::Clippy,
419+
test::CompiletestTest,
419420
test::RustdocJS,
420421
test::RustdocTheme,
421422
// Run bootstrap close to the end as it's unlikely to fail

src/bootstrap/test.rs

+39
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,45 @@ impl Step for Miri {
429429
}
430430
}
431431

432+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
433+
pub struct CompiletestTest {
434+
stage: u32,
435+
host: Interned<String>,
436+
}
437+
438+
impl Step for CompiletestTest {
439+
type Output = ();
440+
441+
fn should_run(run: ShouldRun) -> ShouldRun {
442+
run.path("src/tools/compiletest")
443+
}
444+
445+
fn make_run(run: RunConfig) {
446+
run.builder.ensure(CompiletestTest {
447+
stage: run.builder.top_stage,
448+
host: run.target,
449+
});
450+
}
451+
452+
/// Runs `cargo test` for compiletest.
453+
fn run(self, builder: &Builder) {
454+
let stage = self.stage;
455+
let host = self.host;
456+
let compiler = builder.compiler(stage, host);
457+
458+
let mut cargo = tool::prepare_tool_cargo(builder,
459+
compiler,
460+
Mode::ToolBootstrap,
461+
host,
462+
"test",
463+
"src/tools/compiletest",
464+
SourceType::InTree,
465+
&[]);
466+
467+
try_run(builder, &mut cargo);
468+
}
469+
}
470+
432471
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
433472
pub struct Clippy {
434473
stage: u32,

src/ci/docker/dist-various-1/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ RUN env \
5252
CXX=arm-linux-gnueabi-g++ CXXFLAGS="-march=armv6 -marm" \
5353
bash musl.sh arm && \
5454
env \
55-
CC=arm-linux-gnueabihf-gcc CFLAGS="-march=armv6 -marm" \
56-
CXX=arm-linux-gnueabihf-g++ CXXFLAGS="-march=armv6 -marm" \
55+
CC=arm-linux-gnueabihf-gcc CFLAGS="-march=armv6 -marm -mfpu=vfp" \
56+
CXX=arm-linux-gnueabihf-g++ CXXFLAGS="-march=armv6 -marm -mfpu=vfp" \
5757
bash musl.sh armhf && \
5858
env \
5959
CC=arm-linux-gnueabihf-gcc CFLAGS="-march=armv7-a" \

src/doc/rustc/src/targets/built-in.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ the team is supporting directly.
66

77
To see the list of built-in targets, you can run `rustc --print target-list`,
88
or look at [the API
9-
docs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_back/target/#modules).
9+
docs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_target/spec/index.html#modules).
1010
Each module there defines a builder for a particular target.

src/doc/rustc/src/targets/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
architecture. The list of *targets* are the possible architectures that you can build for.
55

66
To see all the options that you can set with a target, see the docs
7-
[here](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_back/target/struct.Target.html).
7+
[here](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_target/spec/struct.Target.html).
88

99
To compile to a particular target, use the `--target` flag:
1010

src/doc/unstable-book/src/language-features/unsized-locals.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The tracking issue for this feature is: [#48055]
88

99
This implements [RFC1909]. When turned on, you can have unsized arguments and locals:
1010

11-
[RFC1909]: https://github.com/rust-lang/rfcs/blob/master/text/1909-coercions.md
11+
[RFC1909]: https://github.com/rust-lang/rfcs/blob/master/text/1909-unsized-rvalues.md
1212

1313
```rust
1414
#![feature(unsized_locals)]

src/libcore/ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2544,7 +2544,7 @@ pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
25442544
/// assert_eq!(actual, expected);
25452545
/// ```
25462546
#[unstable(feature = "ptr_hash", reason = "newly added", issue = "56286")]
2547-
pub fn hash<T, S: hash::Hasher>(hashee: *const T, into: &mut S) {
2547+
pub fn hash<T: ?Sized, S: hash::Hasher>(hashee: *const T, into: &mut S) {
25482548
use hash::Hash;
25492549
hashee.hash(into);
25502550
}

src/librustc/infer/error_reporting/mod.rs

+20-11
Original file line numberDiff line numberDiff line change
@@ -1095,15 +1095,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
10951095
let sp = hir.span(id);
10961096
// `sp` only covers `T`, change it so that it covers
10971097
// `T:` when appropriate
1098-
let sp = if has_bounds {
1098+
let is_impl_trait = bound_kind.to_string().starts_with("impl ");
1099+
let sp = if has_bounds && !is_impl_trait {
10991100
sp.to(self.tcx
11001101
.sess
11011102
.source_map()
11021103
.next_point(self.tcx.sess.source_map().next_point(sp)))
11031104
} else {
11041105
sp
11051106
};
1106-
(sp, has_bounds)
1107+
(sp, has_bounds, is_impl_trait)
11071108
})
11081109
} else {
11091110
None
@@ -1136,25 +1137,33 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
11361137

11371138
fn binding_suggestion<'tcx, S: fmt::Display>(
11381139
err: &mut DiagnosticBuilder<'tcx>,
1139-
type_param_span: Option<(Span, bool)>,
1140+
type_param_span: Option<(Span, bool, bool)>,
11401141
bound_kind: GenericKind<'tcx>,
11411142
sub: S,
11421143
) {
1143-
let consider = &format!(
1144-
"consider adding an explicit lifetime bound `{}: {}`...",
1145-
bound_kind, sub
1144+
let consider = format!(
1145+
"consider adding an explicit lifetime bound {}",
1146+
if type_param_span.map(|(_, _, is_impl_trait)| is_impl_trait).unwrap_or(false) {
1147+
format!(" `{}` to `{}`...", sub, bound_kind)
1148+
} else {
1149+
format!("`{}: {}`...", bound_kind, sub)
1150+
},
11461151
);
1147-
if let Some((sp, has_lifetimes)) = type_param_span {
1148-
let tail = if has_lifetimes { " + " } else { "" };
1149-
let suggestion = format!("{}: {}{}", bound_kind, sub, tail);
1152+
if let Some((sp, has_lifetimes, is_impl_trait)) = type_param_span {
1153+
let suggestion = if is_impl_trait {
1154+
format!("{} + {}", bound_kind, sub)
1155+
} else {
1156+
let tail = if has_lifetimes { " + " } else { "" };
1157+
format!("{}: {}{}", bound_kind, sub, tail)
1158+
};
11501159
err.span_suggestion_short_with_applicability(
11511160
sp,
1152-
consider,
1161+
&consider,
11531162
suggestion,
11541163
Applicability::MaybeIncorrect, // Issue #41966
11551164
);
11561165
} else {
1157-
err.help(consider);
1166+
err.help(&consider);
11581167
}
11591168
}
11601169

src/librustc/mir/interpret/error.rs

+4-40
Original file line numberDiff line numberDiff line change
@@ -183,50 +183,14 @@ pub struct EvalError<'tcx> {
183183
impl<'tcx> EvalError<'tcx> {
184184
pub fn print_backtrace(&mut self) {
185185
if let Some(ref mut backtrace) = self.backtrace {
186-
eprintln!("{}", print_backtrace(&mut *backtrace));
186+
print_backtrace(&mut *backtrace);
187187
}
188188
}
189189
}
190190

191-
fn print_backtrace(backtrace: &mut Backtrace) -> String {
192-
use std::fmt::Write;
193-
191+
fn print_backtrace(backtrace: &mut Backtrace) {
194192
backtrace.resolve();
195-
196-
let mut trace_text = "\n\nAn error occurred in miri:\n".to_string();
197-
write!(trace_text, "backtrace frames: {}\n", backtrace.frames().len()).unwrap();
198-
'frames: for (i, frame) in backtrace.frames().iter().enumerate() {
199-
if frame.symbols().is_empty() {
200-
write!(trace_text, " {}: no symbols\n", i).unwrap();
201-
}
202-
let mut first = true;
203-
for symbol in frame.symbols() {
204-
if first {
205-
write!(trace_text, " {}: ", i).unwrap();
206-
first = false;
207-
} else {
208-
let len = i.to_string().len();
209-
write!(trace_text, " {} ", " ".repeat(len)).unwrap();
210-
}
211-
if let Some(name) = symbol.name() {
212-
write!(trace_text, "{}\n", name).unwrap();
213-
} else {
214-
write!(trace_text, "<unknown>\n").unwrap();
215-
}
216-
write!(trace_text, " at ").unwrap();
217-
if let Some(file_path) = symbol.filename() {
218-
write!(trace_text, "{}", file_path.display()).unwrap();
219-
} else {
220-
write!(trace_text, "<unknown_file>").unwrap();
221-
}
222-
if let Some(line) = symbol.lineno() {
223-
write!(trace_text, ":{}\n", line).unwrap();
224-
} else {
225-
write!(trace_text, "\n").unwrap();
226-
}
227-
}
228-
}
229-
trace_text
193+
eprintln!("\n\nAn error occurred in miri:\n{:?}", backtrace);
230194
}
231195

232196
impl<'tcx> From<EvalErrorKind<'tcx, u64>> for EvalError<'tcx> {
@@ -238,7 +202,7 @@ impl<'tcx> From<EvalErrorKind<'tcx, u64>> for EvalError<'tcx> {
238202

239203
if val == "immediate" {
240204
// Print it now
241-
eprintln!("{}", print_backtrace(&mut backtrace));
205+
print_backtrace(&mut backtrace);
242206
None
243207
} else {
244208
Some(Box::new(backtrace))

src/librustc_lint/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
376376
store.register_removed("resolve_trait_on_defaulted_unit",
377377
"converted into hard error, see https://github.com/rust-lang/rust/issues/48950");
378378
store.register_removed("private_no_mangle_fns",
379-
"no longer an warning, #[no_mangle] functions always exported");
379+
"no longer a warning, #[no_mangle] functions always exported");
380380
store.register_removed("private_no_mangle_statics",
381-
"no longer an warning, #[no_mangle] statics always exported");
381+
"no longer a warning, #[no_mangle] statics always exported");
382382
}

src/librustc_target/spec/mod.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ mod linux_musl_base;
6868
mod openbsd_base;
6969
mod netbsd_base;
7070
mod solaris_base;
71+
mod uefi_base;
7172
mod windows_base;
7273
mod windows_msvc_base;
7374
mod thumb_base;
@@ -254,12 +255,12 @@ macro_rules! supported_targets {
254255
}
255256
}
256257

257-
pub fn get_targets() -> Box<dyn Iterator<Item=String>> {
258-
Box::new(TARGETS.iter().filter_map(|t| -> Option<String> {
258+
pub fn get_targets() -> impl Iterator<Item = String> {
259+
TARGETS.iter().filter_map(|t| -> Option<String> {
259260
load_specific(t)
260261
.and(Ok(t.to_string()))
261262
.ok()
262-
}))
263+
})
263264
}
264265

265266
#[cfg(test)]
@@ -419,6 +420,8 @@ supported_targets! {
419420
("aarch64-unknown-none", aarch64_unknown_none),
420421

421422
("x86_64-fortanix-unknown-sgx", x86_64_fortanix_unknown_sgx),
423+
424+
("x86_64-unknown-uefi", x86_64_unknown_uefi),
422425
}
423426

424427
/// Everything `rustc` knows about how to compile for a specific target.

src/librustc_target/spec/uefi_base.rs

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// This defines a base target-configuration for native UEFI systems. The UEFI specification has
12+
// quite detailed sections on the ABI of all the supported target architectures. In almost all
13+
// cases it simply follows what Microsoft Windows does. Hence, whenever in doubt, see the MSDN
14+
// documentation.
15+
// UEFI uses COFF/PE32+ format for binaries. All binaries must be statically linked. No dynamic
16+
// linker is supported. As native to COFF, binaries are position-dependent, but will be relocated
17+
// by the loader if the pre-chosen memory location is already in use.
18+
// UEFI forbids running code on anything but the boot-CPU. Not interrupts are allowed other than
19+
// the timer-interrupt. Device-drivers are required to use polling-based models. Furthermore, all
20+
// code runs in the same environment, no process separation is supported.
21+
22+
use spec::{LinkArgs, LinkerFlavor, LldFlavor, PanicStrategy, TargetOptions};
23+
use std::default::Default;
24+
25+
pub fn opts() -> TargetOptions {
26+
let mut pre_link_args = LinkArgs::new();
27+
28+
pre_link_args.insert(LinkerFlavor::Lld(LldFlavor::Link), vec![
29+
// Suppress the verbose logo and authorship debugging output, which would needlessly
30+
// clog any log files.
31+
"/NOLOGO".to_string(),
32+
33+
// UEFI is fully compatible to non-executable data pages. Tell the compiler that
34+
// non-code sections can be marked as non-executable, including stack pages.
35+
"/NXCOMPAT".to_string(),
36+
37+
// There is no runtime for UEFI targets, prevent them from being linked. UEFI targets
38+
// must be freestanding.
39+
"/nodefaultlib".to_string(),
40+
41+
// Non-standard subsystems have no default entry-point in PE+ files. We have to define
42+
// one. "efi_main" seems to be a common choice amongst other implementations and the
43+
// spec.
44+
"/entry:efi_main".to_string(),
45+
46+
// COFF images have a "Subsystem" field in their header, which defines what kind of
47+
// program it is. UEFI has 3 fields reserved, which are EFI_APPLICATION,
48+
// EFI_BOOT_SERVICE_DRIVER, and EFI_RUNTIME_DRIVER. We default to EFI_APPLICATION,
49+
// which is very likely the most common option. Individual projects can override this
50+
// with custom linker flags.
51+
// The subsystem-type only has minor effects on the application. It defines the memory
52+
// regions the application is loaded into (runtime-drivers need to be put into
53+
// reserved areas), as well as whether a return from the entry-point is treated as
54+
// exit (default for applications).
55+
"/subsystem:efi_application".to_string(),
56+
]);
57+
58+
TargetOptions {
59+
dynamic_linking: false,
60+
executables: true,
61+
disable_redzone: true,
62+
exe_suffix: ".efi".to_string(),
63+
allows_weak_linkage: false,
64+
panic_strategy: PanicStrategy::Abort,
65+
singlethread: true,
66+
emit_debug_gdb_scripts: false,
67+
68+
linker: Some("lld-link".to_string()),
69+
lld_flavor: LldFlavor::Link,
70+
pre_link_args,
71+
72+
.. Default::default()
73+
}
74+
}

0 commit comments

Comments
 (0)