Build system: use ocaml{c,opt}.opt instead of ocaml{c,opt} when available#8840
Build system: use ocaml{c,opt}.opt instead of ocaml{c,opt} when available#8840gasche merged 9 commits intoocaml:trunkfrom
Conversation
|
Very nice fix! |
9f021c4 to
d79c325
Compare
|
If The warning cannot be observed in a cold-build scenario, and it should not be observable when running |
|
I have implemented the newer-than check (it's a Make function rather than a shell script to easily make use of Make's
|
I applaud the effort (of using make functions) but dislike the smells of scripting (using |
|
Very nice! I pushed a patch with your version. (In the bytecode case we need to prefix with I had thought of doing something like that (without the assignment) but I couldn't find a way that would (1) statically make the choice at Makefile-invocation time (I'm worried of the performance cost of checking at each compiler invocation) and (2) keep using the In fact I checked, and CAMLRUN is not redefined anywhere in this style (some other variables use redefinitions and lazy expansions, in particular the CAML{C,OPT} and CAML{C,OPT}_CMD pairing) -- it is sometimes redefined on recursive invocation of Make (to promote, for example) but that should be fine. So we don't need to keep (2) and can use eager assignment with your version. |
c2ecd5f to
c70f998
Compare
|
(cc @shindere this is the other Makefile-oriented PR that I mentioned.) |
|
I am wondering why e.g. `choose_best` needs to take two arguemnts, given
that, as far as I can tell, it will always be called with `foo` and
`foo.opt`. would it be okay to rename it to, say, `find_tool` and to
give it only one argument? I am suspecting that this could be used to
choose between `ocamldoc` and `ocmaldoc.opt` too, right?
|
c70f998 to
389c4a5
Compare
|
I addressed the review comments of @shindere -- I have a one-argument instead of two-argument function now. |
|
I'm not that found of the proliferation of makefiles, even less found of
it when it's at the top-level of the source tree.
Why not adding these definitions to `Makefile.common` directly,
actually?
|
|
I think it's good to have a mechanism where these definitions must be explicitly opted into. The alternative would be to have them in Personally I think having the |
Makefile.best_binaries
Outdated
| ok) | ||
|
|
||
| choose_best = $(strip $(if \ | ||
| $(and $(wildcard $(ROOTDIR)/$1.opt),$(strip $(call check_not_stale,$1,$1.opt))), \ |
There was a problem hiding this comment.
Alas, this line is failing check-typo (I can't remember if you're a fan of the githook or not - worrying that if you are, that it's not working??)
There was a problem hiding this comment.
@dra27 could we have instructions in HACKING.adoc on how to enable them (instructions were given in a discussion not long time ago) ? It's quite annoying to make PRs have the slow CI fail only on this.
There was a problem hiding this comment.
They've been in CONTRIBUTING.md since the hook was added (L71-L72)
There was a problem hiding this comment.
Ah thanks ! Maybe there are too much of these documents...
|
David Allsopp (2019/09/27 01:45 -0700):
I think it's good to have a mechanism where these definitions must be
explicitly opted into.
Why?
The alternative would be to have them in `Makefile.common` but have a
variable which can be defined before `Makefile.common` is `include`d
to enable them.
If anything, I'd prefer that, although I'd not like it very much either.
Personally I think having the `Makefile.best_binaries` as it is better
It does not really scale...
|
|
Daniel Bünzli (2019/09/27 01:59 -0700):
dbuenzli commented on this pull request.
> +
+# It exports definitions of BEST_OCAML{C,OPT,LEX,DEP} commands that
+# run to either the bytecode binary built in the repository or the
+# native binary, if available. Note that they never use the boot/
+# versions: we assume that ocamlc, ocamlopt, etc. have been run first.
+
+check_not_stale = \
+ $(if $(shell test $(ROOTDIR)/$1 -nt $(ROOTDIR)/$2 && echo stale), \
+ $(info Warning: we are not using the native binary $2 \
+because it is older than the bytecode binary $1; \
+you should silence this warning by either removing $2 \
+or rebuilding it (or `touch`-ing it) if you want it used.), \
+ ok)
+
+choose_best = $(strip $(if \
+ $(and $(wildcard $(ROOTDIR)/$1.opt),$(strip $(call check_not_stale,$1,$1.opt))), \
@dra27 could we have instructions in `HACKING.adoc` on how to enable
them (instructions were given a discussion not long time ago) ? It's
quite annoying to make PRs have the slow CI fail only on this.
There's even a proposal to include invoking `check-typo` in the
compiler's build process on dev builds. That might even be better and
does not exclude the pre-commit hook anyway.
|
|
Daniel Bünzli (2019/09/27 02:26 -0700):
Ah thanks ! Maybe there are too much of these documents...
Both files seem already a bit large, but I agree that it would be nice
to have less of them.
|
I'm not sure what sort of scalability you have in mind here, is it the scalability of We could think of moving the sub-Makefiles into |
|
Gabriel Scherer (2019/09/27 07:16 -0700):
I'm not sure what sort of scalability you have in mind here, is it the
scalability of `ls` at the root?
Of course not :)
When we write programs, we tend to consider that it is good style to split distinct part of the codebase in different files, instead of having everything in a single source file.
We could think of moving the sub-Makefiles into `tools/` for example,
or a new `makefiles/` directory (as we used to have in the testsuite).
Sure, a directory with the sub-makefiles owuld be better, I think. Still
I don't like it too much to have one new Makefile for each thing we may
invent. To me it feels error-prone to multiply the makefiles because
there is always the risk to forget to include one, or to include it in
the wrong place, stuff like that.
|
|
I don't see the problem. If you forget to include a makefile that provides definitions/variables, then your makefile code fails and you quickly notice the problem. On the other hand, having a monster Makefile that defines everything at once makes it harder to reason about, for example, which definitions are or are not in scope at a given point. (For example, everytime you add a definition there, you have to check all Makefiles including it, which is all makefiles, for naming conflicts.) |
|
Well `Makefile.common` is far from being a monster at the moment, IMO,
but if everybody agrees, fine.
|
|
Could we try to make faster progress on this PR? Saving 40s to a minute of compiler full-build time seems like an important quality-of-life improvement for developers (and could also help CI response times), it's disappointing to wait for two months to make a decision. |
(make -C ocamltest) will run the first rule of the ocamltest Makefile, which happens to be the 'all' rule. This is not robust to the addition of new rules in some of the included Makefile, and indeed a previous version of the previous commit broke it inadvertently.
On my machine, a sequential build of (make all allopt) goes from 31s to 11s, and a parallel build (-j5) goes from 16s to 6s.
On my machine the sequential build time goes from 7.5s to 3.5s.
On my machine the sequential build time goes from 3.7s to 1.3s
On my machine, the sequential build time goes from 30s to 10s.
389c4a5 to
39071d1
Compare
|
Thanks! (I'm sorry for my sprout of grumpiness now.) I had just rebased the PR to fix the check-typo issue, so we should wait for CI. |
|
I took no grumpiness 🙂 - feel free to merge when AppVeyor comes back |
|
I presume as you rebased you'd like to keep the commit history? |
|
I just merged, thanks everyone for the feedback. |
This PR supersedes #8839, it tweaks the build system to use native-compiled compilers (and lexer) in most of the tools that can be compiled after the .opt compilers are built in the opt.opt (world.opt) build scenarios: otherlibs, ocamltest, ocamldoc and the debugger.
On my machine the total
world.optbuild time with-j5decreases from 3m30s to 2m50s, and it seems to save around a minute of CPU time.