Skip to content

//go/private:context bzl_library is missing transitive dep on @rules_cc//cc:find_cc_toolchain.bzl - breaks Stardoc users #4394

@tetromino

Description

@tetromino

The //go/private:context bzl_library target lists a direct dependency on @bazel_tools//tools/cpp:toolchain_utils.bzl - but it's missing the transitive dependencies of that file. bazelbuild/bazel#23809 (released as part of Bazel 8) moved toolchain logic to rules_cc, and toolchain_utils.bzl now loads@rules_cc//cc:find_cc_toolchain.bzl.

So now//go/private:context needs a dep on @rules_cc//cc:find_cc_toolchain_bzl.

This was first reported at bazelbuild/stardoc#300 - the missing dep causes Stardoc doc generation for .bzl files which load rules_go symbols to start failing when updating from Bazel 7 to Bazel 8/9, because Stardoc requires complete transitive load dependencies to be accessible from deps.

To reproduce:

cat >MODULE.bazel <<EOF
bazel_dep(name = "rules_go", version = "0.55.1")
bazel_dep(name = "stardoc", version = "0.8.0")
bazel_dep(name = "bazel_skylib", version = "1.8.1")
EOF

cat >BUILD <<EOF
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@stardoc//stardoc:stardoc.bzl", "stardoc")

bzl_library(
    name = "my_rule",
    srcs = ["my_rule.bzl"],
    visibility = ["//visibility:public"],
    deps = ["@rules_go//go:def"],
)

stardoc(
    name = "my_rule_docs",
    out = "my_rule.md",
    input = "my_rule.bzl",
    deps = [":my_rule"],
)
EOF

cat >my_rule.bzl <<EOF
load("@rules_go//go:def.bzl", "go_test")

def go_helper_test(name, **kwargs):
    """A helper function to create a Go test target with specific attributes."""
    go_test(
        name = name,
        srcs = ["test_helper.go"],
        embed = [":helper_lib"],
        **kwargs
    )
EOF

bazelisk build my_rule_docs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions