Bazel
Dependencies
- Ubuntu/Debian
- Arch
- macOS
- Windows
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
Ubuntu versions >=24.04 also require libclang-rt-dev
.
Install libclang-rt-dev
sudo apt install libclang-rt-dev
Install dependencies
sudo pacman -S clang llvm lcov python jdk-openjdk 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
C++ Bazel projects are currently not supported.
C++ Bazel projects are currently not supported.
Version requirements
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
following modules to 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")
bazel_dep(name = "cifuzz", dev_dependency = True)
git_override(
module_name = "cifuzz",
remote = "https://github.com/CodeIntelligenceTesting/cifuzz-bazel.git",
commit = "4def1849380da6c9bfae159f7d1873df826d9055",
)
If you are using a WORKSPACE
file, add the following dependencies:
WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_python",
sha256 = "9c6e26911a79fbf510a8f06d8eedb40f412023cf7fa6d1461def27116bff022c",
strip_prefix = "rules_python-1.1.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/1.1.0/rules_python-1.1.0.tar.gz",
)
load("@rules_python//python:repositories.bzl", "py_repositories")
py_repositories()
http_archive(
name = "rules_fuzzing",
sha256 = "e6bc219bfac9e1f83b327dd090f728a9f973ee99b9b5d8e5a184a2732ef08623",
strip_prefix = "rules_fuzzing-0.5.2",
urls = ["https://github.com/bazelbuild/rules_fuzzing/archive/v0.5.2.zip"],
)
load("@rules_fuzzing//fuzzing:repositories.bzl", "rules_fuzzing_dependencies")
rules_fuzzing_dependencies()
load("@rules_fuzzing//fuzzing:init.bzl", "rules_fuzzing_init")
rules_fuzzing_init()
load("@fuzzing_py_deps//:requirements.bzl", "install_deps")
install_deps()
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"],
)