From 3ff99dfba3c2d6070d48dbd283e54ddd2f94ddb9 Mon Sep 17 00:00:00 2001 From: Marco Stronati Date: Tue, 5 Jun 2018 23:40:15 +0200 Subject: [PATCH] hacl: build system for 32 bits architecture --- vendors/ocaml-hacl/readme.md | 1 + vendors/ocaml-hacl/src/config/discover.ml | 11 +++++++++++ vendors/ocaml-hacl/src/config/jbuild | 5 +++++ vendors/ocaml-hacl/src/jbuild | 8 +++++++- 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 vendors/ocaml-hacl/src/config/discover.ml create mode 100644 vendors/ocaml-hacl/src/config/jbuild diff --git a/vendors/ocaml-hacl/readme.md b/vendors/ocaml-hacl/readme.md index 120bafdf7..cb1cd5db0 100644 --- a/vendors/ocaml-hacl/readme.md +++ b/vendors/ocaml-hacl/readme.md @@ -1,2 +1,3 @@ Tezos binding for Hacl* https://github.com/mitls/hacl-star/tree/master/snapshots/tezos +commit b69319a0d3b71af8042f487d6a5bac8101edf2d0 diff --git a/vendors/ocaml-hacl/src/config/discover.ml b/vendors/ocaml-hacl/src/config/discover.ml new file mode 100644 index 000000000..c6dbe1e9f --- /dev/null +++ b/vendors/ocaml-hacl/src/config/discover.ml @@ -0,0 +1,11 @@ +let () = + (* inspired by https://github.com/vbmithr/ocaml-secp256k1-internal/blob/master/config/discover.ml *) + let ccopts = "-Ofast -march=native -mtune=native -m64 -fwrapv -fomit-frame-pointer -funroll-loops -Wall -Werror -Wfatal-errors" in + (* the important bit is -DKRML_NOUINT128 which enables the verified (but slow) implementation of UInt128 in FStar.c rather than the builtin __int128 which is only available on 64-bit platforms. *) + let ccopts32 = "-Ofast -fwrapv -fomit-frame-pointer -funroll-loops -DKRML_NOUINT128 -Wall -Werror -Wfatal-errors" in + + let oc = open_out "c_flags.sexp" in + let sixtyfour = Sys.word_size = 64 in + let flags = if sixtyfour then ccopts else ccopts32 in + Printf.fprintf oc "(%s)%!" flags ; + close_out oc diff --git a/vendors/ocaml-hacl/src/config/jbuild b/vendors/ocaml-hacl/src/config/jbuild new file mode 100644 index 000000000..d96941edd --- /dev/null +++ b/vendors/ocaml-hacl/src/config/jbuild @@ -0,0 +1,5 @@ +(jbuild_version 1) + +(executable + ((name discover) + (libraries (base stdio)))) diff --git a/vendors/ocaml-hacl/src/jbuild b/vendors/ocaml-hacl/src/jbuild index 519cb83bf..7b7fb1042 100644 --- a/vendors/ocaml-hacl/src/jbuild +++ b/vendors/ocaml-hacl/src/jbuild @@ -22,5 +22,11 @@ Hacl_Salsa20 NaCl Hacl_Unverified_Random)) - (c_flags (-O3 -Wall -Werror -Wfatal-errors)) + (c_flags (:include c_flags.sexp)) )) + +; sets flags for 32/64 bits architectures +(rule + ((targets (c_flags.sexp)) + (deps (config/discover.exe)) + (action (run ${<} -ocamlc ${OCAMLC}))))