Skip to content

Commit d9bd4b2

Browse files
committed
Auto merge of #63228 - Centril:rollup-x39p5ga, r=Centril
Rollup of 7 pull requests Successful merges: - #63107 (Added support for armv7-unknown-linux-gnueabi/musleabi) - #63121 (On `format!()` arg count mismatch provide extra info) - #63196 (build_helper: try less confusing method names) - #63206 (remove unsupported test case) - #63208 (Round generator sizes to a multiple of their alignment) - #63212 (Pretty print attributes in `print_arg`) - #63215 (Clarify semantics of mem::zeroed) Failed merges: r? @ghost
2 parents b0e40bf + 4520a39 commit d9bd4b2

File tree

24 files changed

+709
-288
lines changed

24 files changed

+709
-288
lines changed

src/bootstrap/configure.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ def v(*args):
125125
"arm-unknown-linux-musleabihf install directory")
126126
v("musl-root-armv5te", "target.armv5te-unknown-linux-musleabi.musl-root",
127127
"armv5te-unknown-linux-musleabi install directory")
128-
v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root",
128+
v("musl-root-armv7", "target.armv7-unknown-linux-musleabi.musl-root",
129+
"armv7-unknown-linux-musleabi install directory")
130+
v("musl-root-armv7hf", "target.armv7-unknown-linux-musleabihf.musl-root",
129131
"armv7-unknown-linux-musleabihf install directory")
130132
v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root",
131133
"aarch64-unknown-linux-musl install directory")

src/bootstrap/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ use std::os::unix::fs::symlink as symlink_file;
125125
use std::os::windows::fs::symlink_file;
126126

127127
use build_helper::{
128-
mtime, output, run_silent, run_suppressed, t, try_run_silent, try_run_suppressed,
128+
mtime, output, run, run_suppressed, t, try_run, try_run_suppressed,
129129
};
130130
use filetime::FileTime;
131131

