xref: /aosp_15_r20/external/jazzer-api/third_party/libFuzzer.BUILD (revision 33edd6723662ea34453766bfdca85dbfdd5342b8)
1cc_library(
2    name = "libfuzzer_no_main",
3    srcs = glob(
4        [
5            "*.cpp",
6        ],
7        exclude = ["FuzzerMain.cpp"],
8    ),
9    hdrs = glob([
10        "*.h",
11        "*.def",
12    ]),
13    copts = [
14        # https://github.com/llvm/llvm-project/blob/eab395fa4074a5a0cbfebe811937dbb1816df9ef/compiler-rt/CMakeLists.txt#L294-L309
15        "-fno-builtin",
16        "-fno-exceptions",
17        "-funwind-tables",
18        "-fno-stack-protector",
19        "-fvisibility=hidden",
20        "-fno-lto",
21    ] + select({
22        "@platforms//os:windows": [
23            # https://github.com/llvm/llvm-project/blob/eab395fa4074a5a0cbfebe811937dbb1816df9ef/compiler-rt/CMakeLists.txt#L362-L363
24            "/Oy-",
25            "/GS-",
26            "/std:c++17",
27        ],
28        "//conditions:default": [
29            # https://github.com/llvm/llvm-project/commit/29d3ba7576b30a37bd19a5d40f304fc39c6ab13d
30            "-fno-omit-frame-pointer",
31            # https://github.com/llvm/llvm-project/blob/eab395fa4074a5a0cbfebe811937dbb1816df9ef/compiler-rt/CMakeLists.txt#L392
32            "-O3",
33            # Use the same C++ standard as Jazzer itself.
34            "-std=c++17",
35        ],
36    }),
37    linkstatic = True,
38    visibility = ["//visibility:public"],
39    alwayslink = True,
40)
41