comparison contrib/fuzz/Makefile @ 43812:bf0453866c80

fuzz: use a variable to allow specifying python-config to use Eventually we should probably default this to just `python-config` and have the oss-fuzz build.sh script specify the sanpy python-config, but for now this lets us make progress. Differential Revision: https://phab.mercurial-scm.org/D7563
author Augie Fackler <augie@google.com>
date Fri, 06 Dec 2019 15:15:05 -0500
parents d1587fadff06
children 5a9e2ae9899b
comparison
equal deleted inserted replaced
43811:d1587fadff06 43812:bf0453866c80
1 CC = clang 1 CC = clang
2 CXX = clang++ 2 CXX = clang++
3 3
4 LIB_FUZZING_ENGINE ?= -lFuzzingEngine 4 LIB_FUZZING_ENGINE ?= -lFuzzingEngine
5
6 PYTHON_CONFIG ?= $$OUT/sanpy/bin/python-config
5 7
6 CXXFLAGS += -Wno-deprecated-register 8 CXXFLAGS += -Wno-deprecated-register
7 9
8 all: bdiff mpatch xdiff 10 all: bdiff mpatch xdiff
9 11
10 pyutil.o: pyutil.cc pyutil.h 12 pyutil.o: pyutil.cc pyutil.h
11 $(CXX) $(CXXFLAGS) -g -O1 \ 13 $(CXX) $(CXXFLAGS) -g -O1 \
12 `$$OUT/sanpy/bin/python-config --cflags` \ 14 `$(PYTHON_CONFIG) --cflags` \
13 -I../../mercurial -c -o pyutil.o pyutil.cc 15 -I../../mercurial -c -o pyutil.o pyutil.cc
14 16
15 bdiff.o: ../../mercurial/bdiff.c 17 bdiff.o: ../../mercurial/bdiff.c
16 $(CC) $(CFLAGS) -fsanitize=fuzzer-no-link,address -c -o bdiff.o \ 18 $(CC) $(CFLAGS) -fsanitize=fuzzer-no-link,address -c -o bdiff.o \
17 ../../mercurial/bdiff.c 19 ../../mercurial/bdiff.c
69 $(CXX) $(CXXFLAGS) -std=c++17 -I../../mercurial xdiff.cc \ 71 $(CXX) $(CXXFLAGS) -std=c++17 -I../../mercurial xdiff.cc \
70 fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o \ 72 fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o \
71 $(LIB_FUZZING_ENGINE) -o $$OUT/xdiff_fuzzer 73 $(LIB_FUZZING_ENGINE) -o $$OUT/xdiff_fuzzer
72 74
73 manifest.o: ../../mercurial/cext/manifest.c 75 manifest.o: ../../mercurial/cext/manifest.c
74 $(CC) $(CFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ 76 $(CC) $(CFLAGS) `$(PYTHON_CONFIG) --cflags` \
75 -I../../mercurial \ 77 -I../../mercurial \
76 -c -o manifest.o ../../mercurial/cext/manifest.c 78 -c -o manifest.o ../../mercurial/cext/manifest.c
77 79
78 charencode.o: ../../mercurial/cext/charencode.c 80 charencode.o: ../../mercurial/cext/charencode.c
79 $(CC) $(CFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ 81 $(CC) $(CFLAGS) `$(PYTHON_CONFIG) --cflags` \
80 -I../../mercurial \ 82 -I../../mercurial \
81 -c -o charencode.o ../../mercurial/cext/charencode.c 83 -c -o charencode.o ../../mercurial/cext/charencode.c
82 84
83 parsers.o: ../../mercurial/cext/parsers.c 85 parsers.o: ../../mercurial/cext/parsers.c
84 $(CC) $(CFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ 86 $(CC) $(CFLAGS) `$(PYTHON_CONFIG) --cflags` \
85 -I../../mercurial \ 87 -I../../mercurial \
86 -c -o parsers.o ../../mercurial/cext/parsers.c 88 -c -o parsers.o ../../mercurial/cext/parsers.c
87 89
88 dirs.o: ../../mercurial/cext/dirs.c 90 dirs.o: ../../mercurial/cext/dirs.c
89 $(CC) $(CFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ 91 $(CC) $(CFLAGS) `$(PYTHON_CONFIG) --cflags` \
90 -I../../mercurial \ 92 -I../../mercurial \
91 -c -o dirs.o ../../mercurial/cext/dirs.c 93 -c -o dirs.o ../../mercurial/cext/dirs.c
92 94
93 pathencode.o: ../../mercurial/cext/pathencode.c 95 pathencode.o: ../../mercurial/cext/pathencode.c
94 $(CC) $(CFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ 96 $(CC) $(CFLAGS) `$(PYTHON_CONFIG) --cflags` \
95 -I../../mercurial \ 97 -I../../mercurial \
96 -c -o pathencode.o ../../mercurial/cext/pathencode.c 98 -c -o pathencode.o ../../mercurial/cext/pathencode.c
97 99
98 revlog.o: ../../mercurial/cext/revlog.c 100 revlog.o: ../../mercurial/cext/revlog.c
99 $(CC) $(CFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ 101 $(CC) $(CFLAGS) `$(PYTHON_CONFIG) --cflags` \
100 -I../../mercurial \ 102 -I../../mercurial \
101 -c -o revlog.o ../../mercurial/cext/revlog.c 103 -c -o revlog.o ../../mercurial/cext/revlog.c
102 104
103 dirs_fuzzer: dirs.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o 105 dirs_fuzzer: dirs.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o
104 $(CXX) $(CXXFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ 106 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
105 -Wno-register -Wno-macro-redefined \ 107 -Wno-register -Wno-macro-redefined \
106 -I../../mercurial dirs.cc \ 108 -I../../mercurial dirs.cc \
107 manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \ 109 manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \
108 $(LIB_FUZZING_ENGINE) `$$OUT/sanpy/bin/python-config --ldflags` \ 110 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) --ldflags` \
109 -o $$OUT/dirs_fuzzer 111 -o $$OUT/dirs_fuzzer
110 112
111 fncache_fuzzer: fncache.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o 113 fncache_fuzzer: fncache.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o
112 $(CXX) $(CXXFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ 114 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
113 -Wno-register -Wno-macro-redefined \ 115 -Wno-register -Wno-macro-redefined \
114 -I../../mercurial fncache.cc \ 116 -I../../mercurial fncache.cc \
115 manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \ 117 manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \
116 $(LIB_FUZZING_ENGINE) `$$OUT/sanpy/bin/python-config --ldflags` \ 118 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) --ldflags` \
117 -o $$OUT/fncache_fuzzer 119 -o $$OUT/fncache_fuzzer
118 120
119 jsonescapeu8fast_fuzzer: jsonescapeu8fast.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o 121 jsonescapeu8fast_fuzzer: jsonescapeu8fast.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o
120 $(CXX) $(CXXFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ 122 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
121 -Wno-register -Wno-macro-redefined \ 123 -Wno-register -Wno-macro-redefined \
122 -I../../mercurial jsonescapeu8fast.cc \ 124 -I../../mercurial jsonescapeu8fast.cc \
123 manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \ 125 manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \
124 $(LIB_FUZZING_ENGINE) `$$OUT/sanpy/bin/python-config --ldflags` \ 126 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) --ldflags` \
125 -o $$OUT/jsonescapeu8fast_fuzzer 127 -o $$OUT/jsonescapeu8fast_fuzzer
126 128
127 manifest_corpus.zip: 129 manifest_corpus.zip:
128 python manifest_corpus.py $$OUT/manifest_fuzzer_seed_corpus.zip 130 python manifest_corpus.py $$OUT/manifest_fuzzer_seed_corpus.zip
129 131
130 manifest_fuzzer: manifest.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o 132 manifest_fuzzer: manifest.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o
131 $(CXX) $(CXXFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ 133 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
132 -Wno-register -Wno-macro-redefined \ 134 -Wno-register -Wno-macro-redefined \
133 -I../../mercurial manifest.cc \ 135 -I../../mercurial manifest.cc \
134 manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \ 136 manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \
135 $(LIB_FUZZING_ENGINE) `$$OUT/sanpy/bin/python-config --ldflags` \ 137 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) --ldflags` \
136 -o $$OUT/manifest_fuzzer 138 -o $$OUT/manifest_fuzzer
137 139
138 revlog_fuzzer: revlog.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o 140 revlog_fuzzer: revlog.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o
139 $(CXX) $(CXXFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ 141 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
140 -Wno-register -Wno-macro-redefined \ 142 -Wno-register -Wno-macro-redefined \
141 -I../../mercurial revlog.cc \ 143 -I../../mercurial revlog.cc \
142 manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \ 144 manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \
143 $(LIB_FUZZING_ENGINE) `$$OUT/sanpy/bin/python-config --ldflags` \ 145 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) --ldflags` \
144 -o $$OUT/revlog_fuzzer 146 -o $$OUT/revlog_fuzzer
145 147
146 revlog_corpus.zip: 148 revlog_corpus.zip:
147 python revlog_corpus.py $$OUT/revlog_fuzzer_seed_corpus.zip 149 python revlog_corpus.py $$OUT/revlog_fuzzer_seed_corpus.zip
148 150
149 dirstate_fuzzer: dirstate.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o 151 dirstate_fuzzer: dirstate.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o
150 $(CXX) $(CXXFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ 152 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
151 -Wno-register -Wno-macro-redefined \ 153 -Wno-register -Wno-macro-redefined \
152 -I../../mercurial dirstate.cc \ 154 -I../../mercurial dirstate.cc \
153 manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \ 155 manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \
154 $(LIB_FUZZING_ENGINE) `$$OUT/sanpy/bin/python-config --ldflags` \ 156 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) --ldflags` \
155 -o $$OUT/dirstate_fuzzer 157 -o $$OUT/dirstate_fuzzer
156 158
157 dirstate_corpus.zip: 159 dirstate_corpus.zip:
158 python dirstate_corpus.py $$OUT/dirstate_fuzzer_seed_corpus.zip 160 python dirstate_corpus.py $$OUT/dirstate_fuzzer_seed_corpus.zip
159 161
160 fm1readmarkers_fuzzer: fm1readmarkers.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o 162 fm1readmarkers_fuzzer: fm1readmarkers.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o
161 $(CXX) $(CXXFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ 163 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
162 -Wno-register -Wno-macro-redefined \ 164 -Wno-register -Wno-macro-redefined \
163 -I../../mercurial fm1readmarkers.cc \ 165 -I../../mercurial fm1readmarkers.cc \
164 manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \ 166 manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \
165 $(LIB_FUZZING_ENGINE) `$$OUT/sanpy/bin/python-config --ldflags` \ 167 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) --ldflags` \
166 -o $$OUT/fm1readmarkers_fuzzer 168 -o $$OUT/fm1readmarkers_fuzzer
167 169
168 fm1readmarkers_corpus.zip: 170 fm1readmarkers_corpus.zip:
169 python fm1readmarkers_corpus.py $$OUT/fm1readmarkers_fuzzer_seed_corpus.zip 171 python fm1readmarkers_corpus.py $$OUT/fm1readmarkers_fuzzer_seed_corpus.zip
170 172