Skip to content

Commit 1572bf1

Browse files
committed
Auto merge of #40091 - eddyb:rollup, r=eddyb
Rollup of 28 pull requests - Successful merges: #39859, #39864, #39888, #39903, #39905, #39914, #39945, #39950, #39953, #39961, #39980, #39988, #39993, #39995, #40019, #40020, #40022, #40024, #40025, #40026, #40027, #40031, #40035, #40037, #40038, #40064, #40069, #40086 - Failed merges: #39927, #40008, #40047
2 parents e78aa5d + 207c763 commit 1572bf1

File tree

119 files changed

+1520
-536
lines changed

Some content is hidden

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

119 files changed

+1520
-536
lines changed

src/bootstrap/bin/rustc.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ fn main() {
6868
};
6969
let stage = env::var("RUSTC_STAGE").expect("RUSTC_STAGE was not set");
7070
let sysroot = env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not set");
71+
let mut on_fail = env::var_os("RUSTC_ON_FAIL").map(|of| Command::new(of));
7172

7273
let rustc = env::var_os(rustc).unwrap_or_else(|| panic!("{:?} was not set", rustc));
7374
let libdir = env::var_os(libdir).unwrap_or_else(|| panic!("{:?} was not set", libdir));
@@ -217,9 +218,20 @@ fn main() {
217218
}
218219

219220
// Actually run the compiler!
220-
std::process::exit(match exec_cmd(&mut cmd) {
221-
Ok(s) => s.code().unwrap_or(0xfe),
222-
Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e),
221+
std::process::exit(if let Some(ref mut on_fail) = on_fail {
222+
match cmd.status() {
223+
Ok(s) if s.success() => 0,
224+
_ => {
225+
println!("\nDid not run successfully:\n{:?}\n-------------", cmd);
226+
exec_cmd(on_fail).expect("could not run the backup command");
227+
1
228+
}
229+
}
230+
} else {
231+
std::process::exit(match exec_cmd(&mut cmd) {
232+
Ok(s) => s.code().unwrap_or(0xfe),
233+
Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e),
234+
})
223235
})
224236
}
225237

src/bootstrap/bootstrap.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,12 @@ def build_bootstrap(self):
355355
env = os.environ.copy()
356356
env["CARGO_TARGET_DIR"] = build_dir
357357
env["RUSTC"] = self.rustc()
358-
env["LD_LIBRARY_PATH"] = os.path.join(self.bin_root(), "lib")
359-
env["DYLD_LIBRARY_PATH"] = os.path.join(self.bin_root(), "lib")
358+
env["LD_LIBRARY_PATH"] = os.path.join(self.bin_root(), "lib") + \
359+
(os.pathsep + env["LD_LIBRARY_PATH"]) \
360+
if "LD_LIBRARY_PATH" in env else ""
361+
env["DYLD_LIBRARY_PATH"] = os.path.join(self.bin_root(), "lib") + \
362+
(os.pathsep + env["DYLD_LIBRARY_PATH"]) \
363+
if "DYLD_LIBRARY_PATH" in env else ""
360364
env["PATH"] = os.path.join(self.bin_root(), "bin") + \
361365
os.pathsep + env["PATH"]
362366
if not os.path.isfile(self.cargo()):
@@ -485,6 +489,8 @@ def build_triple(self):
485489
ostype += 'abi64'
486490
elif cputype in {'powerpc', 'ppc', 'ppc64'}:
487491
cputype = 'powerpc'
492+
elif cputype == 'sparcv9':
493+
pass
488494
elif cputype in {'amd64', 'x86_64', 'x86-64', 'x64'}:
489495
cputype = 'x86_64'
490496
else:

