aboutsummaryrefslogtreecommitdiff
path: root/third_party
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 /third_party
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 'third_party')
-rw-r--r--third_party/BUILD.bazel17
-rw-r--r--third_party/bazel-toolchain-export-dynamic-macos-asan.patch21
-rw-r--r--third_party/bazel-toolchain-support-ubuntu-21.patch13
3 files changed, 47 insertions, 4 deletions
diff --git a/third_party/BUILD.bazel b/third_party/BUILD.bazel
index d4c527f8..1ebe86c7 100644
--- a/third_party/BUILD.bazel
+++ b/third_party/BUILD.bazel
@@ -1,4 +1,13 @@
-exports_files([
- "gflags-use-double-dash-args.patch",
- "jacoco-make-probe-inserter-subclassable.patch",
-])
+load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
+
+bool_flag(
+ name = "toolchain",
+ build_setting_default = False,
+)
+
+config_setting(
+ name = "uses_toolchain",
+ flag_values = {
+ ":toolchain": "true",
+ },
+)
diff --git a/third_party/bazel-toolchain-export-dynamic-macos-asan.patch b/third_party/bazel-toolchain-export-dynamic-macos-asan.patch
new file mode 100644
index 00000000..ccbd79b0
--- /dev/null
+++ b/third_party/bazel-toolchain-export-dynamic-macos-asan.patch
@@ -0,0 +1,21 @@
+diff --git toolchain/BUILD.tpl toolchain/BUILD.tpl
+index bc9280f..f4bfa3d 100644
+--- toolchain/BUILD.tpl
++++ toolchain/BUILD.tpl
+@@ -126,6 +126,7 @@ filegroup(
+ [
+ "lib/lib*.a",
+ "lib/clang/%{llvm_version}/lib/**/*.a",
++ "lib/clang/%{llvm_version}/lib/**/*.dylib",
+ ],
+ exclude = [
+ "lib/libLLVM*.a",
+@@ -216,3 +217,8 @@ filegroup(
+ ":linker_components",
+ ],
+ )
++
++cc_import(
++ name = "macos_asan_dynamic",
++ shared_library = "lib/clang/%{llvm_version}/lib/darwin/libclang_rt.asan_osx_dynamic.dylib",
++)
diff --git a/third_party/bazel-toolchain-support-ubuntu-21.patch b/third_party/bazel-toolchain-support-ubuntu-21.patch
new file mode 100644
index 00000000..b605cfc1
--- /dev/null
+++ b/third_party/bazel-toolchain-support-ubuntu-21.patch
@@ -0,0 +1,13 @@
+diff --git toolchain/tools/llvm_release_name.py toolchain/tools/llvm_release_name.py
+index 8ee544f..86f29f4 100755
+--- toolchain/tools/llvm_release_name.py
++++ toolchain/tools/llvm_release_name.py
+@@ -77,7 +77,7 @@ def _linux(llvm_version):
+ os_name = "linux-sles%s" % version
+ elif distname == "ubuntu" and version.startswith("14.04"):
+ os_name = "linux-gnu-ubuntu-14.04"
+- elif (distname == "ubuntu" and version.startswith("20.04")) or (distname == "linuxmint" and version.startswith("20")):
++ elif (distname == "ubuntu" and version.startswith("2")) or (distname == "linuxmint" and version.startswith("20")):
+ if major_llvm_version < 11:
+ # There is no binary packages specifically for 20.04, but those for 18.04 works on
+ # 20.04