• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1load("@fmeum_rules_jni//jni:defs.bzl", "cc_jni_library")
2
3cc_jni_library(
4    name = "native_asan",
5    srcs = [
6        "com_example_ExampleFuzzerWithNative.cpp",
7    ],
8    copts = [
9        "-fsanitize=fuzzer-no-link,address",
10        "-fno-sanitize-blacklist",
11    ],
12    defines = [
13        # Workaround for Windows build failures with VS 2022:
14        # "lld-link: error: /INFERASANLIBS is not allowed in .drectve"
15        # https://github.com/llvm/llvm-project/issues/56300#issuecomment-1214313292
16        "_DISABLE_STRING_ANNOTATION=1",
17        "_DISABLE_VECTOR_ANNOTATION=1",
18    ],
19    linkopts = select({
20        "//:clang_on_linux": ["-fuse-ld=lld"],
21        "@platforms//os:windows": [
22            # Windows requires all symbols that should be imported from the main
23            # executable to be defined by an import lib.
24            "/wholearchive:clang_rt.asan_dll_thunk-x86_64.lib",
25        ],
26        "//conditions:default": [],
27    }),
28    visibility = ["//examples:__pkg__"],
29    deps = [
30        "//examples:example_fuzzer_with_native_lib.hdrs",
31    ],
32)
33
34cc_jni_library(
35    name = "native_ubsan",
36    srcs = [
37        "com_example_ExampleFuzzerWithNative.cpp",
38    ],
39    copts = [
40        "-fsanitize=fuzzer-no-link,undefined",
41        "-fno-sanitize-recover=all",
42    ],
43    linkopts = select({
44        "//:clang_on_linux": ["-fuse-ld=lld"],
45        "@platforms//os:windows": [
46            # Using the asan thunk is correct here as it contains symbols for
47            # UBSan and SanCov as well.
48            "/wholearchive:clang_rt.asan_dll_thunk-x86_64.lib",
49        ],
50        "//conditions:default": [],
51    }),
52    visibility = ["//examples:__pkg__"],
53    deps = [
54        "//examples:example_fuzzer_with_native_lib.hdrs",
55    ],
56)
57