Skip to content

Commit

Permalink
Pass -Z no-codegen when invoking rustc.
Browse files Browse the repository at this point in the history
We only need crate metadata and MIR, not the built object files, so this
allows us to skip unecessary work when building `libstd`. It also
prevents us from trying to codegen the `try` panicking intrinsic, which
assumes that `libpanic_unwind` is being compiled for the target
platform. We built `libpanic_unwind` with `cfg(miri)`, which may
invalidate these assumptions (e.g. the `eh_catch_typeinfo` lang item is
no longer defined).
  • Loading branch information
Aaron1011 committed Nov 13, 2019
1 parent 7bb3052 commit c6d3179
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ Several `-Z` flags are relevant for Miri:
sets this flag per default.
* `-Zmir-emit-retag` controls whether `Retag` statements are emitted. Miri
enables this per default because it is needed for validation.
* `-Zno-codegen` makes rustc skip generating LLVM IR for MIR (though it still
writes out empty object files). This is needed to prevent rustc from trying
to codegen certain panic-related intrinsics, which will not work with a
`libpanic_unwind` compiled in `cfg(miri)` mode. It also speeds up
building our custom libstd.

Moreover, Miri recognizes some environment variables:

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ pub use crate::eval::{eval_main, create_ecx, MiriConfig};
/// Insert rustc arguments at the beginning of the argument list that Miri wants to be
/// set per default, for maximal validation power.
pub fn miri_default_args() -> &'static [&'static str] {
&["-Zalways-encode-mir", "-Zmir-emit-retag", "-Zmir-opt-level=0", "--cfg=miri"]
&["-Zalways-encode-mir", "-Zmir-emit-retag", "-Zmir-opt-level=0", "-Zno-codegen", "--cfg=miri"]
}

0 comments on commit c6d3179

Please sign in to comment.