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