diff --git a/src/discover/discover.ml b/src/discover/discover.ml index f2e0b92..913d964 100644 --- a/src/discover/discover.ml +++ b/src/discover/discover.ml @@ -14,7 +14,11 @@ let () = main ~name:"discover" ~args:[ "-o", Set_string output, "FILENAME output file" ] - (fun c -> - let has_popcnt = c_test c ~c_flags:[ "-mpopcnt" ] program in + (fun _c -> + let f,oc = Filename.open_temp_file "baseconf" ".c" in + let has_popcnt = + Fun.protect ~finally:(fun () -> close_out oc; Sys.remove f) + (fun () -> output_string oc program; flush oc; + Sys.command (Printf.sprintf "cc %s -mpopcnt -o /dev/null >/dev/null 2>&1" f) = 0) in Flags.write_sexp !output (if has_popcnt then [ "-mpopcnt" ] else [])) ;;