Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to bazel 7 #1878

Closed
mlevesquedion opened this issue Dec 11, 2023 · 0 comments · Fixed by #2006
Closed

Migrate to bazel 7 #1878

mlevesquedion opened this issue Dec 11, 2023 · 0 comments · Fixed by #2006

Comments

@mlevesquedion
Copy link
Contributor

mlevesquedion commented Dec 11, 2023

Bazel 7 (bazelbuild/bazel#18548) seems to introduce some changes that break our tests.

We should look into what is needed to migrate to Bazel 7 and do the migration. For now, we can pin the Bazel version to avoid breakages.

This page has instructions on how to migrate.

I'm not sure exactly what the source of the issue is, but I'm seeing this failure in all our tests (I don't see such failures with Bazel < 7):

exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //stablehlo/testdata:vmap_gather_from_take_indices_name__4__axis_2_enable_xla_True_mode_clip_dynamic.mlir.test
-----------------------------------------------------------------------------
lit.py: $HOME/.local/lib/python3.11/site-packages/lit/TestingConfig.py:151: fatal: unable to parse config file '/tmp/bazel-working-directory/_main/bazel-out/k8-fastbuild/bin/stablehlo/testdata/vmap_gather_from_take_indices_name__4__axis_2_enable_xla_True_mode_clip_dynamic.mlir.test.runfiles/_main/stablehlo/testdata/lit.site.cfg.py', traceback: Traceback (most recent call last):
  File "$HOME/.local/lib/python3.11/site-packages/lit/TestingConfig.py", line 139, in load_from_path
    exec(compile(data, path, "exec"), cfg_globals, None)
  File "/tmp/bazel-working-directory/_main/bazel-out/k8-fastbuild/bin/stablehlo/testdata/vmap_gather_from_take_indices_name__4__axis_2_enable_xla_True_mode_clip_dynamic.mlir.test.runfiles/_main/stablehlo/testdata/lit.site.cfg.py", line 21, in <module>
    lit_config.load_config(config, os.path.join(os.environ['TEST_SRCDIR'], 'stablehlo') + "/stablehlo/testdata/lit.cfg.py")
  File "$HOME/.local/lib/python3.11/site-packages/lit/LitConfig.py", line 136, in load_config
    config.load_from_path(path, self)
  File "$HOME/.local/lib/python3.11/site-packages/lit/TestingConfig.py", line 126, in load_from_path
    f = open(path)
        ^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/bazel-working-directory/_main/bazel-out/k8-fastbuild/bin/stablehlo/testdata/vmap_gather_from_take_indices_name__4__axis_2_enable_xla_True_mode_clip_dynamic.mlir.test.runfiles/stablehlo/stablehlo/testdata/lit.cfg.py'

Thanks to @j2kun for filing google/heir#332, which helped me figure out what the issue was and what a fix could look like.

GleasonK pushed a commit that referenced this issue Dec 11, 2023
This should be an effective stopgap for migrating to Bazel 7, which
currently breaks our bazel build. This version of bazel should be
supported until EOY 2025: https://bazel.build/release\#support-matrix

This specific version was chosen to align with XLA:
https://github.com/openxla/xla/blob/83bcebe6dd1081ab501d8d6689153c6bc3ba0344/.bazelversion#L1

#1878
fzakaria added a commit that referenced this issue Feb 13, 2024
Major change: Bump Bazel to the new LTS at 7.X

* Included a default Python toolchain 3.10

  There is a problem at the moment running lit using Python311 where it
  cannot find the module.

  Our CI system already enforces Python310 to get around it but we should
  set the toolchain in Bazel itself to avoid this problem.
  I had already filed llvm/llvm-project#75963

* I moved skylib to MODULE.bazel to test the MODULE portion of Bazel is
working. A remaining action item is to move LLVM itself to MODULE.bazel
which would preclude needing to define skylib since its a dependency of
LLVM.

* Workspace names are no longer named in Bazel 7+
  
  I had to change stablehlo to _main to fix the runfiles directory.
  Please see bazelbuild/bazel#18128

We should consider using
https://github.com/bazelbuild/rules_python/blob/main/python/runfiles/runfiles.py#L262
instead to get the runfiles directory for future proofing.

Fixes #1878

---------

Co-authored-by: mlevesquedion <mlevesquedion@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant