Skip to content

Commit 661bb22

Browse files
committed
Auto merge of #42536 - frewsxcv:rollup, r=frewsxcv
Rollup of 6 pull requests - Successful merges: #42307, #42385, #42487, #42491, #42521, #42531 - Failed merges:
2 parents ae3d387 + d80ac82 commit 661bb22

File tree

9 files changed

+94
-49
lines changed

9 files changed

+94
-49
lines changed

src/bootstrap/flags.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,14 @@ Arguments:
196196
./x.py build
197197
./x.py build --stage 1
198198
199-
For a quick build with a usable compile, you can pass:
199+
For a quick build of a usable compiler, you can pass:
200200
201-
./x.py build --stage 1 src/libtest");
201+
./x.py build --stage 1 src/libtest
202+
203+
This will first build everything once (like --stage 0 without further
204+
arguments would), and then use the compiler built in stage 0 to build
205+
src/libtest and its dependencies.
206+
Once this is done, build/$ARCH/stage1 contains a usable compiler.");
202207
}
203208
"test" => {
204209
subcommand_help.push_str("\n

src/libcollections/vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
//! A contiguous growable array type with heap-allocated contents, written
12-
//! `Vec<T>` but pronounced 'vector.'
12+
//! `Vec<T>`.
1313
//!
1414
//! Vectors have `O(1)` indexing, amortized `O(1)` push (to the end) and
1515
//! `O(1)` pop (from the end).

src/libpanic_unwind/dwarf/eh.rs

+32-23
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ pub enum EHAction {
6161

6262
pub const USING_SJLJ_EXCEPTIONS: bool = cfg!(all(target_os = "ios", target_arch = "arm"));
6363

64-
pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext) -> EHAction {
64+
pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext)
65+
-> Result<EHAction, ()>
66+
{
6567
if lsda.is_null() {
66-
return EHAction::None;
68+
return Ok(EHAction::None)
6769
}
6870

6971
let func_start = context.func_start;
@@ -72,7 +74,7 @@ pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext) -> EHAction {
7274
let start_encoding = reader.read::<u8>();
7375
// base address for landing pad offsets
7476
let lpad_base = if start_encoding != DW_EH_PE_omit {
75-
read_encoded_pointer(&mut reader, context, start_encoding)
77+
read_encoded_pointer(&mut reader, context, start_encoding)?
7678
} else {
7779
func_start
7880
};
@@ -90,9 +92,9 @@ pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext) -> EHAction {
9092

9193
if !USING_SJLJ_EXCEPTIONS {
9294
while reader.ptr < action_table {
93-
let cs_start = read_encoded_pointer(&mut reader, context, call_site_encoding);
94-
let cs_len = read_encoded_pointer(&mut reader, context, call_site_encoding);
95-
let cs_lpad = read_encoded_pointer(&mut reader, context, call_site_encoding);
95+
let cs_start = read_encoded_pointer(&mut reader, context, call_site_encoding)?;
96+
let cs_len = read_encoded_pointer(&mut reader, context, call_site_encoding)?;
97+
let cs_lpad = read_encoded_pointer(&mut reader, context, call_site_encoding)?;
9698
let cs_action = reader.read_uleb128();
9799
// Callsite table is sorted by cs_start, so if we've passed the ip, we
98100
// may stop searching.
@@ -101,23 +103,23 @@ pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext) -> EHAction {
101103
}
102104
if ip < func_start + cs_start + cs_len {
103105
if cs_lpad == 0 {
104-
return EHAction::None;
106+
return Ok(EHAction::None)
105107
} else {
106108
let lpad = lpad_base + cs_lpad;
107-
return interpret_cs_action(cs_action, lpad);
109+
return Ok(interpret_cs_action(cs_action, lpad))
108110
}
109111
}
110112
}
111113
// Ip is not present in the table. This should not happen... but it does: issue #35011.
112114
// So rather than returning EHAction::Terminate, we do this.
113-
EHAction::None
115+
Ok(EHAction::None)
114116
} else {
115117
// SjLj version:
116118
// The "IP" is an index into the call-site table, with two exceptions:
117119
// -1 means 'no-action', and 0 means 'terminate'.
118120
match ip as isize {
119-
-1 => return EHAction::None,
120-
0 => return EHAction::Terminate,
121+
-1 => return Ok(EHAction::None),
122+
0 => return Ok(EHAction::Terminate),
121123
_ => (),
122124
}
123125
let mut idx = ip;
@@ -129,7 +131,7 @@ pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext) -> EHAction {
129131
// Can never have null landing pad for sjlj -- that would have
130132
// been indicated by a -1 call site index.
131133
let lpad = (cs_lpad + 1) as usize;
132-
return interpret_cs_action(cs_action, lpad);
134+
return Ok(interpret_cs_action(cs_action, lpad))
133135
}
134136
}
135137
}
@@ -144,21 +146,26 @@ fn interpret_cs_action(cs_action: u64, lpad: usize) -> EHAction {
144146
}
145147

