Stop comparing compiler outputs in the testsuite#12339
Stop comparing compiler outputs in the testsuite#12339lthls wants to merge 1 commit intoocaml:trunkfrom
Conversation
|
Just to make sure I understand: are you saying that the pure bytecode executables produced by |
|
For reference, we did the same thing for the native-code compiler in #9677. |
|
If I remember correctly there are parts of the bytecode executable that are generated using But if somebody knows how to investigate these errors and is willing to share tips, I could try to find out more precisely what's going on. |
|
I would agree. Quoting the justification provided by @nojb in the native issue:
This is all true for bytecode as well. I find it frustrating, from a reproducible-builds perspective, that our compiler output is fragile in this way, but I don't see an easy solution (see the discussion in #8853 for an example of the difficulties) and I don't think that trying to check a property that we don't actually guarantee in practice is a good use of our workforce. |
|
Sorry for the delayed response.
As a coincidence, @damiendoligez and I had discussed this topic offline
last monday. We came to a slightly different conclusion which I starrted
to implement. The idea would be not only to stop comparing compiler
outputs but also to stop compiling programs twice per backend.
So, for instance, if the native compiler is enabled, then one would
compile bytecode programs only with ocamlc.opt and native programs
only with ocamlopt.optn which would I think save a significant amount of
time for running the testsuite.
I started to implement it to produce numbers but it was a bit more work
than I expected because of the way ocamltest is designed.
I intend to continue to work on that and expect to be able to show
someting soon, unless it is considered a bad idea.
|
I think it is a good idea. If you are open to suggestions, I would like the ability to choose which versions of the tools to use through a |
|
I would go beyond @lthls: I very often have compilers in their default configuration (so in particular, native code is enabled), but where I have only built the bytecode tools. It is important for me that I can test the bytecode tools in this configuration. ocamltest and the testsuite Makefiles make this difficult for me today, and some ways to implement the change that you propose could make things worse. |
|
(The reason to do this is that the bytecode tools are much faster to build, and the only thing I care about when working on the frontend -- parser, type-checker, etc.) |
|
For reference, the default sequence of actions for a test is, currently,
There used to be a step 4 "Compare the two native-code executables" but it was removed as unreliable. This PR proposes to remove step 8 for the same reason. The "recompiling" steps 3 and 7 are pretty useless if we don't do anything with the produced executables. Initially, ocamltest would run them, but that was removed a long time ago as it was taking too much time. So, I agree with the idea of compiling only with ocamlopt.byte + ocamlc.byte or only with ocamlopt.opt + ocamlc.opt, provided there's an easy way to choose which compilers are used. As @lthls mentioned, when there's a bug in the native-code compiler, or when we're working on a new port, ocamlopt.opt and ocamlc.opt are unreliable, and using them to build a test case means that the compiler will crash before the test case can be run, making it impossible to use the test cases to locate the problem. When I did the POWER port of OCaml 5, I ended up compiling and running many tests by hand, without ocamltest, because of this. So, we must have a way to use only the .byte compilers when running the test suite. |
|
So you'd like to use only `ocamlc.byte` and not e.g. `ocamlopt.byte`,
even if it's there, right?
Assume we would have two environment variables:
`OCAML_TESST_{BYTECODE,NATIVE}_COMPILER` that would disable the
corresponding test if set to `false`, would that satisfy your needs?
|
|
Gabriel Scherer (2023/07/01 05:23 -0700):
I would go beyond @lthls: I very often have compilers in their default
configuration (so in particular, native code is enabled), but where I
have only built the bytecode tools. It is important for me that I can
test the bytecode tools in this configuration. ocamltest and the
testsuite Makefiles make this difficult for me today, and some ways to
implement the change that you propose could make things worse.
I'm curious on why/how you end-up in such situations, @gasche?
If your wish to work on the bytecode compiler only, why don't you
explicitly configure with `--disable-native-compiler`?
|
|
Gabriel Scherer (2023/07/01 05:24 -0700):
(The reason to do this is that the bytecode tools are much faster to
build, and the only thing I care about when working on the frontend --
parser, type-checker, etc.)
Well but then I think the most efficient way to go is to just disable
them at configure time and then you can just type make and things will
work.
|
I have a local build of |
No, I'd like to use
I'm not sure what the "corresponding tests" are. I don't want to disable tests, just be able to run them with the .byte compilers and not the .opt compilers. |
|
Gabriel Scherer (2023/07/17 07:56 -0700):
I have a local build of `trunk` which I rebuild incrementally after
`git pull`. I create feature or bugfix branches from it, without
cleaning the local artifacts. Sometimes I want to work on a
type-checker bugfix, and I want to rebuild just the `core` target and
then re-run the testsuite. Sometimes I want to work on a
native-compiler and rebuild `ocamlopt` -- depending on the context I
would or wouldn't want to build the `.opt` targets as well in this
case.
I see. Thanks for having taken the time to explain. Have you considered
using different worktrees? You'd be able to configure each of them
accordingto your needs and have access to all of them in parallel.
|
|
Xavier Leroy (2023/07/17 07:59 -0700):
> So you'd like to use only `ocamlc.byte` and not e.g. `ocamlopt.byte`, even if it's there, right?
No, I'd like to use `ocamlc.byte` even if `ocamlc.opt` is there, and
likewise for `ocamlopt.byte` even if `ocamlopt.opt` is there.
I was responding to Vincent's comment, actually.
|
I could create a new worktree for each feature branch, but that means I would have to do a cold build each time, and manage their garbage-collection manually. I could try to have one worktree per broad configuration (frontend changes only, ocamlopt, runtime, etc.), but that is also more work on my end, more disk space, etc. I already have one worktree per release branch plus trunk, and while I mostly use this partial-build workflow on I understand that some things have to be fixed at configuration time for various software-engineering reasons; for example, currently we can only choose one native backend at a time, and flambda is a configure-time option. Having to create worktrees for those is inevitable. But ideally it would be possible to run a subset of the testsuite without having to decide it at configure-time. |
My use-case is the same as Xavier's: the |
While working on #12232 I got bitten by the comparison check failing.
I suspect that it's a harmless difference in memory layouts (usually sharing) between
ocamlc.byteandocamlc.opt, and with no way to actually get useful info out of the test failure, and no simple way to disable this check, I decided to propose this PR, which turns off the binary comparison of executables from the default bytecode rule.I did check that running
dumpobjon the two programs produced the exact same output in my case, so the difference is likely in the rest of the data stored in the executable.Cc @shindere as it's an ocamltest patch.