Skip to content
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

Support OCaml 5.2 #470

Merged
merged 1 commit into from
Feb 6, 2024
Merged

Conversation

leostera
Copy link
Contributor

@leostera leostera commented Nov 13, 2023

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

src/lib/uTop_compat.ml Outdated Show resolved Hide resolved
@ManasJayanth
Copy link

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
Copy link
Collaborator

emillon commented Nov 14, 2023

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:

  • put this in dune-workspace.multi (do not commit this file to the repository)
(lang dune 1.0)
(context (opam (switch utop-411)))
(context (opam (switch utop-412)))
(context (opam (switch utop-413)))
(context (opam (switch utop-414)))
(context (opam (switch utop-500)))
(context (opam (switch utop-510)))
(context (opam (switch utop-520)))
  • create N global switches named like the above and based on the corresponding ocaml compiler version, and install the dev-deps in them. You'll never activate these switches directly
$ 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)

  • then instead of the usual dune build, use dune build --workspace dune-workspace.multi. This is going to make a dune build that builds using all the different switches. Error messages will carry the name of the opam switch that failed, so you can use that to know what went wrong.

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.

Copy link
Collaborator

@emillon emillon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, many comments regarding organization but this is going to work.

src/lib/uTop.ml Outdated Show resolved Hide resolved
src/lib/uTop.ml Outdated Show resolved Hide resolved
src/lib/uTop.mli Outdated Show resolved Hide resolved
src/lib/uTop_main.ml Outdated Show resolved Hide resolved
src/lib/uTop_main.ml Outdated Show resolved Hide resolved
src/lib/uTop_main.ml Outdated Show resolved Hide resolved
src/lib/uTop_main.ml Outdated Show resolved Hide resolved
src/lib/uTop_main.ml Show resolved Hide resolved
@leostera
Copy link
Contributor Author

@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 🙌🏼

CONTRIBUTING.md Outdated Show resolved Hide resolved
#endif
end

let is_abstract_type_kind type_kind =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor remark, but I think we can keep the type_kind = part in the guard and just expose abstract_type_kind

@@ -394,7 +394,7 @@ let visible_modules () =
(Sys.readdir (if dir = "" then Filename.current_dir_name else dir))
with Sys_error _ ->
acc)
String_set.empty @@ Load_path.get_paths ()
String_set.empty @@ (UTop_compat.get_load_path ())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ and parens are redundant here

src/lib/uTop_main.ml Outdated Show resolved Hide resolved
@emillon
Copy link
Collaborator

emillon commented Dec 22, 2023

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

Co-authored-by: Rashid Al Muhairi <r.muhairi@pm.me>
@emillon
Copy link
Collaborator

emillon commented Feb 6, 2024

@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
Copy link
Collaborator

emillon commented Feb 6, 2024

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

@emillon emillon merged commit 4a97c4c into ocaml-community:master Feb 6, 2024
1 check passed
@leostera leostera deleted the ocaml-5-support branch February 6, 2024 11:59
@kit-ty-kate
Copy link
Contributor

Would it be possible to get a new release?

@pmetzger
Copy link
Member

pmetzger commented Feb 8, 2024

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

@emillon
Copy link
Collaborator

emillon commented Feb 9, 2024

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
Copy link
Contributor

alpha1 is already available but ocaml-ci hasn't been updated yet. This is tracked at ocurrent/ocaml-ci#917

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

emillon added a commit to emillon/opam-repository that referenced this pull request Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OCaml 5.2 support
5 participants