@@ -682,7 +682,7 @@ impl Build {
682682
fn run(&self, cmd: &mut Command) {
683683
if self.config.dry_run { return; }
684684
self.verbose(&format!("running: {:?}", cmd));
685-
run_silent(cmd)
685+
run(cmd)
686686
}
687687

688688
/// Runs a command, printing out nice contextual information if it fails.
@@ -698,7 +698,7 @@ impl Build {
698698
fn try_run(&self, cmd: &mut Command) -> bool {
699699
if self.config.dry_run { return true; }
700700
self.verbose(&format!("running: {:?}", cmd));
701-
try_run_silent(cmd)
701+
try_run(cmd)
702702
}
703703

704704
/// Runs a command, printing out nice contextual information if it fails.

src/bootstrap/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,7 @@ impl Step for RustcGuide {
15271527
fn run(self, builder: &Builder<'_>) {
15281528
let src = builder.src.join("src/doc/rustc-guide");
15291529
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
1530-
try_run_quiet(builder, rustbook_cmd.arg("linkcheck").arg(&src));
1530+
try_run(builder, rustbook_cmd.arg("linkcheck").arg(&src));
15311531
}
15321532
}
15331533

src/build_helper/lib.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,19 @@ pub fn restore_library_path() {
4545
}
4646
}
4747

48-
pub fn run(cmd: &mut Command) {
48+
/// Run the command, printing what we are running.
49+
pub fn run_verbose(cmd: &mut Command) {
4950
println!("running: {:?}", cmd);
50-
run_silent(cmd);
51+
run(cmd);
5152
}
5253

53-
pub fn run_silent(cmd: &mut Command) {
54-
if !try_run_silent(cmd) {
54+
pub fn run(cmd: &mut Command) {
55+
if !try_run(cmd) {
5556
std::process::exit(1);
5657
}
5758
}
5859

59-
pub fn try_run_silent(cmd: &mut Command) -> bool {
60+
pub fn try_run(cmd: &mut Command) -> bool {
6061
let status = match cmd.status() {
6162
Ok(status) => status,
6263
Err(e) => fail(&format!(

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ RUN env \
6464
env \
6565
CC=arm-linux-gnueabihf-gcc CFLAGS="-march=armv7-a" \
6666
CXX=arm-linux-gnueabihf-g++ CXXFLAGS="-march=armv7-a" \
67-
bash musl.sh armv7 && \
67+
bash musl.sh armv7hf && \
6868
env \
6969
CC=aarch64-linux-gnu-gcc \
7070
CXX=aarch64-linux-gnu-g++ \
@@ -137,7 +137,7 @@ ENV RUST_CONFIGURE_ARGS \
137137
--musl-root-armv5te=/musl-armv5te \
138138
--musl-root-arm=/musl-arm \
139139
--musl-root-armhf=/musl-armhf \
140-
--musl-root-armv7=/musl-armv7 \
140+
--musl-root-armv7hf=/musl-armv7hf \
141141
--musl-root-aarch64=/musl-aarch64 \
142142
--musl-root-mips=/musl-mips \
143143
--musl-root-mipsel=/musl-mipsel \

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

+28-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ RUN sed -i 's/^# deb-src/deb-src/' /etc/apt/sources.list
88

99
RUN apt-get update && apt-get build-dep -y clang llvm && apt-get install -y --no-install-recommends \
1010
build-essential \
11-
gcc-multilib \
11+
# gcc-multilib can not be installed together with gcc-arm-linux-gnueabi
12+
gcc-7-multilib \
1213
libedit-dev \
1314
libgmp-dev \
1415
libisl-dev \
@@ -21,11 +22,20 @@ RUN apt-get update && apt-get build-dep -y clang llvm && apt-get install -y --no
2122
unzip \
2223
# Needed for apt-key to work:
2324
dirmngr \
24-
gpg-agent
25+
gpg-agent \
26+
g++-7-arm-linux-gnueabi
2527

2628
RUN apt-key adv --batch --yes --keyserver keyserver.ubuntu.com --recv-keys 74DA7924C5513486
2729
RUN add-apt-repository -y 'deb http://apt.dilos.org/dilos dilos2 main'
2830

31+
WORKDIR /build
32+
COPY scripts/musl.sh /build
33+
RUN env \
34+
CC=arm-linux-gnueabi-gcc-7 CFLAGS="-march=armv7-a" \
35+
CXX=arm-linux-gnueabi-g++-7 CXXFLAGS="-march=armv7-a" \
36+
bash musl.sh armv7 && \
37+
rm -rf /build/*
38+
2939
WORKDIR /tmp
3040
COPY dist-various-2/shared.sh /tmp/
3141
COPY dist-various-2/build-cloudabi-toolchain.sh /tmp/
@@ -58,7 +68,11 @@ ENV \
5868
CXX_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-g++ \
5969
AR_x86_64_sun_solaris=x86_64-sun-solaris2.10-ar \
6070
CC_x86_64_sun_solaris=x86_64-sun-solaris2.10-gcc \
61-
CXX_x86_64_sun_solaris=x86_64-sun-solaris2.10-g++
71+
CXX_x86_64_sun_solaris=x86_64-sun-solaris2.10-g++ \
72+
CC_armv7_unknown_linux_gnueabi=arm-linux-gnueabi-gcc-7 \
73+
CXX_armv7_unknown_linux_gnueabi=arm-linux-gnueabi-g++-7 \
74+
CC=gcc-7 \
75+
CXX=g++-7
6276

6377
ENV CARGO_TARGET_X86_64_FUCHSIA_AR /usr/local/bin/llvm-ar
6478
ENV CARGO_TARGET_X86_64_FUCHSIA_RUSTFLAGS \
@@ -81,9 +95,19 @@ ENV TARGETS=$TARGETS,x86_64-unknown-linux-gnux32
8195
ENV TARGETS=$TARGETS,x86_64-unknown-cloudabi
8296
ENV TARGETS=$TARGETS,x86_64-fortanix-unknown-sgx
8397
ENV TARGETS=$TARGETS,nvptx64-nvidia-cuda
98+
ENV TARGETS=$TARGETS,armv7-unknown-linux-gnueabi
99+
ENV TARGETS=$TARGETS,armv7-unknown-linux-musleabi
84100

85101
ENV X86_FORTANIX_SGX_LIBS="/x86_64-fortanix-unknown-sgx/lib/"
86102

103+
# As per https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1300211
104+
# we need asm in the search path for gcc-7 (for gnux32) but not in the search path of the
105+
# cross compilers.
106+
# Luckily one of the folders is /usr/local/include so symlink /usr/include/asm-generic there
107+
RUN ln -s /usr/include/asm-generic /usr/local/include/asm
108+
87109
ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --disable-docs \
88-
--set target.wasm32-wasi.wasi-root=/wasm32-wasi
110+
--set target.wasm32-wasi.wasi-root=/wasm32-wasi \
111+
--musl-root-armv7=/musl-armv7
112+
89113
ENV SCRIPT python2.7 ../x.py dist --target $TARGETS

src/libcore/mem/mod.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -414,17 +414,20 @@ pub const fn needs_drop<T>() -> bool {
414414
intrinsics::needs_drop::<T>()
415415
}
416416

417-
/// Creates a value whose bytes are all zero.
417+
/// Returns the value of type `T` represented by the all-zero byte-pattern.
418418
///
419-
/// This has the same effect as [`MaybeUninit::zeroed().assume_init()`][zeroed].
420-
/// It is useful for FFI sometimes, but should generally be avoided.
419+
/// This means that, for example, the padding byte in `(u8, u16)` is not
420+
/// necessarily zeroed.
421421
///
422422
/// There is no guarantee that an all-zero byte-pattern represents a valid value of
423423
/// some type `T`. For example, the all-zero byte-pattern is not a valid value
424424
/// for reference types (`&T` and `&mut T`). Using `zeroed` on such types
425425
/// causes immediate [undefined behavior][ub] because [the Rust compiler assumes][inv]
426426
/// that there always is a valid value in a variable it considers initialized.
427427
///
428+
/// This has the same effect as [`MaybeUninit::zeroed().assume_init()`][zeroed].
429+
/// It is useful for FFI sometimes, but should generally be avoided.
430+
///
428431
/// [zeroed]: union.MaybeUninit.html#method.zeroed
429432
/// [ub]: ../../reference/behavior-considered-undefined.html
430433
/// [inv]: union.MaybeUninit.html#initialization-invariant

src/libfmt_macros/lib.rs

+48-24
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,20 @@ pub struct Argument<'a> {
5656
/// Specification for the formatting of an argument in the format string.
5757
#[derive(Copy, Clone, PartialEq)]
5858
pub struct FormatSpec<'a> {
59-
/// Optionally specified character to fill alignment with
59+
/// Optionally specified character to fill alignment with.
6060
pub fill: Option<char>,
61-
/// Optionally specified alignment
61+
/// Optionally specified alignment.
6262
pub align: Alignment,
63-
/// Packed version of various flags provided
63+
/// Packed version of various flags provided.
6464
pub flags: u32,
65-
/// The integer precision to use
65+
/// The integer precision to use.
6666
pub precision: Count,
67-
/// The string width requested for the resulting format
67+
/// The span of the precision formatting flag (for diagnostics).
68+
pub precision_span: Option<InnerSpan>,
69+
/// The string width requested for the resulting format.
6870
pub width: Count,
71+
/// The span of the width formatting flag (for diagnostics).
72+
pub width_span: Option<InnerSpan>,
6973
/// The descriptor string representing the name of the format desired for
7074
/// this argument, this can be empty or any number of characters, although
7175
/// it is required to be one word.
@@ -282,19 +286,24 @@ impl<'a> Parser<'a> {
282286
}
283287

284288
/// Optionally consumes the specified character. If the character is not at
285-
/// the current position, then the current iterator isn't moved and false is
286-
/// returned, otherwise the character is consumed and true is returned.
289+
/// the current position, then the current iterator isn't moved and `false` is
290+
/// returned, otherwise the character is consumed and `true` is returned.
287291
fn consume(&mut self, c: char) -> bool {
288-
if let Some(&(_, maybe)) = self.cur.peek() {
292+
self.consume_pos(c).is_some()
293+
}
294+
295+
/// Optionally consumes the specified character. If the character is not at
296+
/// the current position, then the current iterator isn't moved and `None` is
297+
/// returned, otherwise the character is consumed and the current position is
298+
/// returned.
299+
fn consume_pos(&mut self, c: char) -> Option<usize> {
300+
if let Some(&(pos, maybe)) = self.cur.peek() {
289301
if c == maybe {
290302
self.cur.next();
291-
true
292-
} else {
293-
false
303+
return Some(pos);
294304
}
295-
} else {
296-
false
297305
}
306+
None
298307
}
299308

300309
fn to_span_index(&self, pos: usize) -> InnerOffset {
@@ -462,7 +471,9 @@ impl<'a> Parser<'a> {
462471
align: AlignUnknown,
463472
flags: 0,
464473
precision: CountImplied,
474+
precision_span: None,
465475
width: CountImplied,
476+
width_span: None,
466477
ty: &self.input[..0],
467478
};
468479
if !self.consume(':') {
@@ -499,6 +510,7 @@ impl<'a> Parser<'a> {
499510
}
500511
// Width and precision
501512
let mut havewidth = false;
513+
502514
if self.consume('0') {
503515
// small ambiguity with '0$' as a format string. In theory this is a
504516
// '0' flag and then an ill-formatted format string with just a '$'
@@ -512,17 +524,28 @@ impl<'a> Parser<'a> {
512524
}
513525
}
514526
if !havewidth {
515-
spec.width = self.count();
527+
let width_span_start = if let Some((pos, _)) = self.cur.peek() {
528+
*pos
529+
} else {
530+
0
531+
};
532+
let (w, sp) = self.count(width_span_start);
533+
spec.width = w;
534+
spec.width_span = sp;
516535
}
517-
if self.consume('.') {
518-
if self.consume('*') {
536+
if let Some(start) = self.consume_pos('.') {
537+
if let Some(end) = self.consume_pos('*') {
519538
// Resolve `CountIsNextParam`.
520539
// We can do this immediately as `position` is resolved later.
521540
let i = self.curarg;
522541
self.curarg += 1;
523542
spec.precision = CountIsParam(i);
543+
spec.precision_span =
544+
Some(self.to_span_index(start).to(self.to_span_index(end + 1)));
524545
} else {
525-
spec.precision = self.count();
546+
let (p, sp) = self.count(start);
547+
spec.precision = p;
548+
spec.precision_span = sp;
526549
}
527550
}
528551
// Optional radix followed by the actual format specifier
@@ -551,24 +574,25 @@ impl<'a> Parser<'a> {
551574
/// Parses a Count parameter at the current position. This does not check
552575
/// for 'CountIsNextParam' because that is only used in precision, not
553576
/// width.
554-
fn count(&mut self) -> Count {
577+
fn count(&mut self, start: usize) -> (Count, Option<InnerSpan>) {
555578
if let Some(i) = self.integer() {
556-
if self.consume('$') {
557-
CountIsParam(i)
579+
if let Some(end) = self.consume_pos('$') {
580+
let span = self.to_span_index(start).to(self.to_span_index(end + 1));
581+
(CountIsParam(i), Some(span))
558582
} else {
559-
CountIs(i)
583+
(CountIs(i), None)
560584
}
561585
} else {
562586
let tmp = self.cur.clone();
563587
let word = self.word();
564588
if word.is_empty() {
565589
self.cur = tmp;
566-
CountImplied
590+
(CountImplied, None)
567591
} else if self.consume('$') {
568-
CountIsName(Symbol::intern(word))
592+
(CountIsName(Symbol::intern(word)), None)
569593
} else {
570594
self.cur = tmp;
571-
CountImplied
595+
(CountImplied, None)
572596
}
573597
}
574598
}

0 commit comments

Comments
 (0)