aboutsummaryrefslogtreecommitdiff
path: root/examples/src/main/native/com/example/BUILD.bazel
blob: 7f23f75e9efabc020e519e3a0be377e31af2163e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
load("@fmeum_rules_jni//jni:defs.bzl", "cc_jni_library")

cc_jni_library(
    name = "native_asan",
    srcs = [
        "com_example_ExampleFuzzerWithNative.cpp",
    ],
    copts = [
        "-fsanitize=fuzzer-no-link,address",
        "-fno-sanitize-blacklist",
    ],
    linkopts = select({
        "//:clang_on_linux": ["-fuse-ld=lld"],
        "@platforms//os:windows": [
            # Windows requires all symbols that should be imported from the main
            # executable to be defined by an import lib.
            "/wholearchive:clang_rt.asan_dll_thunk-x86_64.lib",
        ],
        "//conditions:default": [],
    }),
    visibility = ["//examples:__pkg__"],
    deps = [
        "//examples:example_fuzzer_with_native_lib.hdrs",
    ],
)

cc_jni_library(
    name = "native_ubsan",
    srcs = [
        "com_example_ExampleFuzzerWithNative.cpp",
    ],
    copts = [
        "-fsanitize=fuzzer-no-link,undefined",
        "-fno-sanitize-recover=all",
    ],
    linkopts = select({
        "//:clang_on_linux": ["-fuse-ld=lld"],
        "@platforms//os:windows": [
            # Using the asan thunk is correct here as it contains symbols for
            # UBSan and SanCov as well.
            "/wholearchive:clang_rt.asan_dll_thunk-x86_64.lib",
        ],
        "//conditions:default": [],
    }),
    visibility = ["//examples:__pkg__"],
    deps = [
        "//examples:example_fuzzer_with_native_lib.hdrs",
    ],
)