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
50
51
52
53
54
55
56
57
58
59
60
61
62
|
from devtools.yamaker.modules import Linkable, Switch
from devtools.yamaker.platform_macros import LLVM_VERSION
from devtools.yamaker.project import CMakeNinjaNixProject
# as of 15.0.x, libfuzzer makes use of
#
# ATTRIBUTE_NO_SANITIZE_ALL
# size_t ForEachNonZeroByte()
#
# which invokes undefined behavior,
# which is not disabled by ATTRIBUTE_NO_SANITIZE_ALL
S1 = """
IF (SANITIZER_TYPE == "undefined")
NO_SANITIZE()
ENDIF()
"""
def post_install(self):
with self.yamakes["."] as m:
m.NO_SANITIZE_COVERAGE = True
m.after("CFLAGS", S1)
m.before(
"NO_SANITIZE_COVERAGE",
Switch(
{
'SANITIZE_COVERAGE MATCHES "trace-pc"': 'MESSAGE(FATAL_ERROR "I will crash you with trace-pc or trace-pc-guard. Use inline-8bit-counters.")'
}
),
)
m.SET.append(["SANITIZER_CFLAGS"])
m.after(
"SRCS",
Switch(
OS_WINDOWS=Linkable(SRCS=["lib/fuzzer/standalone/StandaloneFuzzTargetMain.c"]),
default=Linkable(SRCS=m.SRCS),
),
)
m.SRCS = []
m.PEERDIR.add("library/cpp/sanitizer/include")
with self.yamakes["lib/fuzzer/afl"] as m:
m.NO_SANITIZE = True
m.PEERDIR = ["contrib/libs/afl/llvm_mode"]
llvm_libfuzzer = CMakeNinjaNixProject(
owners=["g:cpp-contrib"],
nixattr=f"llvmPackages_{LLVM_VERSION}.compiler-rt",
arcdir="contrib/libs/libfuzzer",
build_targets=["clang_rt.fuzzer-x86_64", "libfuzzer-afl.so"],
copy_sources=[
"include/fuzzer/FuzzedDataProvider.h",
"lib/fuzzer/standalone/StandaloneFuzzTargetMain.c",
],
put={
"clang_rt.fuzzer-x86_64": ".",
"fuzzer-afl": "lib/fuzzer/afl",
},
post_install=post_install,
)
|