1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- 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,
- )
|