Skip to content

Commit

Permalink
Merge pull request #74 from janestreet/v0.12.0-for-win
Browse files Browse the repository at this point in the history
backport fix for popcount detection on windows
  • Loading branch information
xclerc committed May 22, 2019
2 parents 390c016 + b817831 commit f958445
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
20 changes: 20 additions & 0 deletions src/discover/discover.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
open Configurator.V1

let program =
{|
int main(int argc, char ** argv)
{
return __builtin_popcount(argc);
}
|}
;;

let () =
let output = ref "" in
main
~name:"discover"
~args:[ "-o", Set_string output, "FILENAME output file" ]
(fun c ->
let has_popcnt = c_test c ~c_flags:[ "-mpopcnt" ] program in
Flags.write_sexp !output (if has_popcnt then [ "-mpopcnt" ] else []))
;;
1 change: 1 addition & 0 deletions src/discover/discover.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(* empty *)
2 changes: 2 additions & 0 deletions src/discover/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(executables (names discover) (libraries dune.configurator)
(preprocess no_preprocessing))
10 changes: 2 additions & 8 deletions src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@
-apply=js_style,base_lint,type_conv))
(js_of_ocaml (javascript_files runtime.js)))

(rule (targets mpopcnt.sexp) (deps)
(action
(progn
(with-stdout-to popcnt_test.c
(echo
"int main(int argc, char ** argv) { return __builtin_popcount(argc); }"))
(system
"%{cc} -mpopcnt -c popcnt_test.c 2> ${null} && echo '(-mpopcnt)' > %{targets} || echo '()' > %{targets}"))))
(rule (targets mpopcnt.sexp) (deps discover/discover.exe)
(action (run ./discover/discover.exe -o %{targets})))

(ocamllex hex_lexer)
2 changes: 0 additions & 2 deletions test/test_map.ml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ let%expect_test "[Map.of_alist_multi] preserves value ordering" =
(b (1 3))) |}]
;;


module Poly = struct
let%test _ =
length Poly.empty = 0
Expand All @@ -61,4 +60,3 @@ module Poly = struct
length a = length b
;;
end

0 comments on commit f958445

Please sign in to comment.