-
Notifications
You must be signed in to change notification settings - Fork 34
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
CEP for packaging coq-native #48
Conversation
IMHO
I strongly recommend that instead libraries provide a |
I am a bit confused by items 2 and 3. If item 2 changes the default to By the way, I still strongly believe that any solution that requires item 3 is a bad solution. Also, it seems that item 1 completely forbids |
That's intentional, because today that's the only way to avoid any overhead from native-compute searching/loading native libraries. It'd be better if you could compile it in, but still have no overhead by default, if that's easy enough to do, but this hasn't been done since 8.11 because of problems. But to be sure: would it be so hard to require a command-line option (and otherwise immutable) to make native-compute available? The challenge IIRC was with "more mutable" flags. |
What do you mean? Are you saying that the overhead is currently paid even if no native libraries are compiled (which is the whole point of |
To be clearer, I see three meaningful cases:
|
According to the text of the CEP, item 2 is for upcoming versions of Coq and item 3 is only for already released versions of Coq. |
Oops, my mistake. This is indeed written not just once but twice in the CEP. (But not in the detailed description of item 3, so I kind of missed it.) |
While I understand the motivation and rationale behind the proposal, I can see using More specifically, under this proposal, is there any way at all to determine post-hoc with any certainty that Coq was actually compiled with native compute? For example, it looks like it is possible to install (or uninstall) |
Is that how |
Are you sure? I thought that was the whole point of |
Documentation of |
OK, so this invalidates Karl's argument and also Emilio's claim that "compilation is not anymore deterministic". |
It seems to me that the most important argument of Emilio against this is actually the third one: "the flag is all-or-nothing, so in the case of only needing a few packages with native support users still do pay the full price". And this comes with an alternative proposal:
It seems to me that the trade-off / debate is here: loss of flexibility for the user (native compilation is for a whole switch, unless they mess with |
It is a huge pain for packagers, but it is also a minor pain for users. Indeed, if users want to use In the case of a single |
I would go for the simpler option, one package to opt in your switch. Exactly as you opt in a compiler feature like flambda. |
Ondemand will try to load native libraries, and it will succeed on the std library. We noticed when that costed 10x on one MacOS machine, but I can measure overhead even on Linux. And yes, that should have better fixes, but that seems hard and hasn’t happened for years. But I’m happy to be proven wrong. On the “separate foo-native package” idea, I thought that relied on new Coq features of creating native code from vo files? IIRC they were described as “easy”, but that was months ago. |
But that is only if the standard library has been compiled to native code. I don't see any reason to compile the standard library to native code if the |
Hm, that was in today's setup. You have a point; however, you're making a (reasonable but untested) assumption that native-compiler ondemand doesn't have any downsides left in this scenario.
|
The difference between So, if you want to use As I explained in some other venue, the To summarize, the use cases for (Currently, if you have an Opam installation of CoqInterval, then MathComp, Flocq, Coquelicot, and Bignums, are compiled on-the-fly to native code when you use tactics |
My 2cts:
|
No it doesn't in the sense that any 3rd party package can actually produce non-local changes, so it turns out that builds are not compositional anymore, in the sense that building A and B separately is not the same as building See the thread for lablgtk. I am strongly against any solution using |
On the other hand using two packages as Enrico proposes should work fine; so we could go in the line of a virtual |
IMHO whether to add the One question that I think has not been addressed is what control the user has over their own libs. For example it is not clear if the user should have control à la |
That does not make sense to me. You say that builds involving packages with For example, you say that having two packages The very reason we have a tool like Opam which embeds a full-blown constraint solver is because builds are inherently non-compositional in the real world. By the way, even your idea of having |
It shouldn't be that hard though. I must confess I'd prefer a solution where native libraries are a parallel package, rather than the solution advocated in this CEP which is essentially introducing a different, incompatible Coq compiler flavour. |
Even if they are parallel packages (which will be painful for maintainers), they will transitively need to depend on |
I'm not very savvy on that .cmxs change, however IINM it would only be applicable for upcoming releases of Coq… while this CEP proposes a unified change for each
OK. but IMHO this "compiler flavor" (which amounts to define a package flag setting the
So I tend to agree with @silene and @gares 's remarks #48 (comment) and #48 (comment) |
Hi @silene, good catch! that makes sense, indeed.
|
so I guess the CEP is ready to be merged if no one objects :) (unless you'd want to add yet another remark in this section about the scenario we discussed again just now?) |
eaab5d7
to
7337e5e
Compare
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.
A few minor comments, LGTM otherwise.
d3c6f5d
to
35b5450
Compare
Applied. Thanks again @proux01 :) |
This an implementation of point 2 of CEP coq#48 coq/ceps#48 Option -native-compiler of the configure script now impacts the default value of the option -native-compiler of coqc. The -native-compiler option of the configure script is added an ondemand value, which becomes the default, thus preserving the previous default behavior. The stdlib is still precompiled when configuring with -native-compiler yes. It is not precompiled otherwise.
This an implementation of point 2 of CEP coq/ceps#48 coq/ceps#48 Option -native-compiler of the configure script now impacts the default value of the option -native-compiler of coqc. The -native-compiler option of the configure script is added an ondemand value, which becomes the default, thus preserving the previous default behavior. The stdlib is still precompiled when configuring with -native-compiler yes. It is not precompiled otherwise.
This an implementation of point 2 of CEP coq/ceps#48 coq/ceps#48 Option -native-compiler of the configure script now impacts the default value of the option -native-compiler of coqc. The -native-compiler option of the configure script is added an ondemand value, which becomes the default, thus preserving the previous default behavior. The stdlib is still precompiled when configuring with -native-compiler yes. It is not precompiled otherwise. (cherry picked from commit 1596cdb)
Hi, the implem. of item 2 (coq/coq#13352) is now part of the v8.13 branch; I'm going to prepare the PR of item 1 (for Coq < 8.13). |
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.
No, go ahead with your PR, but let's merge this one soon.
I propose to merge by the end of the week if no more comments (with my renaming suggestion taken into account or not).
just FYI when ocaml/opam-repository#17690 will be merged, I plan to add the The question whether it is the best option might arise though for But if you don't object, I'll do the same change in docker-coq for Coq ≥ 8.13 (adding Indeed when I discussed this quickly with Théo at the CUDW, he mentioned this may be useful to further test users' libs w.r.t. the native precompilation − and it is always possible to override the |
* Otherwise, with Coq 8.13: #=== ERROR while compiling coq-coqeal.1.0.5 ===================================# # [...] # File "./refinements/multipoly.v", line 1532, characters 0-67: # Warning: Duplicate clear of sz_m' [duplicate-clear,ssr] # File "./refinements/.coq-native/NCoqEAL_refinements_multipoly.native", line 66, characters 14-82: # Error: Unbound module NSsrMultinomials_mpoly # Error: Native compiler exited with status 2 * This fix is temporary: when multinomials will require Coq >= 8.12.1, one could then rely on ocaml/dune#3210, which provides the `(mode native)` stanza. * For details, see also: coq/ceps#48
* Otherwise, with (coq.8.13.2 + coq-native): #=== ERROR while compiling coq-coqeal.1.0.5 ===================================# # [...] # File "./refinements/multipoly.v", line 1532, characters 0-67: # Warning: Duplicate clear of sz_m' [duplicate-clear,ssr] # File "./refinements/.coq-native/NCoqEAL_refinements_multipoly.native", line 66, characters 14-82: # Error: Unbound module NSsrMultinomials_mpoly # Error: Native compiler exited with status 2 * This fix is temporary: when multinomials will require Coq >= 8.12.1, one could then rely on ocaml/dune#3210, which provides the `(mode native)` stanza. * For details, see also: coq/ceps#48
* Otherwise, with (coq.8.13.2 + coq-native): #=== ERROR while compiling coq-coqeal.1.0.5 ===================================# # [...] # File "./refinements/multipoly.v", line 1532, characters 0-67: # Warning: Duplicate clear of sz_m' [duplicate-clear,ssr] # File "./refinements/.coq-native/NCoqEAL_refinements_multipoly.native", line 66, characters 14-82: # Error: Unbound module NSsrMultinomials_mpoly # Error: Native compiler exited with status 2 * This fix is temporary: when multinomials will require Coq >= 8.12.1, one could then rely on ocaml/dune#3210, which provides the `(mode native)` stanza. * For details, see also: coq/ceps#48
* Otherwise, with (coq.8.13.2 + coq-native): #=== ERROR while compiling coq-coqeal.1.0.5 ===================================# # [...] # File "./refinements/multipoly.v", line 1532, characters 0-67: # Warning: Duplicate clear of sz_m' [duplicate-clear,ssr] # File "./refinements/.coq-native/NCoqEAL_refinements_multipoly.native", line 66, characters 14-82: # Error: Unbound module NSsrMultinomials_mpoly # Error: Native compiler exited with status 2 * This fix is temporary: when multinomials will require Coq >= 8.12.1, one could then rely on ocaml/dune#3210, which provides the `(mode native)` stanza. * For details, see also: coq/ceps#48
# Note to library developers and package maintainers | ||
|
||
To fully benefit from `native_compute` with a library using Coq 8.5+, some (`opam`) packaging update may be required for this library's dependencies: | ||
|
||
- for `coq_makefile`: no change required for Coq 8.13+; otherwise follow **item 3** above (related to Section [Precompiling for `native_compute`](https://coq.github.io/doc/master/refman/practical-tools/utilities.html?highlight=coq_makefile#precompiling-for-native-compute) in Coq refman); | ||
- for `dune / coq.theory`: this will require Coq 8.12.1+ and a version of `dune` implementing [PR ocaml/dune#3210](https://github.com/ocaml/dune/pull/3210) (cf. [this comment](https://github.com/coq/ceps/pull/48#issuecomment-727020253) by **@ejgallego**); otherwise (without native support), Dune will just ignore the native parts and no `./coq-native/*.cmxs` file will be installed. | ||
|
||
Note that these changes could be performed directly in the existing packages gathered in the [coq/opam-coq-archive](https://github.com/coq/opam-coq-archive) repository. |
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.
Please make this section more visible, at least by searching "native" in refman.
I found here by searching "native" on Discourse and following the link in this post, which doesn't seem so intuitive.
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.
Actually since Dune 3.0 we could just make native work automatically, I'm gonna open a dune issue.
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.
Please emphasize that Coq stanza should also be upgraded to (coq 0.3)
. I figured it out by reading between the lines in ocaml/dune#3210.
This CEP describes a new strategy for setting the default value for the
-native-compiler
option (incoqc
and in theopam
packaging).It has been written by @proux01 and I, following a suggestion by @Zimmi48 − in coq/coq#12757 (comment)
I Cc some coq devs involved in the features/packaging discussed here: @maximedenes @silene @ejgallego @gares @palmskog @clarus @SkySkimmer @vbgl @Blaisorblade (sorry if I forget someone, but feel free to Cc other coq devs recursively…)
Direct link to the rendered
.md
(final version)