src/bootstrap/flags.rs

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use step;
2828
/// Deserialized version of all flags for this compile.
2929
pub struct Flags {
3030
pub verbose: usize, // verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose
31+
pub on_fail: Option<String>,
3132
pub stage: Option<u32>,
3233
pub keep_stage: Option<u32>,
3334
pub build: String,
@@ -81,6 +82,7 @@ impl Flags {
8182
opts.optopt("", "build", "build target of the stage0 compiler", "BUILD");
8283
opts.optmulti("", "host", "host targets to build", "HOST");
8384
opts.optmulti("", "target", "target targets to build", "TARGET");
85+
opts.optopt("", "on-fail", "command to run on failure", "CMD");
8486
opts.optopt("", "stage", "stage to build", "N");
8587
opts.optopt("", "keep-stage", "stage to keep without recompiling", "N");
8688
opts.optopt("", "src", "path to the root of the rust checkout", "DIR");
@@ -283,6 +285,7 @@ To learn more about a subcommand, run `./x.py <command> -h`
283285
Flags {
284286
verbose: m.opt_count("v"),
285287
stage: stage,
288+
on_fail: m.opt_str("on-fail"),
286289
keep_stage: m.opt_str("keep-stage").map(|j| j.parse().unwrap()),
287290
build: m.opt_str("build").unwrap_or_else(|| {
288291
env::var("BUILD").unwrap()

src/bootstrap/lib.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,10 @@ impl Build {
499499
cargo.env("RUSTC_INCREMENTAL", incr_dir);
500500
}
501501

502+
if let Some(ref on_fail) = self.flags.on_fail {
503+
cargo.env("RUSTC_ON_FAIL", on_fail);
504+
}
505+
502506
let verbose = cmp::max(self.config.verbose, self.flags.verbose);
503507
cargo.env("RUSTC_VERBOSE", format!("{}", verbose));
504508

@@ -828,17 +832,6 @@ impl Build {
828832
if target.contains("apple-darwin") {
829833
base.push("-stdlib=libc++".into());
830834
}
831-
// This is a hack, because newer binutils broke things on some vms/distros
832-
// (i.e., linking against unknown relocs disabled by the following flag)
833-
// See: https://github.com/rust-lang/rust/issues/34978
834-
match target {
835-
"i586-unknown-linux-gnu" |
836-
"i686-unknown-linux-musl" |
837-
"x86_64-unknown-linux-musl" => {
838-
base.push("-Wa,-mrelax-relocations=no".into());
839-
},
840-
_ => {},
841-
}
842835
return base
843836
}
844837

src/ci/docker/linux-tested-targets/Dockerfile

+8
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ ENV RUST_CONFIGURE_ARGS \
3434
--musl-root-x86_64=/musl-x86_64 \
3535
--musl-root-i686=/musl-i686
3636

37+
# Newer binutils broke things on some vms/distros (i.e., linking against
38+
# unknown relocs disabled by the following flag), so we need to go out of our
39+
# way to produce "super compatible" binaries.
40+
#
41+
# See: https://github.com/rust-lang/rust/issues/34978
42+
ENV CFLAGS_i686_unknown_linux_gnu=-Wa,-mrelax-relocations=no \
43+
CFLAGS_x86_64_unknown_linux_gnu=-Wa,-mrelax-relocations=no
44+
3745
ENV SCRIPT \
3846
python2.7 ../x.py test \
3947
--target x86_64-unknown-linux-musl \

src/ci/docker/linux-tested-targets/build-musl.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111

1212
set -ex
1313

14-
export CFLAGS="-fPIC"
14+
# We need to mitigate rust-lang/rust#34978 when compiling musl itself as well
15+
export CFLAGS="-fPIC -Wa,-mrelax-relocations=no"
16+
export CXXFLAGS="-Wa,-mrelax-relocations=no"
17+
1518
MUSL=musl-1.1.14
1619
curl https://www.musl-libc.org/releases/$MUSL.tar.gz | tar xzf -
1720
cd $MUSL

src/doc/nomicon/src/phantom-data.md

+20-2
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,23 @@ standard library made a utility for itself called `Unique<T>` which:
8282

8383
* wraps a `*const T` for variance
8484
* includes a `PhantomData<T>`
85-
* auto-derives Send/Sync as if T was contained
86-
* marks the pointer as NonZero for the null-pointer optimization
85+
* auto-derives `Send`/`Sync` as if T was contained
86+
* marks the pointer as `NonZero` for the null-pointer optimization
87+
88+
## Table of `PhantomData` patterns
89+
90+
Here’s a table of all the wonderful ways `PhantomData` could be used:
91+
92+
| Phantom type | `'a` | `T` |
93+
|-----------------------------|-----------|---------------------------|
94+
| `PhantomData<T>` | - | variant (with drop check) |
95+
| `PhantomData<&'a T>` | variant | variant |
96+
| `PhantomData<&'a mut T>` | variant | invariant |
97+
| `PhantomData<*const T>` | - | variant |
98+
| `PhantomData<*mut T>` | - | invariant |
99+
| `PhantomData<fn(T)>` | - | contravariant (*) |
100+
| `PhantomData<fn() -> T>` | - | variant |
101+
| `PhantomData<fn(T) -> T>` | - | invariant |
102+
| `PhantomData<Cell<&'a ()>>` | invariant | - |
103+
104+
(*) If contravariance gets scrapped, this would be invariant.

src/libcompiler_builtins/build.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,15 @@ fn main() {
9292
// compiler-rt's build system already
9393
cfg.flag("-fno-builtin");
9494
cfg.flag("-fvisibility=hidden");
95-
cfg.flag("-fomit-frame-pointer");
95+
// Accepted practice on Solaris is to never omit frame pointer so that
96+
// system observability tools work as expected. In addition, at least
97+
// on Solaris, -fomit-frame-pointer on sparcv9 appears to generate
98+
// references to data outside of the current stack frame. A search of
99+
// the gcc bug database provides a variety of issues surrounding
100+
// -fomit-frame-pointer on non-x86 platforms.
101+
if !target.contains("solaris") && !target.contains("sparc") {
102+
cfg.flag("-fomit-frame-pointer");
103+
}
96104
cfg.flag("-ffreestanding");
97105
cfg.define("VISIBILITY_HIDDEN", None);
98106
}

src/librustc/cfg/construct.rs

+23-13
Original file line numberDiff line numberDiff line change
@@ -220,15 +220,24 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
220220
// Note that `break` and `continue` statements
221221
// may cause additional edges.
222222

223-
// Is the condition considered part of the loop?
224223
let loopback = self.add_dummy_node(&[pred]); // 1
225-
let cond_exit = self.expr(&cond, loopback); // 2
226-
let expr_exit = self.add_ast_node(expr.id, &[cond_exit]); // 3
224+
225+
// Create expr_exit without pred (cond_exit)
226+
let expr_exit = self.add_ast_node(expr.id, &[]); // 3
227+
228+
// The LoopScope needs to be on the loop_scopes stack while evaluating the
229+
// condition and the body of the loop (both can break out of the loop)
227230
self.loop_scopes.push(LoopScope {
228231
loop_id: expr.id,
229232
continue_index: loopback,
230233
break_index: expr_exit
231234
});
235+
236+
let cond_exit = self.expr(&cond, loopback); // 2
237+
238+
// Add pred (cond_exit) to expr_exit
239+
self.add_contained_edge(cond_exit, expr_exit);
240+
232241
let body_exit = self.block(&body, cond_exit); // 4
233242
self.add_contained_edge(body_exit, loopback); // 5
234243
self.loop_scopes.pop();
@@ -294,17 +303,17 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
294303
self.add_unreachable_node()
295304
}
296305

297-
hir::ExprBreak(label, ref opt_expr) => {
306+
hir::ExprBreak(destination, ref opt_expr) => {
298307
let v = self.opt_expr(opt_expr, pred);
299-
let loop_scope = self.find_scope(expr, label);
308+
let loop_scope = self.find_scope(expr, destination);
300309
let b = self.add_ast_node(expr.id, &[v]);
301310
self.add_exiting_edge(expr, b,
302311
loop_scope, loop_scope.break_index);
303312
self.add_unreachable_node()
304313
}
305314

306-
hir::ExprAgain(label) => {
307-
let loop_scope = self.find_scope(expr, label);
315+
hir::ExprAgain(destination) => {
316+
let loop_scope = self.find_scope(expr, destination);
308317
let a = self.add_ast_node(expr.id, &[pred]);
309318
self.add_exiting_edge(expr, a,
310319
loop_scope, loop_scope.continue_index);
@@ -579,17 +588,18 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
579588

580589
fn find_scope(&self,
581590
expr: &hir::Expr,
582-
label: Option<hir::Label>) -> LoopScope {
583-
match label {
584-
None => *self.loop_scopes.last().unwrap(),
585-
Some(label) => {
591+
destination: hir::Destination) -> LoopScope {
592+
593+
match destination.loop_id.into() {
594+
Ok(loop_id) => {
586595
for l in &self.loop_scopes {
587-
if l.loop_id == label.loop_id {
596+
if l.loop_id == loop_id {
588597
return *l;
589598
}
590599
}
591-
span_bug!(expr.span, "no loop scope for id {}", label.loop_id);
600+
span_bug!(expr.span, "no loop scope for id {}", loop_id);
592601
}
602+
Err(err) => span_bug!(expr.span, "loop scope error: {}", err)
593603
}
594604
}
595605
}

src/librustc/hir/def.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use hir::def_id::DefId;
1212
use util::nodemap::NodeMap;
1313
use syntax::ast;
14+
use syntax::ext::base::MacroKind;
1415
use hir;
1516

1617
#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
@@ -53,7 +54,7 @@ pub enum Def {
5354
Label(ast::NodeId),
5455

5556
// Macro namespace
56-
Macro(DefId),
57+
Macro(DefId, MacroKind),
5758

5859
// Both namespaces
5960
Err,
@@ -141,7 +142,7 @@ impl Def {
141142
Def::Variant(id) | Def::VariantCtor(id, ..) | Def::Enum(id) | Def::TyAlias(id) |
142143
Def::AssociatedTy(id) | Def::TyParam(id) | Def::Struct(id) | Def::StructCtor(id, ..) |
143144
Def::Union(id) | Def::Trait(id) | Def::Method(id) | Def::Const(id) |
144-
Def::AssociatedConst(id) | Def::Local(id) | Def::Upvar(id, ..) | Def::Macro(id) => {
145+
Def::AssociatedConst(id) | Def::Local(id) | Def::Upvar(id, ..) | Def::Macro(id, ..) => {
145146
id
146147
}
147148

src/librustc/hir/intravisit.rs

+14-10
Original file line numberDiff line numberDiff line change
@@ -1006,18 +1006,22 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
10061006
ExprPath(ref qpath) => {
10071007
visitor.visit_qpath(qpath, expression.id, expression.span);
10081008
}
1009-
ExprBreak(None, ref opt_expr) => {
1009+
ExprBreak(label, ref opt_expr) => {
1010+
label.ident.map(|ident| {
1011+
if let Ok(loop_id) = label.loop_id.into() {
1012+
visitor.visit_def_mention(Def::Label(loop_id));
1013+
}
1014+
visitor.visit_name(ident.span, ident.node.name);
1015+
});
10101016
walk_list!(visitor, visit_expr, opt_expr);
10111017
}
1012-
ExprBreak(Some(label), ref opt_expr) => {
1013-
visitor.visit_def_mention(Def::Label(label.loop_id));
1014-
visitor.visit_name(label.span, label.name);
1015-
walk_list!(visitor, visit_expr, opt_expr);
1016-
}
1017-
ExprAgain(None) => {}
1018-
ExprAgain(Some(label)) => {
1019-
visitor.visit_def_mention(Def::Label(label.loop_id));
1020-
visitor.visit_name(label.span, label.name);
1018+
ExprAgain(label) => {
1019+
label.ident.map(|ident| {
1020+
if let Ok(loop_id) = label.loop_id.into() {
1021+
visitor.visit_def_mention(Def::Label(loop_id));
1022+
}
1023+
visitor.visit_name(ident.span, ident.node.name);
1024+
});
10211025
}
10221026
ExprRet(ref optional_expression) => {
10231027
walk_list!(visitor, visit_expr, optional_expression);

0 commit comments

Comments
 (0)