diff mbox series

[bug#49867,v2,13/31] gnu: Add ocaml-mirage-crypto.

Message ID 20210809070124.25641-13-pukkamustard@posteo.net
State Accepted
Headers show
Series [bug#49867,v2,01/31] gnu: Add ocaml-cohttp-lwt. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

pukkamustard Aug. 9, 2021, 7:01 a.m. UTC
* gnu/packages/ocaml.scm (ocaml-mirage-crypto): New variable.
---
 gnu/packages/ocaml.scm | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

Comments

Julien Lepiller Aug. 21, 2021, 2:01 p.m. UTC | #1
Trying to build ocaml-mirage-crypto, I get errors during the tests:

ocamlopt tests/test_symmetric_runner.exe (exit 2)

Error: Files
/gnu/store/id3dchcsw5gijsnn73kw5sn9ymjj90ai-ocaml-eqaf-0.7/lib/ocaml/site-lib/eqaf/bigstring/eqaf_bigstring.cmxa
and
/gnu/store/id3dchcsw5gijsnn73kw5sn9ymjj90ai-ocaml-eqaf-0.7/lib/ocaml/site-lib/eqaf/eqaf.cmxa
make inconsistent assumptions over implementation Eqaf

this seems to indicate Eqaf did not build properly? Does it build for
you?

also, minor but there's a typo in the synopsis "provding" ->
"providing".
pukkamustard Aug. 23, 2021, 2:27 p.m. UTC | #2
Julien Lepiller <julien@lepiller.eu> writes:

> Trying to build ocaml-mirage-crypto, I get errors during the 
> tests:
>
> ocamlopt tests/test_symmetric_runner.exe (exit 2)
>
> Error: Files
> /gnu/store/id3dchcsw5gijsnn73kw5sn9ymjj90ai-ocaml-eqaf-0.7/lib/ocaml/site-lib/eqaf/bigstring/eqaf_bigstring.cmxa
> and
> /gnu/store/id3dchcsw5gijsnn73kw5sn9ymjj90ai-ocaml-eqaf-0.7/lib/ocaml/site-lib/eqaf/eqaf.cmxa
> make inconsistent assumptions over implementation Eqaf
>
> this seems to indicate Eqaf did not build properly? Does it 
> build for
> you?

Negative. Can confirm that ocaml-mirage-crypto does not build when 
rebased on master. I will investigate.

> also, minor but there's a typo in the synopsis "provding" ->
> "providing".

Oops. Will fix.

-pukkamustard
pukkamustard Aug. 23, 2021, 4:52 p.m. UTC | #3
pukkamustard <pukkamustard@posteo.net> writes:

> Julien Lepiller <julien@lepiller.eu> writes:
>
>> Trying to build ocaml-mirage-crypto, I get errors during the 
>> tests:
>>
>> ocamlopt tests/test_symmetric_runner.exe (exit 2)
>>
>> Error: Files
>> /gnu/store/id3dchcsw5gijsnn73kw5sn9ymjj90ai-ocaml-eqaf-0.7/lib/ocaml/site-lib/eqaf/bigstring/eqaf_bigstring.cmxa
>> and
>> /gnu/store/id3dchcsw5gijsnn73kw5sn9ymjj90ai-ocaml-eqaf-0.7/lib/ocaml/site-lib/eqaf/eqaf.cmxa
>> make inconsistent assumptions over implementation Eqaf
>>
>> this seems to indicate Eqaf did not build properly? Does it 
>> build for
>> you?
>
> Negative. Can confirm that ocaml-mirage-crypto does not build 
> when rebased on
> master. I will investigate.

This seems to be related to the recently added dune profile 
parameter (https://issues.guix.gnu.org/49868).

The installed eqaf.cmxa seems to be the one built by using the 
"dev" profile, whereas eqaf_bigstring.cmxa is expecting the Eqaf 
module built with the "release" profile:

```
$ ocamlobjinfo 
/gnu/store/id3dchcsw5gijsnn73kw5sn9ymjj90ai-ocaml-eqaf-0.7/lib/ocaml/site-lib/eqaf/bigstring/eqaf_bigstring.cmxa
[..]
Implementations imported:
	193f160ab58c2c455f4e1fe1425b8971	Eqaf
[..]

$ ocamlobjinfo 
/gnu/store/id3dchcsw5gijsnn73kw5sn9ymjj90ai-ocaml-eqaf-0.7/lib/ocaml/site-lib/eqaf/eqaf.cmxa
[..]
CRC of implementation: f693310ffd4f92f54cd1fde8271782b8
[..]
```

With (arguments `(#:profile "dev")):
```
$ ocamlobjinfo 
/gnu/store/v2s1h1is0ci2ij2h8k5fbna3j8ycrw9y-ocaml-eqaf-0.7/lib/ocaml/site-lib/eqaf/bigstring/eqaf_bigstring.cmxa
[..]
Implementations imported:
[..]
--------------------------------	Eqaf

$ ocamlobjinfo 
/gnu/store/v2s1h1is0ci2ij2h8k5fbna3j8ycrw9y-ocaml-eqaf-0.7/lib/ocaml/site-lib/eqaf/eqaf.cmxa
[..]
CRC of implementation: f693310ffd4f92f54cd1fde8271782b8
[..]
```

When using the "dev" profile the ocaml-eqaf and 
ocaml-mirage-crypto build and pass the checks.

(I assume that the missing CRC in eqaf_bigstring.cmxa means it 
does not check the CRC of the Eqaf implementation.)

If I set (arguments `(#:package "eqaf")), then also everything 
builds fine and the hashes seem to be right:

```
$ ocamlobjinfo 
/gnu/store/cyw1n07cqdh25w5awww185s44yzbcyss-ocaml-eqaf-0.7/lib/ocaml/site-lib/eqaf/bigstring/eqaf_bigstring.cmxa
Implementations imported:
	193f160ab58c2c455f4e1fe1425b8971	Eqaf


$ ocamlobjinfo 
/gnu/store/cyw1n07cqdh25w5awww185s44yzbcyss-ocaml-eqaf-0.7/lib/ocaml/site-lib/eqaf/eqaf.cmxa
CRC of implementation: 193f160ab58c2c455f4e1fe1425b8971
```

This seems weird. I don't understand why dune installs the 
eqaf.cmxa built with "dev" profile but eqaf_bigstring.cmxa with 
"release" profile. Maybe this is a bug in dune?

It does seem that using the dune "--profile" options on its own is 
not very common. Opam uses the dune "-p" option. This sets the 
profile to "release" and does a couple of other things 
(https://dune.readthedocs.io/en/stable/opam.html?highlight=build%20profile#invocation-from-opam). 
I don't think many people use the "--profile" option on its own.

For our dune-build-system I think it makes more sense to always 
use the "-p" flag. This requires adding the explicit OCaml 
package(s) to many specifications in Guix. I also think the 
"profile" parameter should be removed as the interactions with the 
"package" parameter (dune "-p") are not as expected. Sorry for not 
doing this research before submitting the patch that added the 
"profile" parameter.

Thoughts?

-pukkamustard
diff mbox series

Patch

diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index 7101cc6c2f..c6cdd3a318 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -7592,6 +7592,37 @@  property-based testing and the magical bug-finding powers of
 constant-time to avoid timing-attack with crypto stuff.")
     (license license:expat)))
 
+(define-public ocaml-mirage-crypto
+  (package
+    (name "ocaml-mirage-crypto")
+    (version "0.10.3")
+    (home-page "https://github.com/mirage/mirage-crypto")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url home-page)
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "0j7x07c8xy8bmqp9ad1cib6j69dy7acjg9m1d7pn0dnmbkrl8fiz"))))
+    (build-system dune-build-system)
+    (arguments `(#:package "mirage-crypto"
+                 #:test-target "."))
+    (propagated-inputs
+     `(("ocaml-cstruct" ,ocaml-cstruct)
+       ("ocaml-eqaf" ,ocaml-eqaf)
+       ("ocaml-bigarray-compat" ,ocaml-bigarray-compat)))
+    (native-inputs
+     `(("pkg-config" ,pkg-config)
+       ("ocaml-ounit" ,ocaml-ounit)))
+    (synopsis "OCaml library provding cryptographic primitives")
+    (description "This OCaml library provides symmetric ciphers (DES, AES,
+RC4, ChaCha20/Poly1305), and hashes (MD5, SHA-1, SHA-2).  This library can be
+used from MirageOS unikernels.")
+    (license license:isc)))
+
 (define-public js-of-ocaml
   (package
     (name "js-of-ocaml")