Skip to content

Commit

Permalink
chore(deps): update dependency bazel to v7 (#213)
Browse files Browse the repository at this point in the history
* Update to v7

* Support bzlmod for docs and make docs gen work again

* Configure nccl example for bzlmod

* Fix examples building from top-level rules_cuda dir

* Adjust CI config for bazel7
  • Loading branch information
cloudhan authored Jan 16, 2024
1 parent 216e134 commit 34de163
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 19 deletions.
1 change: 0 additions & 1 deletion .bazelignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
bazel-*
docs
examples
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.4.0
7.0.0
21 changes: 11 additions & 10 deletions .github/workflows/build-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,15 @@ jobs:
echo "build --config=clang" > $HOME/.bazelrc
echo "build:clang --@rules_cuda//cuda:archs=sm_80" >> $HOME/.bazelrc
- run: bazelisk build @rules_cuda_examples//basic:all
- run: bazelisk build @rules_cuda_examples//rdc:all
- run: bazelisk build @rules_cuda_examples//if_cuda:main
- run: bazelisk build @rules_cuda_examples//if_cuda:main --enable_cuda=False

- run: cd examples && bazelisk build //basic:all --config=bzlmod
- run: cd examples && bazelisk build //rdc:all --config=bzlmod
- run: cd examples && bazelisk build //if_cuda:main --config=bzlmod
- run: cd examples && bazelisk build //if_cuda:main --enable_cuda=False --config=bzlmod

# Use Bazel with version specified in .bazelversion
# out of @examples repo build requires WORKSPACE-based external dependency system
- run: bazelisk build --noenable_bzlmod @rules_cuda_examples//basic:all
- run: bazelisk build --noenable_bzlmod @rules_cuda_examples//rdc:all
- run: bazelisk build --noenable_bzlmod @rules_cuda_examples//if_cuda:main
- run: bazelisk build --noenable_bzlmod @rules_cuda_examples//if_cuda:main --enable_cuda=False
# in @examples repo build, bzlmod is enabled by default since Bazel 7
- run: cd examples && bazelisk build //basic:all
- run: cd examples && bazelisk build //rdc:all
- run: cd examples && bazelisk build //if_cuda:main
- run: cd examples && bazelisk build //if_cuda:main --enable_cuda=False
- run: bazelisk shutdown
4 changes: 2 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module(
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(name = "platforms", version = "0.0.6")

toolchain = use_extension("@rules_cuda//cuda:extensions.bzl", "toolchain")
use_repo(toolchain, "local_cuda")
cuda = use_extension("@rules_cuda//cuda:extensions.bzl", "toolchain")
use_repo(cuda, "local_cuda")

register_toolchains(
"@local_cuda//toolchain:nvcc-local-toolchain",
Expand Down
26 changes: 22 additions & 4 deletions docs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,32 +1,50 @@
load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

bzl_library(
name = "bazel_tools_bzl_srcs",
srcs = ["@bazel_tools//tools:bzl_srcs"],
)

# NOTE: when the `out` is changed, the `nav` part of `mkdocs.yaml` must be also be changed correspondingly.
stardoc(
name = "user_docs",
out = "user/user_docs.md",
input = "user_docs.bzl",
deps = ["@rules_cuda//:bzl_srcs"],
deps = [
":bazel_tools_bzl_srcs",
"@rules_cuda//:bzl_srcs",
],
)

stardoc(
name = "toolchain_config_docs",
out = "user/toolchain_config_docs.md",
input = "toolchain_config_docs.bzl",
deps = ["@rules_cuda//:bzl_srcs"],
deps = [
":bazel_tools_bzl_srcs",
"@rules_cuda//:bzl_srcs",
],
)

stardoc(
name = "providers_docs",
out = "developer/providers_docs.md",
input = "providers_docs.bzl",
deps = ["@rules_cuda//:bzl_srcs"],
deps = [
":bazel_tools_bzl_srcs",
"@rules_cuda//:bzl_srcs",
],
)

stardoc(
name = "developer_docs",
out = "developer/developer_docs.md",
input = "developer_docs.bzl",
deps = ["@rules_cuda//:bzl_srcs"],
deps = [
":bazel_tools_bzl_srcs",
"@rules_cuda//:bzl_srcs",
],
)

filegroup(
Expand Down
20 changes: 20 additions & 0 deletions docs/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module(
name = "rules_cuda_docs",
version = "0.0.0",
compatibility_level = 1,
)

bazel_dep(name = "rules_cuda", version = "0.2.1")
local_path_override(
module_name = "rules_cuda",
path = "..",
)

cuda = use_extension("@rules_cuda//cuda:extensions.bzl", "toolchain")
cuda.local_toolchain(
name = "local_cuda",
toolkit_path = "",
)
use_repo(cuda, "local_cuda")

bazel_dep(name = "stardoc", version = "0.6.2")
2 changes: 1 addition & 1 deletion examples/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ build:clang --repo_env=CC=clang
build:clang --@rules_cuda//cuda:compiler=clang

# https://github.com/bazel-contrib/rules_cuda/issues/1
build --ui_event_filters=-INFO
# build --ui_event_filters=-INFO

common:bzlmod --enable_bzlmod
6 changes: 6 additions & 0 deletions examples/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ cuda.local_toolchain(
toolkit_path = "",
)
use_repo(cuda, "local_cuda")

#################################
# Dependencies for nccl example #
#################################
# See WORKSPACE.bzlmod for the remaining parts
bazel_dep(name = "bazel_skylib", version = "1.4.2")
31 changes: 31 additions & 0 deletions examples/WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#################################
# Dependencies for nccl example #
#################################
# NOTE: this should have been placed in MODULE.bazel, but use_repo_rule is introduced in Bazel 7.
# See https://github.com/bazelbuild/bazel/issues/17141

# http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # For MODULE.bazel
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # For WORKSPACE.bazel

http_archive(
name = "nccl",
add_prefix = "nccl",
build_file = "@rules_cuda_examples//nccl:nccl.BUILD",
sha256 = "83b299cfc2dfe63887dadf3590b3ac2b8b2fd68ec5515b6878774eda39a697d2",
strip_prefix = "nccl-9814c75eea18fc7374cde884592233b6b7dc055b",
urls = ["https://github.com/nvidia/nccl/archive/9814c75eea18fc7374cde884592233b6b7dc055b.tar.gz"],
)

http_archive(
name = "nccl-tests",
add_prefix = "nccl-tests",
build_file = "@rules_cuda_examples//nccl:nccl-tests.BUILD",
patch_args = [
"--directory=nccl-tests",
"-p1",
],
patches = ["@rules_cuda_examples//nccl:nccl-tests-clang.patch"],
sha256 = "946adb84f63aec66aea7aab9739d41df81c24f783e85fba6328ba243cfc057e0",
strip_prefix = "nccl-tests-1a5f551ffd6e3271982b03a9d5653a3f6ba545fa",
urls = ["https://github.com/nvidia/nccl-tests/archive/1a5f551ffd6e3271982b03a9d5653a3f6ba545fa.tar.gz"],
)

0 comments on commit 34de163

Please sign in to comment.