diff --git a/src/discover/discover.ml b/src/discover/discover.ml new file mode 100644 index 00000000..f2e0b921 --- /dev/null +++ b/src/discover/discover.ml @@ -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 [])) +;; diff --git a/src/discover/discover.mli b/src/discover/discover.mli new file mode 100644 index 00000000..e790aeb7 --- /dev/null +++ b/src/discover/discover.mli @@ -0,0 +1 @@ +(* empty *) diff --git a/src/discover/dune b/src/discover/dune new file mode 100644 index 00000000..9e74a1e7 --- /dev/null +++ b/src/discover/dune @@ -0,0 +1,2 @@ +(executables (names discover) (libraries dune.configurator) + (preprocess no_preprocessing)) \ No newline at end of file diff --git a/src/dune b/src/dune index 4ea7d047..422e43d1 100644 --- a/src/dune +++ b/src/dune @@ -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) diff --git a/test/test_map.ml b/test/test_map.ml index cdfd01f2..d4337956 100644 --- a/test/test_map.ml +++ b/test/test_map.ml @@ -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 @@ -61,4 +60,3 @@ module Poly = struct length a = length b ;; end -