xla
xla copied to clipboard
CMake build support
XLA builds with Bazel at the moment, is it desirable to also have a CMake build? Who would benefit from this and what workflow will this enable that aren't doable or easy with the current Bazel configuration?
May be not a strong reason but: In some teams all of they software packages are built with CMake, except TF/XLA. It will make it easier for the team manage the build process of its software packages, if XLA is able to also provide CMake build support.
Hello, Bazel has made things tricky for folk in a couple of ways:
- Assumption of network access. Distro build daemons typically do not build with network access and some corporate systems have restricted network access, working around this typically involves fetching assets separately then "preloading" them in a cache just before build,
- Multiple versions of Bazel needed. Distros have to carry around a few different versions of Bazel, each one to match up with the particular projects (newer versions of Bazel have not always been backwards compatible with older projects).
It would be incredibly helpful for distros (and others I suspect) to have cmake support, to fall back to.
Is this still actively maintained?
https://github.com/google/bazel-to-cmake
Is this still actively maintained?
https://github.com/google/bazel-to-cmake
fwiw such a script exists inside iree https://github.com/openxla/iree/tree/main/build_tools/bazel_to_cmake
I recall being very happy to see this to be the issue #1 🙃
is it desirable to also have a CMake build?
In short, I'd suggest "yes, from the point of view of (package) distributions", because Bazel doesn't support/maybe even hinders dependency injection (in the broad sense, thinking e.g. of cmake's find_package
), which is important for achieving consistent package sets/applying patches consistently. For this to be useful in practice, however, one'd also need downstream projects like tensorflow to use xla in a way that permits substitution
Another thing is the efficiency of the build: Bazel is building the code twice (or thrice sometimes) because of host/target split model. CMake does not suffer from this restriction, so a CMake build on my workstation could be easily twice as fast.
It is also much easier to setup things like "use my prebuilt LLVM" which helps again having much fast build since you only build the XLA code and not "the world".
(Docker containers can be used for dependency and controlling the environment, instead of relying on Bazel for making everything hermetic, at a high cost)
fwiw i'm finding bazel extremely difficult to use, and i'm not totally inept. A look on the internet suggests it's a common problem. I'm very very much in favour of a simple build tool. I don't know if CMake is that, never used it. I imagine this would be appreciated more widely for an opensource project.