Skip to content

Commit 00bcbd1

Browse files
Merge pull request #180 from avsm/fix-mpopcnt
fix -mpopcnt compilation failure on macOS/aarch64 10.4
2 parents 6e07dd4 + ea5fbce commit 00bcbd1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/discover/discover.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ let () =
1414
main
1515
~name:"discover"
1616
~args:[ "-o", Set_string output, "FILENAME output file" ]
17-
(fun c ->
18-
let has_popcnt = c_test c ~c_flags:[ "-mpopcnt" ] program in
17+
(fun _c ->
18+
let f,oc = Filename.open_temp_file "baseconf" ".c" in
19+
let has_popcnt =
20+
Fun.protect ~finally:(fun () -> close_out oc; Sys.remove f)
21+
(fun () -> Out_channel.(output_string oc program; flush oc);
22+
Sys.command (Printf.sprintf "cc %s -mpopcnt -o /dev/null >/dev/null 2>&1" f) = 0) in
1923
Flags.write_sexp !output (if has_popcnt then [ "-mpopcnt" ] else []))
2024
;;

0 commit comments

Comments
 (0)