Skip to content

Comments

feat: bazel 9.0 migration#3496

Open
Alexandr-Solovev wants to merge 14 commits intouxlfoundation:mainfrom
Alexandr-Solovev:dev/asolovev_bazel_9
Open

feat: bazel 9.0 migration#3496
Alexandr-Solovev wants to merge 14 commits intouxlfoundation:mainfrom
Alexandr-Solovev:dev/asolovev_bazel_9

Conversation

@Alexandr-Solovev
Copy link
Contributor

@Alexandr-Solovev Alexandr-Solovev commented Jan 28, 2026

Description

Add Bazel 9.0 Support

Summary

This PR adds support for Bazel 9.0 and updates the build configuration to be compatible with the latest Bazel changes.

Main Changes

  • Migrated multiple built-in Bazel C++ features to external rules_cc rules.
  • Added explicit loads for C++ helpers:
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
  • Added rules_shell dependency to support sh_binary targets:
bazel_dep(name = "rules_shell", version = "0.6.1")

Motivation

Bazel 9.0 moves several features out of the core distribution into external rule sets. This PR aligns the project with the new structure and ensures forward compatibility.


Checklist:

Completeness and readability

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes or created a separate PR with updates and provided its number in the description, if necessary.
  • Git commit message contains an appropriate signed-off-by string (see CONTRIBUTING.md for details).
  • I have resolved any merge conflicts that might occur with the base branch.

Testing

  • I have run it locally and tested the changes extensively.
  • All CI jobs are green or I have provided justification why they aren't.
  • I have extended testing suite if new functionality was introduced in this PR.

Performance

  • I have measured performance for affected algorithms using scikit-learn_bench and provided at least a summary table with measured data, if performance change is expected.
  • I have provided justification why performance and/or quality metrics have changed or why changes are not expected.
  • I have extended the benchmarking suite and provided a corresponding scikit-learn_bench PR if new measurable functionality was introduced in this PR.

@Alexandr-Solovev Alexandr-Solovev changed the title fixes bazel 9.0 migration Feb 5, 2026
@Alexandr-Solovev Alexandr-Solovev marked this pull request as ready for review February 13, 2026 12:27
Copilot AI review requested due to automatic review settings February 13, 2026 12:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the repository’s Bazel/Bzlmod integration to align with a Bazel 9.0 toolchain/rules ecosystem, primarily by switching C++ rule/provider imports to rules_cc and bumping the pinned Bazel version.

Changes:

  • Bump Bazel from 8.5.1 to 9.0.0 and update documented rules_cc version.
  • Migrate multiple BUILD/.bzl files to load C++ rules/providers from @rules_cc (and add rules_shell for sh_binary).
  • Adjust the Linux C++ toolchain Starlark config to use rules_cc-hosted action names/config lib.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
.bazelversion Pins Bazel 9.0.0 for the migration.
MODULE.bazel Adds rules_shell dependency; keeps rules_cc at 0.2.16.
BUILD Adds rules_cc load at repo root (used for Bazel 9 migration consistency).
dev/bazel/AGENTS.md Updates the documented rules_cc version.
dev/bazel/cc.bzl Uses @rules_cc-loaded rules/providers in custom C++ rules.
dev/bazel/cc/common.bzl Switches to @rules_cc-loaded C++ providers/common APIs.
dev/bazel/cc/compile.bzl Switches to @rules_cc-loaded C++ APIs.
dev/bazel/cc/link.bzl Switches to @rules_cc-loaded C++ APIs/providers for linking logic.
dev/bazel/dal.bzl Updates C++ rule loads for Bazel 9/rules_cc alignment.
dev/bazel/release.bzl Uses CcInfo loaded from rules_cc to collect headers/libs.
dev/bazel/deps/ccl.tpl.BUILD Migrates dependency BUILD template to rules_cc loads.
dev/bazel/deps/dpl.tpl.BUILD Migrates dependency BUILD template to rules_cc loads.
dev/bazel/deps/mkl.tpl.BUILD Migrates dependency BUILD template to rules_cc loads.
dev/bazel/deps/mpi.tpl.BUILD Migrates to rules_cc loads and adds sh_binary for mpiexec.
dev/bazel/deps/onedal.tpl.BUILD Migrates dependency BUILD template to rules_cc loads.
dev/bazel/deps/openblas.tpl.BUILD Migrates dependency BUILD template to rules_cc loads.
dev/bazel/deps/opencl.tpl.BUILD Migrates dependency BUILD template to rules_cc loads.
dev/bazel/deps/tbb.tpl.BUILD Migrates dependency BUILD template to rules_cc loads.
dev/bazel/toolchains/cc_toolchain_config_lnx.bzl Moves toolchain config imports to rules_cc equivalents and updates toolchain config info creation signature.
dev/bazel/toolchains/cc_toolchain_lnx.tpl.BUILD Updates toolchain template to load cc_toolchain from rules_cc.

Copilot AI review requested due to automatic review settings February 16, 2026 09:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated no new comments.

