> ## Documentation Index
> Fetch the complete documentation index at: https://site.aspect.build/llms.txt
> Use this file to discover all available pages before exploring further.

# Bazel 9 Upstream Prebuilt Protobuf

> Bazel 9 includes a prebuilt upstream protobuf compiler.

export const BlogPost = ({title, date, authors, tags, image, children}) => {
  const tagList = tags ? tags.split(", ").filter(Boolean) : [];
  const tagSlug = t => t.toLowerCase().replace(/&/g, "").replace(/\+/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
  const formattedDate = date ? new Date(date + "T00:00:00").toLocaleDateString("en-US", {
    year: "numeric",
    month: "long",
    day: "numeric"
  }) : "";
  return <section className="w-full flex justify-center px-4 py-12 md:py-16">
      <div style={{
    maxWidth: "800px",
    width: "100%"
  }}>
        {image && (typeof image === "string" ? <img noZoom src={image} alt={title} className="w-full rounded-xl mb-8" style={{
    maxHeight: "400px",
    objectFit: "cover"
  }} /> : <div className="blog-post-hero-image">{image}</div>)}
        <h1 className="text-3xl md:text-4xl font-bold text-zinc-900 dark:text-white">
          {title}
        </h1>
        <div className="flex flex-wrap items-center gap-3 mt-4 text-sm text-zinc-500 dark:text-zinc-400">
          {authors && <span>{authors}</span>}
          {authors && formattedDate && <span>·</span>}
          {formattedDate && <span>{formattedDate}</span>}
        </div>
        {tagList.length > 0 && <div className="flex flex-wrap gap-2 mt-3">
            {tagList.map(tag => <a key={tag} href={"/blog/tags/" + tagSlug(tag)} className="px-2 py-0.5 rounded-full text-xs bg-zinc-100 dark:bg-zinc-800 text-zinc-600 dark:text-zinc-400 hover:bg-blue-100 dark:hover:bg-blue-900/40 hover:text-blue-700 dark:hover:text-blue-300 transition">
                {tag}
              </a>)}
          </div>}
        <hr className="my-8 border-zinc-200 dark:border-zinc-700" />
        <div className="prose dark:prose-invert max-w-none">{children}</div>
      </div>
    </section>;
};

export const MarketingPage = () => <div className="marketing-page-marker" style={{
  display: "none"
}} />;

export const Section = ({children, className = "", gray = false, dark = false, id}) => <section id={id} className={`w-full flex justify-center px-4 py-16 md:py-24 ${gray ? "bg-gray-50 dark:bg-zinc-900" : dark ? "bg-zinc-900 dark:bg-zinc-950" : ""} ${className}`}>
    <div className="w-full" style={{
  maxWidth: "1140px"
}}>
      {children}
    </div>
  </section>;

<MarketingPage />

<BlogPost title="Bazel 9 Upstream Prebuilt Protobuf" date="2026-01-16" authors="Alex Eagle" tags="Bazel, Releases">
  <img noZoom src="https://mintcdn.com/aspectbuild/x1L7Iep716jCyJVo/images/blog/hashnode/hn-13978548c6.png?fit=max&auto=format&n=x1L7Iep716jCyJVo&q=85&s=c0a628464937bf2d3810807daf670029" alt="" className="blog-post-cover" width="2742" height="1814" data-path="images/blog/hashnode/hn-13978548c6.png" />

  Bazel 9.0 is a major long-term support (LTS) release. It contains new features and backwards incompatible changes.

  * Bzlmod is now always enabled, and all WORKSPACE logic has been removed from Bazel ([#26131](https://github.com/bazelbuild/bazel/issues/26131)). The [Bzlmod migration tool is available](https://bazel.build/external/migration_tool).

  * All C++-related [rules](https://github.com/bazelbuild/bazel/issues/26131) are [removed](https://bazel.build/external/migration_tool) from Bazel and must be loaded from @rules\_cc, as part of the [Starlark effort](https://github.com/bazelbuild/bazel/issues/23043).

  * [Bazel 9](https://github.com/bazelbuild/bazel/issues/23043) ships with the latest protobuf module (version 33.4), which includes support for a prebuilt protobuf compiler.

  This prebuilt protobuf compiler follows up on our blog article [never compile protoc again](/blog/never-compile-protoc-again) which ended with the promise “We’re hoping to upstream our `toolchains_protoc` to the protobuf repository, so that the default Bazel experience will be fast.”

  This is now (nearly) true as of the [v33.4 release](https://github.com/protocolbuffers/protobuf/releases/tag/v33.4).

  We thank the [Google Protobuf](https://github.com/protocolbuffers/protobuf) team for sponsoring this work and reviewing the implementation, including changes to the release process.

  ## Enabling the Protobufs toolchains feature

  Bazel 9 flips the [`--incompatible_enable_proto_toolchain_resolution`](https://registry.build/flag/bazel/?flag=incompatible_enable_proto_toolchain_resolution) flag to true. This means Bazel is responsible for resolving the symbol `@protobuf//bazel/private:proto_toolchain_type` to a “concrete” toolchain that provides the right `protoc` binary for your execution platform. This is also the case for a toolchain\_type for each language stub generator.

  If you’re on Bazel 9, there’s nothing to do, but earlier Bazels require you set the flag.

  ## Opting-in

  Until [https://github.com/protocolbuffers/protobuf/pull/25313](https://github.com/protocolbuffers/protobuf/pull/25313) lands and is released, you need to opt-in to using the `protoc` binaries from [https://github.com/protocolbuffers/protobuf/releases](https://github.com/protocolbuffers/protobuf/releases). Add to your `.bazelrc`:

  ```bash theme={null}
  common --@protobuf//bazel/toolchains:prefer_prebuilt_protoc
  ```

  > note, if you have a `repo_name=com_google_protobuf` you’ll have to adapt the `@protobuf` name

  ## Enforcing

  You can enforce that no rules do the “Wrong Thing” of directly referencing the `cc_binary` target `@protobuf//:protoc` by following our snippets: [https://github.com/aspect-build/toolchains\_protoc#ensure-protobuf-and-grpc-never-built](https://github.com/aspect-build/toolchains_protoc#ensure-protobuf-and-grpc-never-built)

  If this fails to build, it means that there’s a bug you should find or report.

  The [https://github.com/aspect-build/toolchains\_protoc](https://github.com/aspect-build/toolchains_protoc) and [https://github.com/bazelbuild/rules\_proto](https://github.com/bazelbuild/rules_proto) repositories are now archived, completing the deprecation period.

  ## Next

  Need help migrating from WORKSPACE to Bzlmod or other steps to move to Bazel 9? View [Aspect Build services](http://www.aspect.build/services) and email us at [hello@aspect.build](mailto:hello@aspect.build) or ping us on Bazel Slack. We’re happy to support you.
</BlogPost>
