Lots of PPX transformations: optimize ppx executables for speed
We can control ppx_executable builds using Bazel's toolchain and platform mechanisms. The ppx attribute on ocaml_module and ocaml_signature is marked as executable, which requires that it also be marked (via the cfg attribute) for configuration transition. Currently we use cfg = "target", which ensures that the ppx_executable and all of its dependencies target the same platform as the depending (module or signature) target. This is essential since ppxes may carry ppx co-dependencies, which they inject into the sources they transform.
We should be able to control this config transition using a custom transition function. That function would set the host_platform and platforms settings, thereby controlling selection of the toolchain used to build the ppx executable and its deps. So to optimize for build time, we would select a toolchain that runs in the vm. To optimize for ppx execution time, we would select a toolchain that emits native code.
This would require some additional machinery to control the build of co-dependencies, since they would have to be built with the original toolchain, not the one selected to build the ppx executable.
We can control
ppx_executable
builds using Bazel's toolchain and platform mechanisms. Theppx
attribute onocaml_module
andocaml_signature
is marked as executable, which requires that it also be marked (via thecfg
attribute) for configuration transition. Currently we usecfg = "target"
, which ensures that the ppx_executable and all of its dependencies target the same platform as the depending (module or signature) target. This is essential since ppxes may carry ppx co-dependencies, which they inject into the sources they transform.We should be able to control this config transition using a custom transition function. That function would set the
host_platform
andplatforms
settings, thereby controlling selection of the toolchain used to build the ppx executable and its deps. So to optimize for build time, we would select a toolchain that runs in the vm. To optimize for ppx execution time, we would select a toolchain that emits native code.This would require some additional machinery to control the build of co-dependencies, since they would have to be built with the original toolchain, not the one selected to build the ppx executable.