diff options
author | Fabian Meumertzheim <meumertzheim@code-intelligence.com> | 2021-08-04 10:13:18 +0200 |
---|---|---|
committer | Fabian Meumertzheim <fabian@meumertzhe.im> | 2021-08-09 09:36:03 +0200 |
commit | 89285d8f3d3653b37aa9165b05ddbfec50141198 (patch) | |
tree | ac717d760e5a286729dece0cda4b90e99a1e6ac5 /driver | |
parent | 3282049bdf62d053a7ac9a0157ca3ef0f0c4ec27 (diff) | |
download | jazzer-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 'driver')
-rw-r--r-- | driver/BUILD.bazel | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/driver/BUILD.bazel b/driver/BUILD.bazel index d4d166a2..8a0762ea 100644 --- a/driver/BUILD.bazel +++ b/driver/BUILD.bazel @@ -84,6 +84,16 @@ cc_binary( deps = [":driver_lib"], ) +alias( + name = "using_toolchain_on_osx", + actual = select({ + "//third_party:uses_toolchain": "@platforms//os:osx", + # In order to achieve AND semantics, reference a setting that is known + # not to apply. + "//conditions:default": "//third_party:uses_toolchain", + }), +) + cc_binary( name = "jazzer_driver_asan", data = [ @@ -91,10 +101,16 @@ cc_binary( ], linkopts = [ "-fsanitize=address", + "-static-libsan", "-rdynamic", ], visibility = ["//visibility:public"], - deps = [":driver_lib"], + deps = [":driver_lib"] + select({ + # There is no static ASan runtime on macOS, so link to the dynamic + # runtime library if on macOS and using the toolchain. + ":using_toolchain_on_osx": ["@llvm_toolchain//:macos_asan_dynamic"], + "//conditions:default": [], + }), ) cc_binary( @@ -104,6 +120,8 @@ cc_binary( ], linkopts = [ "-fsanitize=undefined", + # Link UBSan statically, even on macOS. + "-static-libsan", "-rdynamic", ], visibility = ["//visibility:public"], |