xla icon indicating copy to clipboard operation
xla copied to clipboard

CMake build support

Open joker-eph opened this issue 2 years ago • 4 comments

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?

joker-eph avatar Aug 09 '22 16:08 joker-eph

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.

etherzhhb avatar Aug 09 '22 17:08 etherzhhb

Hello, Bazel has made things tricky for folk in a couple of ways:

  1. 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,
  2. 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.

stevecapperarm avatar Aug 11 '22 13:08 stevecapperarm

Is this still actively maintained?

https://github.com/google/bazel-to-cmake

bhack avatar Sep 10 '22 13:09 bhack

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

makslevental avatar Mar 14 '23 23:03 makslevental

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

SomeoneSerge avatar Feb 14 '24 20:02 SomeoneSerge

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)

joker-eph avatar Feb 14 '24 21:02 joker-eph

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.

joelberkeley avatar Mar 24 '24 20:03 joelberkeley