ocaml-community / utop

Universal toplevel for OCaml
Other
833 stars 110 forks source link

Support OCaml 5.2 #470

Closed leostera closed 5 months ago

leostera commented 8 months ago

Hi folks! I saw Sabine's tweet and I figured I'd give this a shot. There's a few things that I'd like to upstream to the compiler (like Ast_helpers to create function params), but otherwise this seems to be working.

Screenshot 2023-11-13 at 18 05 01

Happy to amend anything here, just figured I'd open the PR early to get feedback / directions.

Ideally would close #466

ManasJayanth commented 8 months ago

Got here too late: My branch is here https://github.com/DiningPhilosophersCo/utop/tree/prometheansacrifice%40ocaml-5-2 Atleast I think I can lend a hand with a code review. Will leave a comment if necessary. This was fun!

emillon commented 8 months ago

Thanks for this PR. I think that this is going in the right direction but the main thing that is left to address is compatibility. This version of utop needs to build and run on OCaml 4.11 to 5.2.0 (that seems large but bear in mind that I've already axed much of the compatibility so it's a lot easier than it used to be). To have a system where it is easy to test compat code, I recommend the following set up:

$ opam sw create utop-411 ocaml-base-compiler.4.11.1
$ opam install --switch utop-411 utop --deps-only --with-test
...
$ opam sw create utop-510 ocaml-base-compiler.5.1.0
$ opam install --switch utop-510 utop --deps-only --with-test
$ opam sw create utop-520 ocaml-variants.5.2.0+trunk
$ opam install --switch utop-520 utop --deps-only --with-test

(note the --switch ... flags passed to install, and the fact we used ocaml-base-compiler everywhere but ocaml-variants in the 5.2.0 case)

This is the main trick and the most important part to get a green build on all supported versions.

Now, regarding architecture, utop used to have many #ifs sprinkled all around the code base. I moved most of them to uTop_compat.ml. Please aim to put new compat code in there but I appreciate that it's not always possible.

I'll leave the rest of my comments as a review. Thanks again.

leostera commented 7 months ago

@emillon thanks for the guidance! 🙏🏼 made most of the changes (except the add_cmi_hook, but left you a question there). Let me know how you want to proceed 🙌🏼

emillon commented 6 months ago

(I haven't forgotten, I'll get back to you about this during week 1)

emillon commented 5 months ago

@leostera I rebased this on top of master, added a changelog crediting all coauthors.

This is good to go for a release supporting 5.2 but there will probably be things to fix regarding hidden paths, and we'll have to decide if we want to provide a precise API for the load path.

emillon commented 5 months ago

Thanks everyone. that was the first time I was looking for external contributors and this was very succesful, despite the delay in merging!

kit-ty-kate commented 5 months ago

Would it be possible to get a new release?

pmetzger commented 5 months ago

@kit-ty-kate You don't have access to do that on your own? We could give it to you.

emillon commented 5 months ago

as I said previously, I'm waiting for 5.2 in ocaml-ci to cut the release to make sure it works there. this should happen after the first alpha, right?

kit-ty-kate commented 5 months ago

alpha1 is already available but ocaml-ci hasn't been updated yet. This is tracked at https://github.com/ocurrent/ocaml-ci/issues/917

In the meantime, is there any chance you could spawn an opam switch locally instead? It should take less than 3 minutes