146148
#[inline]
147-
fn round_up(unrounded: usize, align: usize) -> usize {
148-
assert!(align.is_power_of_two());
149-
(unrounded + align - 1) & !(align - 1)
149+
fn round_up(unrounded: usize, align: usize) -> Result<usize, ()> {
150+
if align.is_power_of_two() {
151+
Ok((unrounded + align - 1) & !(align - 1))
152+
} else {
153+
Err(())
154+
}
150155
}
151156

152157
unsafe fn read_encoded_pointer(reader: &mut DwarfReader,
153158
context: &EHContext,
154159
encoding: u8)
155-
-> usize {
156-
assert!(encoding != DW_EH_PE_omit);
160+
-> Result<usize, ()> {
161+
if encoding == DW_EH_PE_omit {
162+
return Err(())
163+
}
157164

158165
// DW_EH_PE_aligned implies it's an absolute pointer value
159166
if encoding == DW_EH_PE_aligned {
160-
reader.ptr = round_up(reader.ptr as usize, mem::size_of::<usize>()) as *const u8;
161-
return reader.read::<usize>();
167+
reader.ptr = round_up(reader.ptr as usize, mem::size_of::<usize>())? as *const u8;
168+
return Ok(reader.read::<usize>())
162169
}
163170

164171
let mut result = match encoding & 0x0F {
@@ -171,25 +178,27 @@ unsafe fn read_encoded_pointer(reader: &mut DwarfReader,
171178
DW_EH_PE_sdata2 => reader.read::<i16>() as usize,
172179
DW_EH_PE_sdata4 => reader.read::<i32>() as usize,
173180
DW_EH_PE_sdata8 => reader.read::<i64>() as usize,
174-
_ => panic!(),
181+
_ => return Err(()),
175182
};
176183

177184
result += match encoding & 0x70 {
178185
DW_EH_PE_absptr => 0,
179186
// relative to address of the encoded value, despite the name
180187
DW_EH_PE_pcrel => reader.ptr as usize,
181188
DW_EH_PE_funcrel => {
182-
assert!(context.func_start != 0);
189+
if context.func_start == 0 {
190+
return Err(())
191+
}
183192
context.func_start
184193
}
185194
DW_EH_PE_textrel => (*context.get_text_start)(),
186195
DW_EH_PE_datarel => (*context.get_data_start)(),
187-
_ => panic!(),
196+
_ => return Err(()),
188197
};
189198

190199
if encoding & DW_EH_PE_indirect != 0 {
191200
result = *(result as *const usize);
192201
}
193202

194-
result
203+
Ok(result)
195204
}

src/libpanic_unwind/gcc.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ unsafe extern "C" fn rust_eh_personality(version: c_int,
156156
if version != 1 {
157157
return uw::_URC_FATAL_PHASE1_ERROR;
158158
}
159-
let eh_action = find_eh_action(context);
159+
let eh_action = match find_eh_action(context) {
160+
Ok(action) => action,
161+
Err(_) => return uw::_URC_FATAL_PHASE1_ERROR,
162+
};
160163
if actions as i32 & uw::_UA_SEARCH_PHASE as i32 != 0 {
161164
match eh_action {
162165
EHAction::None |
@@ -219,7 +222,10 @@ unsafe extern "C" fn rust_eh_personality(state: uw::_Unwind_State,
219222
// _Unwind_Context in our libunwind bindings and fetch the required data from there directly,
220223
// bypassing DWARF compatibility functions.
221224

222-
let eh_action = find_eh_action(context);
225+
let eh_action = match find_eh_action(context) {
226+
Ok(action) => action,
227+
Err(_) => return uw::_URC_FAILURE,
228+
};
223229
if search_phase {
224230
match eh_action {
225231
EHAction::None |
@@ -260,7 +266,9 @@ unsafe extern "C" fn rust_eh_personality(state: uw::_Unwind_State,
260266
}
261267
}
262268

263-
unsafe fn find_eh_action(context: *mut uw::_Unwind_Context) -> EHAction {
269+
unsafe fn find_eh_action(context: *mut uw::_Unwind_Context)
270+
-> Result<EHAction, ()>
271+
{
264272
let lsda = uw::_Unwind_GetLanguageSpecificData(context) as *const u8;
265273
let mut ip_before_instr: c_int = 0;
266274
let ip = uw::_Unwind_GetIPInfo(context, &mut ip_before_instr);

src/libpanic_unwind/seh64_gnu.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,10 @@ unsafe fn find_landing_pad(dc: &c::DISPATCHER_CONTEXT) -> Option<usize> {
128128
get_data_start: &|| unimplemented!(),
129129
};
130130
match find_eh_action(dc.HandlerData, &eh_ctx) {
131-
EHAction::None => None,
132-
EHAction::Cleanup(lpad) |
133-
EHAction::Catch(lpad) => Some(lpad),
134-
EHAction::Terminate => intrinsics::abort(),
131+
Err(_) |
132+
Ok(EHAction::None) => None,
133+
Ok(EHAction::Cleanup(lpad)) |
134+
Ok(EHAction::Catch(lpad)) => Some(lpad),
135+
Ok(EHAction::Terminate) => intrinsics::abort(),
135136
}
136137
}

src/librustdoc/html/static/main.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
// Copyright 2014 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.
1+
/*!
2+
* Copyright 2014 The Rust Project Developers. See the COPYRIGHT
3+
* file at the top-level directory of this distribution and at
4+
* http://rust-lang.org/COPYRIGHT.
5+
*
6+
* Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7+
* http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8+
* <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9+
* option. This file may not be copied, modified, or distributed
10+
* except according to those terms.
11+
*/
1012

1113
/*jslint browser: true, es5: true */
1214
/*globals $: true, rootPath: true */

src/libstd/sys/unix/pipe.rs

+23-6
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
use io;
1212
use libc::{self, c_int};
1313
use mem;
14-
use sys::{cvt, cvt_r};
14+
use sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering};
1515
use sys::fd::FileDesc;
16+
use sys::{cvt, cvt_r};
1617

1718
////////////////////////////////////////////////////////////////////////////////
1819
// Anonymous pipes
@@ -21,6 +22,9 @@ use sys::fd::FileDesc;
2122
pub struct AnonPipe(FileDesc);
2223

2324
pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
25+
weak! { fn pipe2(*mut c_int, c_int) -> c_int }
26+
static INVALID: AtomicBool = ATOMIC_BOOL_INIT;
27+
2428
let mut fds = [0; 2];
2529

2630
// Unfortunately the only known way right now to create atomically set the
@@ -31,13 +35,26 @@ pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
3135
target_os = "freebsd",
3236
target_os = "linux",
3337
target_os = "netbsd",
34-
target_os = "openbsd"))
38+
target_os = "openbsd")) &&
39+
!INVALID.load(Ordering::SeqCst)
3540
{
36-
weak! { fn pipe2(*mut c_int, c_int) -> c_int }
41+
3742
if let Some(pipe) = pipe2.get() {
38-
cvt(unsafe { pipe(fds.as_mut_ptr(), libc::O_CLOEXEC) })?;
39-
return Ok((AnonPipe(FileDesc::new(fds[0])),
40-
AnonPipe(FileDesc::new(fds[1]))));
43+
// Note that despite calling a glibc function here we may still
44+
// get ENOSYS. Glibc has `pipe2` since 2.9 and doesn't try to
45+
// emulate on older kernels, so if you happen to be running on
46+
// an older kernel you may see `pipe2` as a symbol but still not
47+
// see the syscall.
48+
match cvt(unsafe { pipe(fds.as_mut_ptr(), libc::O_CLOEXEC) }) {
49+
Ok(_) => {
50+
return Ok((AnonPipe(FileDesc::new(fds[0])),
51+
AnonPipe(FileDesc::new(fds[1]))));
52+
}
53+
Err(ref e) if e.raw_os_error() == Some(libc::ENOSYS) => {
54+
INVALID.store(true, Ordering::SeqCst);
55+
}
56+
Err(e) => return Err(e),
57+
}
4158
}
4259
}
4360
cvt(unsafe { libc::pipe(fds.as_mut_ptr()) })?;

src/test/compile-fail/variadic-ffi.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
// ignore-arm stdcall isn't suppported
12+
// ignore-aarch64 stdcall isn't suppported
1213

1314
extern "stdcall" {
1415
fn printf(_: *const u8, ...); //~ ERROR: variadic function must have C or cdecl calling

src/tools/tidy/src/style.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,10 @@ fn licenseck(file: &Path, contents: &str) -> bool {
169169
lines.windows(LICENSE.lines().count()).any(|window| {
170170
let offset = if window.iter().all(|w| w.starts_with("//")) {
171171
2
172-
} else if window.iter().all(|w| w.starts_with("#")) {
172+
} else if window.iter().all(|w| w.starts_with('#')) {
173173
1
174+
} else if window.iter().all(|w| w.starts_with(" *")) {
175+
2
174176
} else {
175177
return false
176178
};

0 commit comments

Comments
 (0)