aboutsummaryrefslogtreecommitdiff
path: root/WORKSPACE.bazel
diff options
context:
space:
mode:
authorFabian Meumertzheim <meumertzheim@code-intelligence.com>2021-08-04 10:13:18 +0200
committerFabian Meumertzheim <fabian@meumertzhe.im>2021-08-09 09:36:03 +0200
commit89285d8f3d3653b37aa9165b05ddbfec50141198 (patch)
treeac717d760e5a286729dece0cda4b90e99a1e6ac5 /WORKSPACE.bazel
parent3282049bdf62d053a7ac9a0157ca3ef0f0c4ec27 (diff)
downloadjazzer-api-89285d8f3d3653b37aa9165b05ddbfec50141198.tar.gz
Use an LLVM Bazel toolchain in the CI
The toolchain is only enabled in the CI by default as users should use the same compiler toolchain for compiling the Jazzer driver as they use to compile their JNI libraries. However, if they are only interested in fuzzing pure Java libraries, they can pass --config=ci on the CLI to use the toolchain, which greatly simplifies the build on macOS. A significant complication arises because the ASan runtime library can't be linked statically on macOS. To make the tests pass, it needs to be exported from the toolchain and the driver has to conditionally depend on it explicitly. A further patch to the toolchain is required to ensure compatibility with Ubuntu 21.04.
Diffstat (limited to 'WORKSPACE.bazel')
-rw-r--r--WORKSPACE.bazel25
1 files changed, 25 insertions, 0 deletions
diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel
index 358688f7..deaba2e2 100644
--- a/WORKSPACE.bazel
+++ b/WORKSPACE.bazel
@@ -9,6 +9,31 @@ load("//:init.bzl", "jazzer_init")
jazzer_init()
+http_archive(
+ name = "com_grail_bazel_toolchain",
+ patches = [
+ # There is no static runtime library for ASan on macOS, so when using
+ # the toolchain in the CI, we have to explicitly depend on the dylib and
+ # add it to the runfiles for clang/ld.
+ "//third_party:bazel-toolchain-export-dynamic-macos-asan.patch",
+ "//third_party:bazel-toolchain-support-ubuntu-21.patch",
+ ],
+ sha256 = "54b54eedc71b93b278c44b6c056a737dc68545c6da75f63d0810676e1181f559",
+ strip_prefix = "bazel-toolchain-76ce37e977a304acf8948eadabb82c516320e286",
+ urls = ["https://github.com/grailbio/bazel-toolchain/archive/76ce37e977a304acf8948eadabb82c516320e286.tar.gz"],
+)
+
+load("@com_grail_bazel_toolchain//toolchain:deps.bzl", "bazel_toolchain_dependencies")
+
+bazel_toolchain_dependencies()
+
+load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain")
+
+llvm_toolchain(
+ name = "llvm_toolchain",
+ llvm_version = "12.0.0",
+)
+
load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")
rules_jvm_external_deps()