@@ -165,43 +165,51 @@ up the sysroot. If you are using `miri` (the Miri driver) directly, see
165165## Miri ` -Z ` flags and environment variables
166166[ miri-flags ] : #miri--z-flags-and-environment-variables
167167
168- Several ` -Z ` flags are relevant for Miri:
169-
170- * ` -Zmiri-seed=<hex> ` is a custom ` -Z ` flag added by Miri. It configures the
171- seed of the RNG that Miri uses to resolve non-determinism. This RNG is used
172- to pick base addresses for allocations. When isolation is enabled (the default),
173- this is also used to emulate system entropy. The default seed is 0.
174- ** NOTE** : This entropy is not good enough for cryptographic use! Do not
175- generate secret keys in Miri or perform other kinds of cryptographic
176- operations that rely on proper random numbers.
177- * ` -Zmiri-disable-validation ` disables enforcing validity invariants, which are
178- enforced by default. This is mostly useful for debugging. It means Miri will
179- miss bugs in your program. However, this can also help to make Miri run
180- faster.
168+ Miri adds its own set of ` -Z ` flags:
169+
170+ * ` -Zmiri-disable-alignment-check ` disables checking pointer alignment. This is
171+ useful to avoid [ false positives] [ alignment-false-positives ] . However, setting
172+ this flag means Miri could miss bugs in your program.
181173* ` -Zmiri-disable-stacked-borrows ` disables checking the experimental
182174 [ Stacked Borrows] aliasing rules. This can make Miri run faster, but it also
183175 means no aliasing violations will be detected.
176+ * ` -Zmiri-disable-validation ` disables enforcing validity invariants, which are
177+ enforced by default. This is mostly useful to focus on other failures (such
178+ as out-of-bounds accesses) first. Setting this flag means Miri will miss bugs
179+ in your program. However, this can also help to make Miri run faster.
184180* ` -Zmiri-disable-isolation ` disables host isolation. As a consequence,
185181 the program has access to host resources such as environment variables, file
186182 systems, and randomness.
187- * ` -Zmiri-ignore-leaks ` disables the memory leak checker.
188183* ` -Zmiri-env-exclude=<var> ` keeps the ` var ` environment variable isolated from
189- the host. Can be used multiple times to exclude several variables. The ` TERM `
190- environment variable is excluded by default.
184+ the host so that it cannot be accessed by the program. Can be used multiple
185+ times to exclude several variables. On Windows, the ` TERM ` environment
186+ variable is excluded by default.
187+ * ` -Zmiri-ignore-leaks ` disables the memory leak checker.
188+ * ` -Zmiri-seed=<hex> ` configures the seed of the RNG that Miri uses to resolve
189+ non-determinism. This RNG is used to pick base addresses for allocations.
190+ When isolation is enabled (the default), this is also used to emulate system
191+ entropy. The default seed is 0. ** NOTE** : This entropy is not good enough
192+ for cryptographic use! Do not generate secret keys in Miri or perform other
193+ kinds of cryptographic operations that rely on proper random numbers.
194+ * ` -Zmiri-track-alloc-id=<id> ` shows a backtrace when the given allocation is
195+ being allocated. This helps in debugging memory leaks.
196+ * ` -Zmiri-track-pointer-tag=<tag> ` shows a backtrace when the given pointer tag
197+ is popped from a borrow stack (which is where the tag becomes invalid and any
198+ future use of it will error). This helps you in finding out why UB is
199+ happening and where in your code would be a good place to look for it.
200+
201+ [ alignment-false-positives ] : https://github.com/rust-lang/miri/issues/1074
202+
203+ Some native rustc ` -Z ` flags are also very relevant for Miri:
204+
191205* ` -Zmir-opt-level ` controls how many MIR optimizations are performed. Miri
192206 overrides the default to be ` 0 ` ; be advised that using any higher level can
193207 make Miri miss bugs in your program because they got optimized away.
194208* ` -Zalways-encode-mir ` makes rustc dump MIR even for completely monomorphic
195209 functions. This is needed so that Miri can execute such functions, so Miri
196210 sets this flag per default.
197211* ` -Zmir-emit-retag ` controls whether ` Retag ` statements are emitted. Miri
198- enables this per default because it is needed for validation.
199- * ` -Zmiri-track-pointer-tag=<tag> ` shows a backtrace when the given pointer tag
200- is popped from a borrow stack (which is where the tag becomes invalid and any
201- future use of it will error). This helps you in finding out why UB is
202- happening and where in your code would be a good place to look for it.
203- * ` -Zmiri-track-alloc-id=<id> ` shows a backtrace when the given allocation is
204- being allocated. This helps in debugging memory leaks.
212+ enables this per default because it is needed for [ Stacked Borrows] .
205213
206214Moreover, Miri recognizes some environment variables:
207215
0 commit comments