@@ -18,6 +18,8 @@ pub struct MiriConfig {
1818 pub validate : bool ,
1919 /// Determines if communication with the host environment is enabled.
2020 pub communicate : bool ,
21+ /// Determines if memory leaks should be ignored.
22+ pub ignore_leaks : bool ,
2123 /// Environment variables that should always be isolated from the host.
2224 pub excluded_env_vars : Vec < String > ,
2325 /// Command-line arguments passed to the interpreted program.
@@ -169,6 +171,11 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
169171/// Returns `Some(return_code)` if program executed completed.
170172/// Returns `None` if an evaluation error occured.
171173pub fn eval_main < ' tcx > ( tcx : TyCtxt < ' tcx > , main_id : DefId , config : MiriConfig ) -> Option < i64 > {
174+ // FIXME: We always ignore leaks on some platforms where we do not
175+ // correctly implement TLS destructors.
176+ let target_os = tcx. sess . target . target . target_os . to_lowercase ( ) ;
177+ let ignore_leaks = config. ignore_leaks || target_os == "windows" || target_os == "macos" ;
178+
172179 let ( mut ecx, ret_place) = match create_ecx ( tcx, main_id, config) {
173180 Ok ( v) => v,
174181 Err ( mut err) => {
@@ -190,10 +197,6 @@ pub fn eval_main<'tcx>(tcx: TyCtxt<'tcx>, main_id: DefId, config: MiriConfig) ->
190197 // Process the result.
191198 match res {
192199 Ok ( return_code) => {
193- // Disable the leak test on some platforms where we do not
194- // correctly implement TLS destructors.
195- let target_os = ecx. tcx . tcx . sess . target . target . target_os . to_lowercase ( ) ;
196- let ignore_leaks = target_os == "windows" || target_os == "macos" ;
197200 if !ignore_leaks {
198201 let leaks = ecx. memory . leak_report ( ) ;
199202 if leaks != 0 {
0 commit comments