##// END OF EJS Templates
fuzz: clean up some repetition on building parsers.so fuzzers...
Augie Fackler -
r44269:d9f85f61 default
parent child Browse files
Show More
@@ -1,165 +1,141
1 CC = clang
1 CC = clang
2 CXX = clang++
2 CXX = clang++
3
3
4 # By default, use our own standalone_fuzz_target_runner.
4 # By default, use our own standalone_fuzz_target_runner.
5 # This runner does no fuzzing, but simply executes the inputs
5 # This runner does no fuzzing, but simply executes the inputs
6 # provided via parameters.
6 # provided via parameters.
7 # Run e.g. "make all LIB_FUZZING_ENGINE=/path/to/libFuzzer.a"
7 # Run e.g. "make all LIB_FUZZING_ENGINE=/path/to/libFuzzer.a"
8 # to link the fuzzer(s) against a real fuzzing engine.
8 # to link the fuzzer(s) against a real fuzzing engine.
9 #
9 #
10 # OSS-Fuzz will define its own value for LIB_FUZZING_ENGINE.
10 # OSS-Fuzz will define its own value for LIB_FUZZING_ENGINE.
11 LIB_FUZZING_ENGINE ?= standalone_fuzz_target_runner.o
11 LIB_FUZZING_ENGINE ?= standalone_fuzz_target_runner.o
12
12
13 PYTHON_CONFIG ?= $$OUT/sanpy/bin/python-config
13 PYTHON_CONFIG ?= $$OUT/sanpy/bin/python-config
14
14
15 CXXFLAGS += -Wno-deprecated-register
15 CXXFLAGS += -Wno-deprecated-register
16
16
17 all: standalone_fuzz_target_runner.o oss-fuzz
17 all: standalone_fuzz_target_runner.o oss-fuzz
18
18
19 standalone_fuzz_target_runner.o: standalone_fuzz_target_runner.cc
19 standalone_fuzz_target_runner.o: standalone_fuzz_target_runner.cc
20
20
21 pyutil.o: pyutil.cc pyutil.h
21 pyutil.o: pyutil.cc pyutil.h
22 $(CXX) $(CXXFLAGS) -g -O1 \
22 $(CXX) $(CXXFLAGS) -g -O1 \
23 `$(PYTHON_CONFIG) --cflags` \
23 `$(PYTHON_CONFIG) --cflags` \
24 -I../../mercurial -c -o pyutil.o pyutil.cc
24 -I../../mercurial -c -o pyutil.o pyutil.cc
25
25
26 bdiff-oss-fuzz.o: ../../mercurial/bdiff.c
26 bdiff-oss-fuzz.o: ../../mercurial/bdiff.c
27 $(CC) $(CFLAGS) -c -o bdiff-oss-fuzz.o ../../mercurial/bdiff.c
27 $(CC) $(CFLAGS) -c -o bdiff-oss-fuzz.o ../../mercurial/bdiff.c
28
28
29 bdiff_fuzzer: bdiff.cc bdiff-oss-fuzz.o
29 bdiff_fuzzer: bdiff.cc bdiff-oss-fuzz.o
30 $(CXX) $(CXXFLAGS) -std=c++17 -I../../mercurial bdiff.cc \
30 $(CXX) $(CXXFLAGS) -std=c++17 -I../../mercurial bdiff.cc \
31 bdiff-oss-fuzz.o $(LIB_FUZZING_ENGINE) -o \
31 bdiff-oss-fuzz.o $(LIB_FUZZING_ENGINE) -o \
32 $$OUT/bdiff_fuzzer
32 $$OUT/bdiff_fuzzer
33
33
34 mpatch.o: ../../mercurial/mpatch.c
34 mpatch.o: ../../mercurial/mpatch.c
35 $(CC) -g -O1 -fsanitize=fuzzer-no-link,address -c -o mpatch.o \
35 $(CC) -g -O1 -fsanitize=fuzzer-no-link,address -c -o mpatch.o \
36 ../../mercurial/mpatch.c
36 ../../mercurial/mpatch.c
37
37
38 mpatch-oss-fuzz.o: ../../mercurial/mpatch.c
38 mpatch-oss-fuzz.o: ../../mercurial/mpatch.c
39 $(CC) $(CFLAGS) -c -o mpatch-oss-fuzz.o ../../mercurial/mpatch.c
39 $(CC) $(CFLAGS) -c -o mpatch-oss-fuzz.o ../../mercurial/mpatch.c
40
40
41 mpatch_fuzzer: mpatch.cc mpatch-oss-fuzz.o
41 mpatch_fuzzer: mpatch.cc mpatch-oss-fuzz.o
42 $(CXX) $(CXXFLAGS) -std=c++17 -I../../mercurial mpatch.cc \
42 $(CXX) $(CXXFLAGS) -std=c++17 -I../../mercurial mpatch.cc \
43 mpatch-oss-fuzz.o $(LIB_FUZZING_ENGINE) -o \
43 mpatch-oss-fuzz.o $(LIB_FUZZING_ENGINE) -o \
44 $$OUT/mpatch_fuzzer
44 $$OUT/mpatch_fuzzer
45
45
46 mpatch_corpus.zip:
46 mpatch_corpus.zip:
47 python mpatch_corpus.py $$OUT/mpatch_fuzzer_seed_corpus.zip
47 python mpatch_corpus.py $$OUT/mpatch_fuzzer_seed_corpus.zip
48
48
49 fuzz-x%.o: ../../mercurial/thirdparty/xdiff/x%.c ../../mercurial/thirdparty/xdiff/*.h
49 fuzz-x%.o: ../../mercurial/thirdparty/xdiff/x%.c ../../mercurial/thirdparty/xdiff/*.h
50 $(CC) $(CFLAGS) -c \
50 $(CC) $(CFLAGS) -c \
51 -o $@ \
51 -o $@ \
52 $<
52 $<
53
53
54 xdiff_fuzzer: xdiff.cc fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o
54 xdiff_fuzzer: xdiff.cc fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o
55 $(CXX) $(CXXFLAGS) -std=c++17 -I../../mercurial xdiff.cc \
55 $(CXX) $(CXXFLAGS) -std=c++17 -I../../mercurial xdiff.cc \
56 fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o \
56 fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o \
57 $(LIB_FUZZING_ENGINE) -o $$OUT/xdiff_fuzzer
57 $(LIB_FUZZING_ENGINE) -o $$OUT/xdiff_fuzzer
58
58
59 manifest.o: ../../mercurial/cext/manifest.c
59 parsers-%.o: ../../mercurial/cext/%.c
60 $(CC) $(CFLAGS) `$(PYTHON_CONFIG) --cflags` \
60 $(CC) -I../../mercurial `$(PYTHON_CONFIG) --cflags` $(CFLAGS) -c \
61 -I../../mercurial \
61 -o $@ $<
62 -c -o manifest.o ../../mercurial/cext/manifest.c
63
64 charencode.o: ../../mercurial/cext/charencode.c
65 $(CC) $(CFLAGS) `$(PYTHON_CONFIG) --cflags` \
66 -I../../mercurial \
67 -c -o charencode.o ../../mercurial/cext/charencode.c
68
69 parsers.o: ../../mercurial/cext/parsers.c
70 $(CC) $(CFLAGS) `$(PYTHON_CONFIG) --cflags` \
71 -I../../mercurial \
72 -c -o parsers.o ../../mercurial/cext/parsers.c
73
62
74 dirs.o: ../../mercurial/cext/dirs.c
63 PARSERS_OBJS=parsers-manifest.o parsers-charencode.o parsers-parsers.o parsers-dirs.o parsers-pathencode.o parsers-revlog.o
75 $(CC) $(CFLAGS) `$(PYTHON_CONFIG) --cflags` \
76 -I../../mercurial \
77 -c -o dirs.o ../../mercurial/cext/dirs.c
78
64
79 pathencode.o: ../../mercurial/cext/pathencode.c
65 dirs_fuzzer: dirs.cc pyutil.o $(PARSERS_OBJS)
80 $(CC) $(CFLAGS) `$(PYTHON_CONFIG) --cflags` \
81 -I../../mercurial \
82 -c -o pathencode.o ../../mercurial/cext/pathencode.c
83
84 revlog.o: ../../mercurial/cext/revlog.c
85 $(CC) $(CFLAGS) `$(PYTHON_CONFIG) --cflags` \
86 -I../../mercurial \
87 -c -o revlog.o ../../mercurial/cext/revlog.c
88
89 dirs_fuzzer: dirs.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o
90 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
66 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
91 -Wno-register -Wno-macro-redefined \
67 -Wno-register -Wno-macro-redefined \
92 -I../../mercurial dirs.cc \
68 -I../../mercurial dirs.cc \
93 manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \
69 pyutil.o $(PARSERS_OBJS) \
94 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) --ldflags` \
70 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) --ldflags` \
95 -o $$OUT/dirs_fuzzer
71 -o $$OUT/dirs_fuzzer
96
72
97 fncache_fuzzer: fncache.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o
73 fncache_fuzzer: fncache.cc
98 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
74 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
99 -Wno-register -Wno-macro-redefined \
75 -Wno-register -Wno-macro-redefined \
100 -I../../mercurial fncache.cc \
76 -I../../mercurial fncache.cc \
101 manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \
77 pyutil.o $(PARSERS_OBJS) \
102 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) --ldflags` \
78 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) --ldflags` \
103 -o $$OUT/fncache_fuzzer
79 -o $$OUT/fncache_fuzzer
104
80
105 jsonescapeu8fast_fuzzer: jsonescapeu8fast.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o
81 jsonescapeu8fast_fuzzer: jsonescapeu8fast.cc pyutil.o $(PARSERS_OBJS)
106 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
82 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
107 -Wno-register -Wno-macro-redefined \
83 -Wno-register -Wno-macro-redefined \
108 -I../../mercurial jsonescapeu8fast.cc \
84 -I../../mercurial jsonescapeu8fast.cc \
109 manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \
85 pyutil.o $(PARSERS_OBJS) \
110 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) --ldflags` \
86 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) --ldflags` \
111 -o $$OUT/jsonescapeu8fast_fuzzer
87 -o $$OUT/jsonescapeu8fast_fuzzer
112
88
113 manifest_corpus.zip:
89 manifest_corpus.zip:
114 python manifest_corpus.py $$OUT/manifest_fuzzer_seed_corpus.zip
90 python manifest_corpus.py $$OUT/manifest_fuzzer_seed_corpus.zip
115
91
116 manifest_fuzzer: manifest.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o
92 manifest_fuzzer: manifest.cc pyutil.o $(PARSERS_OBJS)
117 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
93 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
118 -Wno-register -Wno-macro-redefined \
94 -Wno-register -Wno-macro-redefined \
119 -I../../mercurial manifest.cc \
95 -I../../mercurial manifest.cc \
120 manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \
96 pyutil.o $(PARSERS_OBJS) \
121 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) --ldflags` \
97 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) --ldflags` \
122 -o $$OUT/manifest_fuzzer
98 -o $$OUT/manifest_fuzzer
123
99
124 revlog_fuzzer: revlog.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o
100 revlog_fuzzer: revlog.cc pyutil.o $(PARSERS_OBJS)
125 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
101 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
126 -Wno-register -Wno-macro-redefined \
102 -Wno-register -Wno-macro-redefined \
127 -I../../mercurial revlog.cc \
103 -I../../mercurial revlog.cc \
128 manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \
104 pyutil.o $(PARSERS_OBJS) \
129 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) --ldflags` \
105 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) --ldflags` \
130 -o $$OUT/revlog_fuzzer
106 -o $$OUT/revlog_fuzzer
131
107
132 revlog_corpus.zip:
108 revlog_corpus.zip:
133 python revlog_corpus.py $$OUT/revlog_fuzzer_seed_corpus.zip
109 python revlog_corpus.py $$OUT/revlog_fuzzer_seed_corpus.zip
134
110
135 dirstate_fuzzer: dirstate.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o
111 dirstate_fuzzer: dirstate.cc pyutil.o $(PARSERS_OBJS)
136 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
112 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
137 -Wno-register -Wno-macro-redefined \
113 -Wno-register -Wno-macro-redefined \
138 -I../../mercurial dirstate.cc \
114 -I../../mercurial dirstate.cc \
139 manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \
115 pyutil.o $(PARSERS_OBJS) \
140 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) --ldflags` \
116 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) --ldflags` \
141 -o $$OUT/dirstate_fuzzer
117 -o $$OUT/dirstate_fuzzer
142
118
143 dirstate_corpus.zip:
119 dirstate_corpus.zip:
144 python dirstate_corpus.py $$OUT/dirstate_fuzzer_seed_corpus.zip
120 python dirstate_corpus.py $$OUT/dirstate_fuzzer_seed_corpus.zip
145
121
146 fm1readmarkers_fuzzer: fm1readmarkers.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o
122 fm1readmarkers_fuzzer: fm1readmarkers.cc pyutil.o $(PARSERS_OBJS)
147 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
123 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
148 -Wno-register -Wno-macro-redefined \
124 -Wno-register -Wno-macro-redefined \
149 -I../../mercurial fm1readmarkers.cc \
125 -I../../mercurial fm1readmarkers.cc \
150 manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \
126 pyutil.o $(PARSERS_OBJS) \
151 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) --ldflags` \
127 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) --ldflags` \
152 -o $$OUT/fm1readmarkers_fuzzer
128 -o $$OUT/fm1readmarkers_fuzzer
153
129
154 fm1readmarkers_corpus.zip:
130 fm1readmarkers_corpus.zip:
155 python fm1readmarkers_corpus.py $$OUT/fm1readmarkers_fuzzer_seed_corpus.zip
131 python fm1readmarkers_corpus.py $$OUT/fm1readmarkers_fuzzer_seed_corpus.zip
156
132
157 clean:
133 clean:
158 $(RM) *.o *_fuzzer \
134 $(RM) *.o *_fuzzer \
159 bdiff \
135 bdiff \
160 mpatch \
136 mpatch \
161 xdiff
137 xdiff
162
138
163 oss-fuzz: bdiff_fuzzer mpatch_fuzzer mpatch_corpus.zip xdiff_fuzzer dirs_fuzzer fncache_fuzzer jsonescapeu8fast_fuzzer manifest_fuzzer manifest_corpus.zip revlog_fuzzer revlog_corpus.zip dirstate_fuzzer dirstate_corpus.zip fm1readmarkers_fuzzer fm1readmarkers_corpus.zip
139 oss-fuzz: bdiff_fuzzer mpatch_fuzzer mpatch_corpus.zip xdiff_fuzzer dirs_fuzzer fncache_fuzzer jsonescapeu8fast_fuzzer manifest_fuzzer manifest_corpus.zip revlog_fuzzer revlog_corpus.zip dirstate_fuzzer dirstate_corpus.zip fm1readmarkers_fuzzer fm1readmarkers_corpus.zip
164
140
165 .PHONY: all clean oss-fuzz
141 .PHONY: all clean oss-fuzz
General Comments 0
You need to be logged in to leave comments. Login now