Skip to content
Open
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.5.1
9.0.0
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module(name = "onedal")
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "bazel_skylib", version = "1.9.0")
bazel_dep(name = "rules_cc", version = "0.2.16")
bazel_dep(name = "rules_shell", version = "0.6.1")
bazel_dep(name = "fmt", version = "12.1.0")

declare_onedal_config = use_repo_rule("@onedal//dev/bazel/config:config.bzl", "declare_onedal_config")
Expand Down
4 changes: 2 additions & 2 deletions dev/bazel/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ module(
version = "1.0.0",
)

bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "catch2", version = "3.4.0")
bazel_dep(name = "rules_cc", version = "0.2.16")
bazel_dep(name = "catch2", version = "3.9.1")
```

## 🔧 Build Rules and Patterns
Expand Down
6 changes: 5 additions & 1 deletion dev/bazel/cc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ load("@onedal//dev/bazel:utils.bzl",
"paths",
"sets",
)

load("@rules_cc//cc:defs.bzl", "cc_library")
load("@onedal//dev/bazel/config:config.bzl",
"CpuInfo",
)
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
load("@onedal//dev/bazel/cc:common.bzl",
onedal_cc_common = "common",
)
Expand Down Expand Up @@ -123,7 +127,7 @@ def cc_module(name, hdrs=[], deps=[], **kwargs):
# > The list of possible extensions for 'public_hdrs' is:
# .h,.hh,.hpp,.ipp,.hxx,.h++,.inc,.inl,.tlh,.tli,.H,.tcc
if hdrs:
native.cc_library(
cc_library(
name = "__{}_headers__".format(name),
hdrs = hdrs,
)
Expand Down
3 changes: 3 additions & 0 deletions dev/bazel/cc/common.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
# limitations under the License.
#===============================================================================

load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")

load("@onedal//dev/bazel:utils.bzl",
"utils",
"paths",
Expand Down
2 changes: 2 additions & 0 deletions dev/bazel/cc/compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# limitations under the License.
#===============================================================================

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

load("@onedal//dev/bazel:utils.bzl",
"utils",
"paths",
Expand Down
4 changes: 4 additions & 0 deletions dev/bazel/cc/link.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@
# limitations under the License.
#===============================================================================

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.

load("@onedal//dev/bazel:utils.bzl",
"utils",
"paths",
"sets",
)

load("@onedal//dev/bazel/toolchains:action_names.bzl",
"CPP_MERGE_STATIC_LIBRARIES"
)
Expand Down
1 change: 1 addition & 0 deletions dev/bazel/deps/catch2.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
# SPDX-License-Identifier: BSL-1.0

load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
load("@rules_cc//cc:defs.bzl", "cc_library")

# oneDAL verison of catch2 bazel build file
expand_template(
Expand Down
2 changes: 1 addition & 1 deletion dev/bazel/deps/ccl.tpl.BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package(default_visibility = ["//visibility:public"])

load("@rules_cc//cc:defs.bzl", "cc_library")
cc_library(
name = "headers",
features = [ "dpc++" ],
Expand Down
2 changes: 1 addition & 1 deletion dev/bazel/deps/dpl.tpl.BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package(default_visibility = ["//visibility:public"])

load("@rules_cc//cc:defs.bzl", "cc_library")
cc_library(
name = "headers",
hdrs = glob(["include/**/**/*"]),
Expand Down
2 changes: 1 addition & 1 deletion dev/bazel/deps/mkl.tpl.BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package(default_visibility = ["//visibility:public"])

load("@rules_cc//cc:defs.bzl", "cc_library")
cc_library(
name = "headers",
hdrs = glob([
Expand Down
3 changes: 2 additions & 1 deletion dev/bazel/deps/mpi.tpl.BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package(default_visibility = ["//visibility:public"])

load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
filegroup(
name = "mpi_runfiles",
srcs = glob([
Expand Down
2 changes: 1 addition & 1 deletion dev/bazel/deps/onedal.tpl.BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package(default_visibility = ["//visibility:public"])

load("@rules_cc//cc:defs.bzl", "cc_library")
cc_library(
name = "headers",
hdrs = glob([
Expand Down
2 changes: 1 addition & 1 deletion dev/bazel/deps/openblas.tpl.BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package(default_visibility = ["//visibility:public"])

load("@rules_cc//cc:defs.bzl", "cc_library")
cc_library(
name = "headers",
hdrs = glob(["include/**/*.h"]),
Expand Down
10 changes: 7 additions & 3 deletions dev/bazel/deps/opencl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ def _opencl_repo_impl(repo_ctx):
if dpcpp_root:
lib_dir = paths.join(dpcpp_root, "lib")
libs = [
"libOpenCL.so",
"libOpenCL.so.1",
"libOpenCL.so.1.2",
"libOpenCL*.so*",
"libsvml.so",
"libirng.so",
"libimf.so",
"libintlc.so*",
"libsycl.so.*",
"libur_loader.so.*",
]
repos.create_symlinks(repo_ctx, lib_dir, libs)
repo_ctx.template(
Expand Down
10 changes: 9 additions & 1 deletion dev/bazel/deps/opencl.tpl.BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
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"],
Comment on lines +7 to 13
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.
visibility = ["//visibility:public"],
)
2 changes: 1 addition & 1 deletion dev/bazel/deps/tbb.tpl.BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package(default_visibility = ["//visibility:public"])

load("@rules_cc//cc:defs.bzl", "cc_library")
cc_library(
name = "headers",
hdrs = glob(["include/**/*.h"]),
Expand Down
1 change: 1 addition & 0 deletions dev/bazel/release.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

load("@onedal//dev/bazel:utils.bzl", "utils", "paths")
load("@onedal//dev/bazel:cc.bzl", "ModuleInfo")
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")

def _match_file_name(file, entries):
for entry in entries:
Expand Down
35 changes: 32 additions & 3 deletions dev/bazel/repos.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,38 @@ def _normalize_download_info(repo_ctx):
def _create_symlinks(repo_ctx, root, entries, substitutions={}, mapping={}):
for entry in entries:
entry_fmt = utils.substitute(entry, substitutions)
src_entry_path = utils.substitute(paths.join(root, entry_fmt), mapping)
dst_entry_path = entry_fmt
repo_ctx.symlink(src_entry_path, dst_entry_path)
if "*" in entry_fmt:
pattern = entry_fmt.split("/")[-1]
dir_part = entry_fmt[:entry_fmt.rfind("/")] if "/" in entry_fmt else ""
root_with_dir = utils.substitute(
paths.join(root, dir_part) if dir_part else root,
mapping
)
for fs_entry in repo_ctx.path(root_with_dir).readdir():
if _matches_glob(fs_entry.basename, pattern):
dst = (paths.join(dir_part, fs_entry.basename)
if dir_part else fs_entry.basename)
repo_ctx.symlink(str(fs_entry), dst)
else:
src_entry_path = utils.substitute(paths.join(root, entry_fmt), mapping)
dst_entry_path = entry_fmt
repo_ctx.symlink(src_entry_path, dst_entry_path)

def _matches_glob(name, pattern):
if "*" not in pattern:
return name == pattern
parts = pattern.split("*")
if not name.startswith(parts[0]):
return False
if not name.endswith(parts[-1]):
return False
pos = len(parts[0])
for part in parts[1:-1]:
idx = name.find(part, pos)
if idx == -1:
return False
pos = idx + len(part)
return True

def _download(repo_ctx):
output = repo_ctx.path("archive")
Expand Down
7 changes: 5 additions & 2 deletions dev/bazel/toolchains/cc_toolchain_config_lnx.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
# limitations under the License.
#===============================================================================

load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
load("@rules_cc//cc:action_names.bzl", "ACTION_NAMES")

load("@rules_cc//cc:cc_toolchain_config_lib.bzl",
"feature",
"feature_set",
"flag_group",
Expand All @@ -26,8 +28,9 @@ load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
"tool",
"artifact_name_pattern",
)
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
load("@onedal//dev/bazel/toolchains:action_names.bzl", "CPP_MERGE_STATIC_LIBRARIES")
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
load("@rules_cc//cc/toolchains:cc_toolchain_config_info.bzl", "CcToolchainConfigInfo")

all_compile_actions = [
ACTION_NAMES.c_compile,
Expand Down
1 change: 1 addition & 0 deletions dev/bazel/toolchains/cc_toolchain_lnx.tpl.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package(default_visibility = ["//visibility:public"])

load("@onedal//dev/bazel/toolchains:cc_toolchain_config_lnx.bzl", "cc_toolchain_config")
load("@rules_cc//cc:defs.bzl", "cc_toolchain")

filegroup(
name = "empty",
Expand Down
Loading