Skip to main content

Bazel

Dependencies

Install dependencies
sudo apt install clang llvm lcov default-jdk zip
Install Bazelisk
sudo curl -L https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 -o /usr/local/bin/bazel
sudo chmod +x /usr/local/bin/bazel

Note: On Ubuntu 24.04 and later versions libclang-rt-dev needs to be installed.

Install libclang-rt-dev
sudo apt install libclang-rt-dev

Version Requirements

  • Bazel >= 5.3.2 on Linux
  • Java JDK >= 8 (1.8) is needed for Bazel's coverage feature
  • LLVM >= 12

Note: Running CI Fuzz with LLVM versions <= 16 on Linux can cause fuzzing runs to randomly crash. Have a look at the troubleshooting guide for instructions to fix this issue.

Initialize a Project

Initialize CI Fuzz in the root directory of your Bazel project with the following command:

cifuzz init

CI Fuzz requires two bazel dependencies to work correctly. Add the rules_fuzzing module in your MODULE.bazel file

MODULE.bazel
bazel_dep(name = "rules_fuzzing", version = "0.5.2")
non_module_dependencies = use_extension("@rules_fuzzing//fuzzing/private:extensions.bzl", "non_module_dependencies")
use_repo(non_module_dependencies, "rules_fuzzing_oss_fuzz")

and the cifuzz repository in your WORKSPACE file.

WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "cifuzz",
sha256 = "1e01292189b0524d1f6114e0717d107474c289f78cbe7513e79fcaff8f0dee90",
strip_prefix = "cifuzz-bazel-1.0.0",
urls = ["https://github.com/CodeIntelligenceTesting/cifuzz-bazel/archive/refs/tags/v1.0.0.zip"],
)

Example Projects