Skip to content

Commit f3f9de7

Browse files
committed
Add -Z orbit for forcing MIR for everything, unless #[rustc_no_mir] is used.
1 parent b3747a5 commit f3f9de7

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

configure

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ opt dist-host-only 0 "only install bins for the host architecture"
607607
opt inject-std-version 1 "inject the current compiler version of libstd into programs"
608608
opt llvm-version-check 1 "check if the LLVM version is supported, build anyway"
609609
opt rustbuild 0 "use the rust and cargo based build system"
610+
opt orbit 0 "get MIR where it belongs - everywhere; most importantly, in orbit"
610611

611612
# Optimization and debugging options. These may be overridden by the release channel, etc.
612613
opt_nosave optimize 1 "build optimized rust code"
@@ -713,6 +714,8 @@ if [ -n "$CFG_ENABLE_DEBUG_ASSERTIONS" ]; then putvar CFG_ENABLE_DEBUG_ASSERTION
713714
if [ -n "$CFG_ENABLE_DEBUGINFO" ]; then putvar CFG_ENABLE_DEBUGINFO; fi
714715
if [ -n "$CFG_ENABLE_DEBUG_JEMALLOC" ]; then putvar CFG_ENABLE_DEBUG_JEMALLOC; fi
715716

717+
if [ -n "$CFG_ENABLE_ORBIT" ]; then putvar CFG_ENABLE_ORBIT; fi
718+
716719
# A magic value that allows the compiler to use unstable features
717720
# during the bootstrap even when doing so would normally be an error
718721
# because of feature staging or because the build turns on

mk/main.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ ifdef CFG_ENABLE_DEBUGINFO
134134
CFG_RUSTC_FLAGS += -g
135135
endif
136136

137+
ifdef CFG_ENABLE_ORBIT
138+
$(info cfg: launching MIR (CFG_ENABLE_ORBIT))
139+
CFG_RUSTC_FLAGS += -Z orbit
140+
endif
141+
137142
ifdef SAVE_TEMPS
138143
CFG_RUSTC_FLAGS += --save-temps
139144
endif

src/librustc/session/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
659659
"print the result of the translation item collection pass"),
660660
mir_opt_level: Option<usize> = (None, parse_opt_uint,
661661
"set the MIR optimization level (0-3)"),
662+
orbit: bool = (false, parse_bool,
663+
"get MIR where it belongs - everywhere; most importantly, in orbit"),
662664
}
663665

664666
pub fn default_lib_output() -> CrateType {

src/librustc_trans/trans/base.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,9 @@ impl<'blk, 'tcx> FunctionContext<'blk, 'tcx> {
14321432
};
14331433

14341434
let check_attrs = |attrs: &[ast::Attribute]| {
1435-
attrs.iter().any(|item| item.check_name("rustc_mir"))
1435+
let default_to_mir = ccx.sess().opts.debugging_opts.orbit;
1436+
let invert = if default_to_mir { "rustc_no_mir" } else { "rustc_mir" };
1437+
default_to_mir ^ attrs.iter().any(|item| item.check_name(invert))
14361438
};
14371439

14381440
let use_mir = if let Some(id) = local_id {
@@ -1464,13 +1466,13 @@ impl<'blk, 'tcx> FunctionContext<'blk, 'tcx> {
14641466
};
14651467

14661468
FunctionContext {
1469+
needs_ret_allocas: nested_returns && mir.is_none(),
14671470
mir: mir,
14681471
llfn: llfndecl,
14691472
llretslotptr: Cell::new(None),
14701473
param_env: ccx.tcx().empty_parameter_environment(),
14711474
alloca_insert_pt: Cell::new(None),
14721475
llreturn: Cell::new(None),
1473-
needs_ret_allocas: nested_returns,
14741476
landingpad_alloca: Cell::new(None),
14751477
lllocals: RefCell::new(NodeMap()),
14761478
llupvars: RefCell::new(NodeMap()),

src/libsyntax/feature_gate.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,14 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeGat
347347
"the `#[rustc_move_fragments]` attribute \
348348
is just used for rustc unit tests \
349349
and will never be stable")),
350-
("rustc_mir", Normal, Gated("rustc_attrs",
351-
"the `#[rustc_mir]` attribute \
352-
is just used for rustc unit tests \
353-
and will never be stable")),
350+
("rustc_mir", Whitelisted, Gated("rustc_attrs",
351+
"the `#[rustc_mir]` attribute \
352+
is just used for rustc unit tests \
353+
and will never be stable")),
354+
("rustc_no_mir", Whitelisted, Gated("rustc_attrs",
355+
"the `#[rustc_no_mir]` attribute \
356+
is just used to make tests pass \
357+
and will never be stable")),
354358

355359
("allow_internal_unstable", Normal, Gated("allow_internal_unstable",
356360
EXPLAIN_ALLOW_INTERNAL_UNSTABLE)),

0 commit comments

Comments
 (0)