Compile tools/make_opcodes with -custom#10293
Conversation
Ensures that it's always executable, even if the bytecode interpreter is being bootstrapped with changed opcodes.
The -custom option will use whatever configuration built boot/ocamlc, which may well not be correct! Instead, use the cat'ing trick directly.
|
Oops, I forgot that |
|
I agree we have a problem, but I don't think I see in the toplevel Makefile that make_opcodes is run with runtime/ocamlrun. Bootstrap-wise, it would work better with boot/ocamlrun, provided that the tools is not built with I think we need to check tools/ w.r.t. bootstrapping and understand what we want first. |
|
Also: insert my standard rant about using OCaml too early while building OCaml. We keep running into this mistake like a moth keeps flying into a bright light. |
I did some other poking around before settling on
I agree, although let's not forget the amount of fighting we also do with sed and awk! Another option, a la #1078, might be to add the script as an option in |
We're in 2021 and there are better scripting languages widely available and used. E.g. Python. |
|
Maybe we could decide that the problem is not worth solving. Do we really need to remove opcodes from the list? Let's just turn them into NOPs and declare them unused/reserved/deprecated/whatever. |
|
For this particular instance that wouldn't work, because the aim was to bring the opcode values back into line with trunk. It seems safe to assume that it won't happen often, but that it'll never happen again - in this case, documenting it almost seems more long-winded than fixing it? |
|
My understanding is that people agree that there is a problem worth solving (at least I would agree), but the specific solution proposed in this PR has been clearly vetoed: no I'm feeling bold today on my closing-PR-spree, so let me just close this. @dra27, please of course feel free to revisit with another option (you mentioned obscure changes to |
Prior to #803,
bytecomp/opcodes.ml*andtools/opnames.mlwere generated by awk and sed scripts. They're now generated infinitely less hideously, but more bootstrappingly complicatedly, with an ocamllex script.@ctk21 hit a problem with multicore trying to change bytecode opcodes (the aim is in fact to remove opcodes which are no longer required, but which were not originally added at the end of the opcode list). Presently, the build system assumes that
tools/make_opcodesexecutes withruntime/ocamlrunbut this is incorrect during a change to the opcodes. Aftermake corehas been run and changes applied,tools/make_opcodesshould be executed withboot/ocamlrun, notruntime/ocamlrun. That change is easy enough to make, but the bootstrap cycle is more complicated - the correct runtime gets cleaned during the bootstrap.This PR is the simplest path for fixing this - we store the runtime used to build
tools/make_opcodeswithtools/make_opcodesby using-custom! I don't think there's any downside to this, beyond slightly more space being used during the build - we don't install the file, so none of the usual problems with-customapply. I don't think we were ever planning on completely removing-custom, but if we did then it would be perfectly reasonable to switch to-output-complete-exe, I haven't done that here because-customis technically quicker (it's a copy vs calling the linker).Note that #1659 would not have been affected by this because an added opcode means that
tools/make_opcodeswas executable at all times withruntime/ocamlrun. However, the issue would be seen if the exec magic number were bumped at the same time (it wasn't in that PR, although arguably it ought to have been).