Mercurial > minori
comparison dep/fmt/test/fuzzing/build.sh @ 343:1faa72660932
*: transfer back to cmake from autotools
autotools just made lots of things more complicated than
they should have and many things broke (i.e. translations)
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Thu, 20 Jun 2024 05:56:06 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
342:adb79bdde329 | 343:1faa72660932 |
---|---|
1 #!/bin/sh | |
2 # | |
3 # Creates fuzzer builds of various kinds | |
4 # - oss-fuzz emulated mode (makes sure a simulated invocation by oss-fuzz works) | |
5 # - libFuzzer build (you will need clang) | |
6 # - afl build (you will need afl) | |
7 # | |
8 # | |
9 # Copyright (c) 2019 Paul Dreik | |
10 # | |
11 # For the license information refer to format.h. | |
12 | |
13 set -e | |
14 me=$(basename $0) | |
15 root=$(readlink -f "$(dirname "$0")/../..") | |
16 | |
17 | |
18 echo $me: root=$root | |
19 | |
20 here=$(pwd) | |
21 | |
22 CXXFLAGSALL="-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION= -g" | |
23 CMAKEFLAGSALL="$root -GNinja -DCMAKE_BUILD_TYPE=Debug -DFMT_DOC=Off -DFMT_TEST=Off -DFMT_FUZZ=On -DCMAKE_CXX_STANDARD=17" | |
24 | |
25 CLANG=clang++-11 | |
26 | |
27 # For performance analysis of the fuzzers. | |
28 builddir=$here/build-fuzzers-perfanalysis | |
29 mkdir -p $builddir | |
30 cd $builddir | |
31 CXX="ccache g++" CXXFLAGS="$CXXFLAGSALL -g" cmake \ | |
32 $CMAKEFLAGSALL \ | |
33 -DFMT_FUZZ_LINKMAIN=On \ | |
34 -DCMAKE_BUILD_TYPE=Release | |
35 | |
36 cmake --build $builddir | |
37 | |
38 # Builds the fuzzers as oss-fuzz does. | |
39 builddir=$here/build-fuzzers-ossfuzz | |
40 mkdir -p $builddir | |
41 cd $builddir | |
42 CXX=$CLANG \ | |
43 CXXFLAGS="$CXXFLAGSALL -fsanitize=fuzzer-no-link" cmake \ | |
44 cmake $CMAKEFLAGSALL \ | |
45 -DFMT_FUZZ_LINKMAIN=Off \ | |
46 -DFMT_FUZZ_LDFLAGS="-fsanitize=fuzzer" | |
47 | |
48 cmake --build $builddir | |
49 | |
50 | |
51 # Builds fuzzers for local fuzzing with libfuzzer with asan+usan. | |
52 builddir=$here/build-fuzzers-libfuzzer | |
53 mkdir -p $builddir | |
54 cd $builddir | |
55 CXX=$CLANG \ | |
56 CXXFLAGS="$CXXFLAGSALL -fsanitize=fuzzer-no-link,address,undefined" cmake \ | |
57 cmake $CMAKEFLAGSALL \ | |
58 -DFMT_FUZZ_LINKMAIN=Off \ | |
59 -DFMT_FUZZ_LDFLAGS="-fsanitize=fuzzer" | |
60 | |
61 cmake --build $builddir | |
62 | |
63 # Builds a fast fuzzer for making coverage fast. | |
64 builddir=$here/build-fuzzers-fast | |
65 mkdir -p $builddir | |
66 cd $builddir | |
67 CXX=$CLANG \ | |
68 CXXFLAGS="$CXXFLAGSALL -fsanitize=fuzzer-no-link -O3" cmake \ | |
69 cmake $CMAKEFLAGSALL \ | |
70 -DFMT_FUZZ_LINKMAIN=Off \ | |
71 -DFMT_FUZZ_LDFLAGS="-fsanitize=fuzzer" \ | |
72 -DCMAKE_BUILD_TYPE=Release | |
73 | |
74 cmake --build $builddir | |
75 | |
76 | |
77 # Builds fuzzers for local fuzzing with afl. | |
78 builddir=$here/build-fuzzers-afl | |
79 mkdir -p $builddir | |
80 cd $builddir | |
81 CXX="afl-g++" \ | |
82 CXXFLAGS="$CXXFLAGSALL -fsanitize=address,undefined" \ | |
83 cmake $CMAKEFLAGSALL \ | |
84 -DFMT_FUZZ_LINKMAIN=On | |
85 | |
86 cmake --build $builddir | |
87 | |
88 | |
89 echo $me: all good | |
90 |