-
Notifications
You must be signed in to change notification settings - Fork 99
The State of the PPX Transition
The issues we were facing and are tackling with our current plan are the following:
-
To keep the PPX ecosystem cross-compiler compatible
a)
ppxlib
was handling and abstracting away parts of the unstablecompiler-libs
API;b)
OMP
/ppxlib
was keeping the AST migration information up-to-date.That situation required us and the compiler developers to coordinate for each compiler release in order to guarantee that the new compiler could be used in projects with ppx rewriters.
-
To guarantee new feature support,
ppxlib
needs to bump theppxlib
AST to the newest version, which implies a breaking change. That was an issue for a homogeneous and up-to-date PPX ecosystem. -
Not all ppx rewriters had migrated from
OMP
toppxlib
. That was also an issue for a homogeneous and up-to-date PPX ecosystem.
The first part of our plan works towards continuous cross-compiler compatibility (Issue 1. above) while making the situation of still having ppx rewriters based on OMP
(Issue 3. above) even more of a problem. It consists of implementing an interface module called Astlib
between ppxlib
and the compiler, then upstreaming it to the compiler. Here are its six steps:
- Moving the
OMP
driver and otherOMP
features fromOMP
toppxlib
. That was done in August 2020, and it introducedOMP2
. This was the start of having the PPX ecosystem split into the two incompatible worlds ofOMP1
ppx rewriters on one hand andppxlib
ppx rewriters on the other hand. - Reducing the
compiler-libs
usage inppxlib
as much as possible to keepAstlib
minimal. That has been completed over time. - Implementing a
ppxlib
internal version ofAstlib
as a layer betweenppxlib
and the compiler. The first ppxlib version containingAstlib
is 0.23.0. - Working on an upstream version of
Astlib
for the compiler and adapting the tooling to update the AST migration logic to the compiler. That's next on our ToDo list. - Discussing the upstream version and the workflow to update the AST migrations with the compiler developers, with the aim to upstream it.
- Simultaneously to upstreaming
Astlib
, implementing the logic to use our internalAstlib
on old compilers and the upstreamAstlib
on new compilers intoppxlib
.
This part of the plan got a bit delayed when the compiler got frozen to integrate multi-core support. With our current roadmap, we're aiming for having Astlib
upstreamed into OCaml 5.1.0.
Moving the driver from OMP
to ppxlib
(Step 1. above) made the fact that some ppx rewriters were still based on OMP
(Issue 3. above) even more of a problem since it split the PPX world in two. For some PPX developers, the reason to avoid porting their ppx rewriters to ppxlib
was that ppxlib
depended on base
and stdio
, so we decided to tackle this situation by three means:
- Dropping the
base
and thestdio
dependencies, which was done in August 2020. - Porting and reviewing some of the most important ppx rewriters ourselves. So far we've ported
js_of_ocaml
,bisect_ppx
, andtyxml
with the help of the respective maintainers, and we've also reviewed several ports. - Spreading the word about the need to port ppx rewriters and asking for help. A lot of people have joined the effort!
In summer 2020, we made a non-exhaustive list of ppx rewriters to be ported. By now (January 2022), all ppx rewriters on that list have been ported.
Our current plan doesn't provide a solution for the problem that a few ppx rewriters break whenever we bump the ppxlib
AST (Issue 2. above), but it does make handling the problem more efficient and takes away the burden from the PPX developers. Since the AST bump to 4.10
, whenever we bump the AST, we create a workspace with all ppx rewriters fulfilling a certain standard, fix the rewriters that break all at once, and open patch PRs. We call that workspace the ppx-universe
. You can find a ppx-universe snapshot on our repo.
Our plan is to make the tooling that creates and interacts with the workspace more sophisticated. We use opam-monorepo as main tool. For the rest, we are currently using a ppxlib-specific bash script.