@Alexandr-Solovev Alexandr-Solovev added the dependencies Pull requests that update a dependency file label Feb 16, 2026
Copilot AI review requested due to automatic review settings February 16, 2026 12:29
@Alexandr-Solovev Alexandr-Solovev changed the title bazel 9.0 migration feat: bazel 9.0 migration Feb 16, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.

@Alexandr-Solovev
Copy link
Contributor Author

/intelci: run

@Alexandr-Solovev
Copy link
Contributor Author

/intelci: run

Copilot AI review requested due to automatic review settings February 19, 2026 09:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.

#===============================================================================

load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
load("@rules_cc//cc:defs.bzl", "cc_toolchain")
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loaded cc_toolchain symbol from @rules_cc//cc:defs.bzl is not referenced in this file (there are no cc_toolchain(...) calls), and its name is also shadowed by function parameters named cc_toolchain. Consider removing this load (or renaming the parameters if you actually intended to use the loaded rule) to avoid confusion and buildifier/lint warnings.

Suggested change
load("@rules_cc//cc:defs.bzl", "cc_toolchain")

Copilot uses AI. Check for mistakes.
Comment on lines +7 to 13
"*.so",
"*.so.*",
],
exclude = ["*.py", "*.cmake", "*.a"],
allow_empty = True,
),
linkopts = ["-lOpenCL"],
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opencl_binary now globs and adds every *.so/*.so.* in the OpenCL external repo as srcs. In cc_library, prebuilt .so files in srcs participate in linking, so this will pull in all symlinked DPC++ runtime DSOs (e.g., libsycl, libsvml, etc.) into link actions for any target that depends on @opencl//:opencl_binary. If the intent is only to make these DSOs available at runtime, consider separating “link” vs “runtime files” (e.g., keep opencl_binary focused on -lOpenCL / libOpenCL* and expose a separate filegroup for runtime DSOs to be consumed via data).

Suggested change
"*.so",
"*.so.*",
],
exclude = ["*.py", "*.cmake", "*.a"],
allow_empty = True,
),
linkopts = ["-lOpenCL"],
"libOpenCL*.so",
"libOpenCL*.so.*",
],
allow_empty = True,
),
linkopts = ["-lOpenCL"],
visibility = ["//visibility:public"],
)
filegroup(
name = "opencl_runtime_dsos",
srcs = glob(
[
"*.so",
"*.so.*",
],
allow_empty = True,
),

Copilot uses AI. Check for mistakes.
@napetrov
Copy link
Contributor

Draft Comment for PR #3496

General Review

Thanks @Alexandr-Solovev for the Bazel 9.0 migration work! Most of the changes look good. I've reviewed Copilot's comments and have feedback:

🔴 Critical Issue: opencl.tpl.BUILD

Copilot is correct here — the glob is too broad. The current change adds DPC++ runtime libraries (libsycl, libsvml, libirng, libimf, libintlc, libur_loader) to srcs, forcing them into link phase. These should only be available at runtime, not link time.

Recommended fix:

cc_library(
    name = "opencl_binary",
    srcs = glob(
        [
            "libOpenCL*.so",
            "libOpenCL*.so.*",
        ],
        allow_empty = True,
    ),
    linkopts = ["-lOpenCL"],
    visibility = ["//visibility:public"],
)

filegroup(
    name = "dpcpp_runtime_dsos",
    srcs = glob(
        [
            "*.so",
            "*.so.*",
        ],
        exclude = ["libOpenCL*.so*"],
        allow_empty = True,
    ),
    visibility = ["//visibility:public"],
)

And in opencl.bzl, consider restricting symlinks:

libs = [
    "libOpenCL*.so*",
]

Unless you intentionally need all DPC++ runtime libs in link phase? If so, please clarify the use case.


✅ Valid Cleanup (Non-Critical)

Copilot is correct about unused imports — buildifier may complain. Easy fix:

All *.tpl.BUILD files (tbb, mkl, mpi, dpl, ccl, openblas, onedal):

load("@rules_cc//cc:defs.bzl", "cc_library")  # Remove cc_binary, cc_toolchain

cc/link.bzl:

# Remove: load("@rules_cc//cc:defs.bzl", "cc_toolchain")
# (never called as a rule, only used as parameter name)

Other files: cc.bzl, dal.bzl, root BUILD, toolchain files — same pattern.


❌ False Positive

cc/compile.bzl CcInfo comment — incorrect, file only loads cc_common, no unused CcInfo.


Decision

  1. Must fix: opencl.tpl.BUILD glob issue
  2. Should fix: unused imports (buildifier hygiene)
  3. Ignore: CcInfo false positive, AGENTS.md doc mismatch

Let me know if you need clarification on the opencl issue or want me to provide a patch!


Review by @napetrov (with AI assist)

@napetrov
Copy link
Contributor

PR #3496 Fix Instructions

Overview

Fix issues identified in Bazel 9.0 migration PR review. One critical issue (opencl) and multiple cleanup issues (unused imports).


🔴 Critical Fix: opencl.tpl.BUILD and opencl.bzl

Problem

Current implementation adds all DPC++ runtime libraries to link phase, causing potential bloat and conflicts.

File 1: dev/bazel/deps/opencl.bzl

Current (lines 26-36):

if dpcpp_root:
    lib_dir = paths.join(dpcpp_root, "lib")
    libs = [
        "libOpenCL*.so*",
        "libsvml.so",
        "libirng.so",
        "libimf.so",
        "libintlc.so*",
        "libsycl.so.*",
        "libur_loader.so.*",
    ]
    repos.create_symlinks(repo_ctx, lib_dir, libs)

Change to:

if dpcpp_root:
    lib_dir = paths.join(dpcpp_root, "lib")
    libs = [
        "libOpenCL*.so*",
    ]
    repos.create_symlinks(repo_ctx, lib_dir, libs)

Rationale: DPC++ runtime libs (libsycl, libsvml, etc.) are automatically handled by icpx/dpcpp compiler. Explicit inclusion causes link bloat.

File 2: dev/bazel/deps/opencl.tpl.BUILD

Current:

package(default_visibility = ["//visibility:public"])
load("@rules_cc//cc:defs.bzl", "cc_library")
cc_library(
    name = "opencl_binary",
    srcs = glob(
        [
            "*.so",
            "*.so.*",
        ],
        exclude = ["*.py", "*.cmake", "*.a"],
        allow_empty = True,
    ),
    linkopts = ["-lOpenCL"],
    visibility = ["//visibility:public"],
)

Change to:

package(default_visibility = ["//visibility:public"])
load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(
    name = "opencl_binary",
    srcs = glob(
        [
            "libOpenCL*.so",
            "libOpenCL*.so.*",
        ],
        allow_empty = True,
    ),
    linkopts = ["-lOpenCL"],
    visibility = ["//visibility:public"],
)

Rationale: Only OpenCL libraries should be in srcs for linking. Runtime dependencies are handled by compiler/loader.


✅ Cleanup Fixes: Remove Unused Imports

File 3: dev/bazel/deps/tbb.tpl.BUILD

Change line 2:

-load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_toolchain")
+load("@rules_cc//cc:defs.bzl", "cc_library")

File 4: dev/bazel/deps/mkl.tpl.BUILD

Change line 2:

-load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_toolchain")
+load("@rules_cc//cc:defs.bzl", "cc_library")

File 5: dev/bazel/deps/mpi.tpl.BUILD

Change line 2:

-load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_toolchain")
+load("@rules_cc//cc:defs.bzl", "cc_library")

(Keep load("@rules_shell//shell:sh_binary.bzl", "sh_binary") on line 3)

File 6: dev/bazel/deps/dpl.tpl.BUILD

Change line 2:

-load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_toolchain")
+load("@rules_cc//cc:defs.bzl", "cc_library")

File 7: dev/bazel/deps/ccl.tpl.BUILD

Change line 2:

-load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_toolchain")
+load("@rules_cc//cc:defs.bzl", "cc_library")

File 8: dev/bazel/deps/openblas.tpl.BUILD

Change line 2:

-load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_toolchain")
+load("@rules_cc//cc:defs.bzl", "cc_library")

File 9: dev/bazel/deps/onedal.tpl.BUILD

Change line 2:

-load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_toolchain")
+load("@rules_cc//cc:defs.bzl", "cc_library")

File 10: dev/bazel/cc/link.bzl

Change lines 17-18:

 load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
-load("@rules_cc//cc:defs.bzl", "cc_toolchain")

Rationale: cc_toolchain is never called as a rule (only used as function parameter name).

File 11: dev/bazel/cc.bzl

Change line 23:

-load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
+load("@rules_cc//cc:defs.bzl", "cc_library")

File 12: dev/bazel/dal.bzl

Remove unused load (if it exists - check the actual diff):

-load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")

File 13: BUILD (root)

Remove unused load (if it exists - check the actual diff):

-load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")

File 14: dev/bazel/toolchains/cc_toolchain_config_lnx.bzl

Already correct - loads only what's needed from @rules_cc.

File 15: dev/bazel/toolchains/cc_toolchain_lnx.tpl.BUILD

Change load line:

-load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_toolchain")
+load("@rules_cc//cc:defs.bzl", "cc_toolchain")

❌ Ignore (False Positives)

Copilot comment on dev/bazel/cc/compile.bzl

No action needed. Comment claims CcInfo is unused, but the file only loads cc_common, not CcInfo. This is a Copilot error.

Copilot comment on dev/bazel/AGENTS.md

Optional/low priority. Documentation example doesn't match exact MODULE.bazel structure. Can update if desired, but not required for correctness.


Testing

After applying fixes:

  1. Run buildifier to verify no lint issues:
bazelisk run //:buildifier
  1. Build test with Bazel 9.0:
bazelisk build //...
  1. Verify OpenCL linking still works:
bazelisk test //cpp/daal/src/sycl/...

Summary

Critical (must fix):

  • Files 1-2: opencl.bzl and opencl.tpl.BUILD

Cleanup (should fix):

  • Files 3-15: Remove unused imports

Ignore:

  • cc/compile.bzl CcInfo comment (false positive)
  • AGENTS.md mismatch (optional docs update)

Estimated effort: 10-15 minutes
Risk: Low (cleanup only, no logic changes)
Impact: Fixes potential link bloat, improves buildifier compliance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants