Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/discover/discover.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ let () =
main
~name:"discover"
~args:[ "-o", Set_string output, "FILENAME output file" ]
(fun _c ->
(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 () -> Out_channel.(output_string oc program; flush oc);
Sys.command (Printf.sprintf "cc %s -mpopcnt -o /dev/null >/dev/null 2>&1" f) = 0) in
match ocaml_config_var_exn c "system" with
| "macosx" -> false
| _ ->
Fun.protect ~finally:(fun () -> close_out oc; Sys.remove f)
(fun () -> Out_channel.(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 []))
;;