This is an archive of the discontinued LLVM Phabricator instance.

Bazel BUILD file for BOLT
ClosedPublic

Authored by tmsriram on Jul 15 2022, 12:55 PM.

Details

Summary

Create a Bazel BUILD file for BOLT.

Diff Detail

Event Timeline

tmsriram created this revision.Jul 15 2022, 12:55 PM
Herald added a reviewer: Amir. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: ayermolo. · View Herald Transcript
tmsriram requested review of this revision.Jul 15 2022, 12:55 PM

Thanks for contributing the Bazel file :) It's probably best to split the atomic rename part to a separate patch.

tmsriram updated this revision to Diff 445124.Jul 15 2022, 1:57 PM

Splitting the changes.

brooksmoses accepted this revision.Jul 19 2022, 3:55 PM
This revision is now accepted and ready to land.Jul 19 2022, 3:55 PM
tmsriram edited the summary of this revision. (Show Details)Jul 19 2022, 3:56 PM
jgorbe accepted this revision.Jul 19 2022, 3:57 PM

Looks good to me.

This revision was landed with ongoing or failed builds.Jul 19 2022, 4:06 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2022, 4:06 PM
Amir added a comment.Jul 19 2022, 4:56 PM

Thank you for working on it. I was able to build llvm-bolt using the following:

llvm-project/utils/bazel$ bazel build --config=generic_gcc @llvm-project//bolt:llvm-bolt

Couple of questions:

  1. Do I understand it correctly that BUILD.bazel file need to be kept in sync with CMakeLists.txt?
  2. Is it possible to run check-bolt tests with bazel?

Couple of questions:

  1. Do I understand it correctly that BUILD.bazel file need to be kept in sync with CMakeLists.txt?

Yes. In general, there's no way to automatically get the Bazel configuration from the CMake one.

  1. Is it possible to run check-bolt tests with bazel?

Assuming that check-bolt runs lit tests, no. Support for lit tests is not available in the Bazel build. I prototyped something, but couldn't get it working with LLVM's peculiar layer on top of lit that is deeply intertwined with the CMake build. Some more discussion here: https://discourse.llvm.org/t/bazel-and-check-mlir-target-does-bazel-support-running-lit-tests/61898/6?u=gcmn

Amir added a comment.Jul 19 2022, 10:38 PM

Couple of questions:

  1. Do I understand it correctly that BUILD.bazel file need to be kept in sync with CMakeLists.txt?

Yes. In general, there's no way to automatically get the Bazel configuration from the CMake one.

I see. I know that bazel build is enabled in pre-merge checks but they are flaky at times, and may not trigger for direct pushes. I may look into adding a buildbot configuration with bazel build. If you have any examples of using bazel in buildbot, please let me know.

  1. Is it possible to run check-bolt tests with bazel?

Assuming that check-bolt runs lit tests, no. Support for lit tests is not available in the Bazel build. I prototyped something, but couldn't get it working with LLVM's peculiar layer on top of lit that is deeply intertwined with the CMake build. Some more discussion here: https://discourse.llvm.org/t/bazel-and-check-mlir-target-does-bazel-support-running-lit-tests/61898/6?u=gcmn

Right, it invokes lit underneath. I would assume that you still use cmake build for LLVM testing?

Couple of questions:

  1. Do I understand it correctly that BUILD.bazel file need to be kept in sync with CMakeLists.txt?

Yes. In general, there's no way to automatically get the Bazel configuration from the CMake one.

  1. Is it possible to run check-bolt tests with bazel?

Assuming that check-bolt runs lit tests, no. Support for lit tests is not available in the Bazel build. I prototyped something, but couldn't get it working with LLVM's peculiar layer on top of lit that is deeply intertwined with the CMake build. Some more discussion here: https://discourse.llvm.org/t/bazel-and-check-mlir-target-does-bazel-support-running-lit-tests/61898/6?u=gcmn

Couple of questions:

  1. Do I understand it correctly that BUILD.bazel file need to be kept in sync with CMakeLists.txt?

Yes. In general, there's no way to automatically get the Bazel configuration from the CMake one.

I see. I know that bazel build is enabled in pre-merge checks but they are flaky at times, and may not trigger for direct pushes. I may look into adding a buildbot configuration with bazel build. If you have any examples of using bazel in buildbot, please let me know.

  1. Is it possible to run check-bolt tests with bazel?

Assuming that check-bolt runs lit tests, no. Support for lit tests is not available in the Bazel build. I prototyped something, but couldn't get it working with LLVM's peculiar layer on top of lit that is deeply intertwined with the CMake build. Some more discussion here: https://discourse.llvm.org/t/bazel-and-check-mlir-target-does-bazel-support-running-lit-tests/61898/6?u=gcmn

Right, it invokes lit underneath. I would assume that you still use cmake build for LLVM testing?

Couple of questions:

  1. Do I understand it correctly that BUILD.bazel file need to be kept in sync with CMakeLists.txt?

Yes. In general, there's no way to automatically get the Bazel configuration from the CMake one.

  1. Is it possible to run check-bolt tests with bazel?

Assuming that check-bolt runs lit tests, no. Support for lit tests is not available in the Bazel build. I prototyped something, but couldn't get it working with LLVM's peculiar layer on top of lit that is deeply intertwined with the CMake build. Some more discussion here: https://discourse.llvm.org/t/bazel-and-check-mlir-target-does-bazel-support-running-lit-tests/61898/6?u=gcmn

I want to mention the Bazel build is an unofficial build system and keeping it work isn't the community's responsibility.
Keeping it work is appreciated by folks who use the Bazel build, though.

I see. I know that bazel build is enabled in pre-merge checks but they are flaky at times, and may not trigger for direct pushes. I may look into adding a buildbot configuration with bazel build. If you have any examples of using bazel in buildbot, please let me know.

We have a Buildkite pipeline that builds every commit: https://buildkite.com/llvm-project/upstream-bazel. Alerts are sent to https://groups.google.com/g/llvm-bazel-alerts. See https://github.com/llvm/llvm-project/tree/main/utils/bazel#continuous-testing. You're welcome to build something with the buildbot infrastructure, but I would first look into why pre-merge tests use a different infra than post-merge and what the long-term plan is. There's currently an effort underway to move a bunch of the infra that's currently run by Google directly to instead be under the auspices of the LLVM foundation, Google having donated the necessary GCP credits to do so. See, e.g. https://github.com/llvm/llvm-iwg/issues/112

I want to mention the Bazel build is an unofficial build system and keeping it work isn't the community's responsibility.
Keeping it work is appreciated by folks who use the Bazel build, though.

Yes, thanks for flagging that. @Amir, if you do anything with a build bot, you'd need to ensure it only notifies those that have opted in in some way. I think a patch editing utils/bazel would count as opting in if that patch was in the blame list. There's also the phabricator project people can join. Note how the Bazel pre-merge testing is enabled: https://github.com/llvm/llvm-project/tree/main/utils/bazel#pre-merge-testing