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
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
info
C/C++ Bazel projects are currently not supported.
info
C/C++ Bazel projects are currently not supported.
Version requirements
info
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 your 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")
git_override(
module_name = "rules_fuzzing",
remote = "https://github.com/CodeIntelligenceTesting/rules_fuzzing.git",
commit = "d17698278270c350ee82b05224a2fafb3da7f756",
)
bazel_dep(name = "cifuzz", dev_dependency = True)
git_override(
module_name = "cifuzz",
remote = "https://github.com/CodeIntelligenceTesting/cifuzz-bazel.git",
commit = "db84a1ff9cf2b25c185e9c32717e14e1e55105bd",
)
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_shell",
sha256 = "3e114424a5c7e4fd43e0133cc6ecdfe54e45ae8affa14fadd839f29901424043",
strip_prefix = "rules_shell-0.4.0",
url = "https://github.com/bazelbuild/rules_shell/releases/download/v0.4.0/rules_shell-v0.4.0.tar.gz",
)
load("@rules_shell//shell:repositories.bzl", "rules_shell_dependencies", "rules_shell_toolchains")
rules_shell_dependencies()
rules_shell_toolchains()
http_archive(
name = "rules_fuzzing",
sha256 = "5b8743464177338fbe2811df86d6c0e5f5b4828d1c8c30548f3c18958c74a32c",
strip_prefix = "rules_fuzzing-d17698278270c350ee82b05224a2fafb3da7f756",
urls = ["https://github.com/CodeIntelligenceTesting/rules_fuzzing/archive/d17698278270c350ee82b05224a2fafb3da7f756.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",
integrity = "sha256-nJQmjTKB1ZljDKxdXKLWcsOZEARakSSVm3dHrirGPEU=",
strip_prefix = "cifuzz-bazel-1.1.0",
urls = ["https://github.com/CodeIntelligenceTesting/cifuzz-bazel/archive/refs/tags/v1.1.0.zip"],
)