Bazel

From carbon-language/carbon-lang · View interactive version

Bazel is an AI agent skill from the GitHub repository carbon-language/carbon-lang. Instructions that **MUST** be followed when using Bazel or Bazelisk to build, test, and debug in the Carbon repository.

How to use this skill

Skill file

Bazel usage

<!--

Part of the Carbon Language project, under the Apache License v2.0 with LLVM

Exceptions. See /LICENSE for license information.

SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

-->

This skill documents how best to use Bazel when building, testing, or

manipulating the Carbon repository's Bazel in any way.

Bazel wrappers

Carbon uses Bazel for its build system. To ensure consistent versions, the

project uses Bazelisk.

[!IMPORTANT] Always use bazelisk whenever you want to run Bazel. Never run

bazel directly in the Carbon project. Anything you want to do with bazel

can be done with the bazelisk command instead.

./scripts/run_bazelisk.py to run bazelisk without it being installed.

Essential commands

Building

Testing

[!TIP] Running all of the tests can be slow, so try to narrowly test the

immediately relevant parts of the project first, and only expand coverage as

necessary to be confident in the changes.

[!TIP] For specialized instructions on testing and developing the Carbon

toolchain, consult these skills:

- Toolchain tests: For

authoring, structuring, and running file_test tests.

- Toolchain development:

For architecture, essential commands, and debugging the toolchain.

Running binaries built by Bazel

[!IMPORTANT] Always manually run binaries built by Bazel using the

bazelisk run command. Never run the binary directly from bazel-bin/.

You can run the Carbon driver or command line directly via Bazel:

toolchain/parse/testdata/basics/empty.carbon`

Advanced configurations

AddressSanitizer (ASan)

To enable ASan for local testing:

Common pitfalls and troubleshooting

`bazel clean`

Changes to packages installed on your system (like changing LLVM versions or

installing libc++) may not be noticed by Bazel.

changes occur.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.