-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to Dune #24
Switch to Dune #24
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the code and apologies for the delay in reviewing.
Overall, this looks very good to me. I'm a bit disappointed by the auto-configuration part, which is both a lot of code and not very subtle.
As an example of "subtility" we would like to add -maes
if we're on x86 and the C compiler supports this flag. The Oasis code could not express that, so we went for a not-subtle criterion "x86 and not Windows" which Oasis expresses nicely and concisely.
If we were to "do the right thing" with -maes
, how would we go about it? Use dune-configurator? Use autoconf? Something else?
Co-authored-by: Xavier Leroy <xavierleroy@users.noreply.github.com>
@xavierleroy Thanks! I'm happy to make the auto-configuration part a bit smarter. Indeed,
Unpacking the "C compiler supports this flag" part: is there a simple test we can use for checking that a C compiler supports this flag? Do we expect that the compilation will just fail if we pass this flag when compiling a dummy C file, producing an error like "unrecognized command line option -maes"? If yes, that should be easy to automate. |
Yes, pretty much. The only difficulty I've encountered is that, when faced with an unknown option, some C compilers stop with a nonzero exit code, and other C compilers print a warning and go on, exiting with 0 code. Here is how we do it in CompCert to check for availability of a link-time option ( For a compile-time option such as Is a test like this appropriate for dune-configurator? On the one hand it would be very useful, and not just for Cryptokit. On the other hand, it's a bit of a hack, owing to the grepping for keywords in standard error. Your call. |
@xavierleroy I've added a basic test using The current implementation doesn't correctly handle the situation where a compiler happily prints a warning about an ignored flag instead of failing with an error. It makes sense to add support for this to Is the current solution sufficient or would you prefer to make the logic more robust, similar to the CompCert check you linked? It's not too difficult (so I'm happy to do it) but the resulting logic would be a bit more ad-hoc. |
@xavierleroy Just a reminder: I think this PR is now complete and can be merged if you're happy with the implementation. I've also tested that this version of cryptokit can be built by Dune as part of the Jane Street universe. |
Thanks for the ping and sorry for the delays. To be entirely honest, I'm still not happy with the configuration part. In the current Oasis-based system, a Windows user can configure with I'm very new to Dune, so I may miss the obvious, but how can users pass configuration options to a Dune build? is there an equivalent to |
@xavierleroy At the moment Dune doesn't provide support for the configuration step. @jeremiedimino and I have just discussed this and we agree that a sub-command like For now, we decided to implement a custom $ ./configure --help
Usage: ./configure [OPTIONS]
--enable-zlib Enable ZLib
--disable-zlib Disable ZLib
--enable-hardwaresupport Enable hardware support for AES and GCM (needs GCC or Clang)
--disable-hardwaresupport Disable hardware support for AES and GCM (needs GCC or Clang)
-help Display this list of options
--help Display this list of options
# Run configure with default settings
$ ./configure
flags src/flags.sexp,src/library_flags.sexp
ZLib: ............................... enabled
Hardware support for AES and GCM: ... enabled
# Override one of the settings
$ ./configure --disable-zlib
flags src/flags.sexp,src/library_flags.sexp
ZLib: ............................... disabled
Hardware support for AES and GCM: ... enabled Calling the Hope this works for you, although we admit that we needed to write more custom code for this than we would have liked. |
Thanks a lot for your patience! The "configure" script seems to work pretty well, and the same approach could apply to other libraries. So, I'm happy. The one thing that still worries me is that
I would expect dune to either build the tests successfully, or explain why it cannot. |
Post-scriptum: I would be perfectly happy if running |
Glad to hear you like how the I didn't realise that tests can't be built in some configurations. I'll think about possible solutions. Strangely, I can't reproduce the poor error messages from your example. If I first run Click to expand!
The error messages I get aren't ideal but better than those from your example.
I don't think this is related to the problem. |
False alarm. Maybe I had leftover files, but after a The "no zlib" stub code is broken, which is why compilation fails in --disable-zlib mode, but that's something I'll fix next. Time to merge! Thanks again for all the work. |
Happy to help, and thank you for the review! |
Exciting news. Would it be possible to release a new version of crpytokit to opam? |
I released version 1.16 and did a |
As we discussed previously by email, in this PR we switch the library to building with Dune.
I updated the README with new instructions, but here is a quick summary:
dune build
.dune exec test/test.exe
,dune exec test/prngtest.exe
ordune exec test/speedtest.exe
.dune install
.dune build @doc
, see_build/default/_doc/_html/cryptokit/Cryptokit/index.html
.There is a special file
src/compute_flags.ml
, invoked during the build, which takes care of computing various flags that depend on the system and architecture. This can be improved by allowing the user to override computed values, or by integrating withdune-configurator
which is aconfigure
-like system for checking if a certain library exists, a certain flag is supported, etc. Please let us know your thoughts on this.This PR currently deletes all OASIS-related files, because maintaining two build systems is painful. We could keep OASIS for some time, just in case, but we don't recommend this: it would be better to fix any issues with Dune instead (we're happy to help).
/cc @jeremiedimino