##// END OF EJS Templates
fuzz: use Python 3 in makefile...
Martin von Zweigbergk -
r47574:1977495d default
parent child Browse files
Show More
@@ -1,130 +1,139 b''
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 # Default to Python 3.
14 #
15 # Windows ships Python 3 as `python.exe`, which may not be on PATH. py.exe is.
16 ifeq ($(OS),Windows_NT)
17 PYTHON?=py -3
18 else
19 PYTHON?=python3
20 endif
21
13 PYTHON_CONFIG ?= $$OUT/sanpy/bin/python-config
22 PYTHON_CONFIG ?= $$OUT/sanpy/bin/python-config
14 PYTHON_CONFIG_FLAGS ?= --ldflags --embed
23 PYTHON_CONFIG_FLAGS ?= --ldflags --embed
15
24
16 CXXFLAGS += -Wno-deprecated-register
25 CXXFLAGS += -Wno-deprecated-register
17
26
18 all: standalone_fuzz_target_runner.o oss-fuzz
27 all: standalone_fuzz_target_runner.o oss-fuzz
19
28
20 standalone_fuzz_target_runner.o: standalone_fuzz_target_runner.cc
29 standalone_fuzz_target_runner.o: standalone_fuzz_target_runner.cc
21
30
22 $$OUT/%_fuzzer_seed_corpus.zip: %_corpus.py
31 $$OUT/%_fuzzer_seed_corpus.zip: %_corpus.py
23 python $< $@
32 $(PYTHON) $< $@
24
33
25 pyutil.o: pyutil.cc pyutil.h
34 pyutil.o: pyutil.cc pyutil.h
26 $(CXX) $(CXXFLAGS) -g -O1 \
35 $(CXX) $(CXXFLAGS) -g -O1 \
27 `$(PYTHON_CONFIG) --cflags` \
36 `$(PYTHON_CONFIG) --cflags` \
28 -I../../mercurial -c -o pyutil.o pyutil.cc
37 -I../../mercurial -c -o pyutil.o pyutil.cc
29
38
30 bdiff-oss-fuzz.o: ../../mercurial/bdiff.c
39 bdiff-oss-fuzz.o: ../../mercurial/bdiff.c
31 $(CC) $(CFLAGS) -c -o bdiff-oss-fuzz.o ../../mercurial/bdiff.c
40 $(CC) $(CFLAGS) -c -o bdiff-oss-fuzz.o ../../mercurial/bdiff.c
32
41
33 bdiff_fuzzer: bdiff.cc bdiff-oss-fuzz.o
42 bdiff_fuzzer: bdiff.cc bdiff-oss-fuzz.o
34 $(CXX) $(CXXFLAGS) -std=c++17 -I../../mercurial bdiff.cc \
43 $(CXX) $(CXXFLAGS) -std=c++17 -I../../mercurial bdiff.cc \
35 bdiff-oss-fuzz.o $(LIB_FUZZING_ENGINE) -o \
44 bdiff-oss-fuzz.o $(LIB_FUZZING_ENGINE) -o \
36 $$OUT/bdiff_fuzzer
45 $$OUT/bdiff_fuzzer
37
46
38 mpatch.o: ../../mercurial/mpatch.c
47 mpatch.o: ../../mercurial/mpatch.c
39 $(CC) -g -O1 -fsanitize=fuzzer-no-link,address -c -o mpatch.o \
48 $(CC) -g -O1 -fsanitize=fuzzer-no-link,address -c -o mpatch.o \
40 ../../mercurial/mpatch.c
49 ../../mercurial/mpatch.c
41
50
42 mpatch-oss-fuzz.o: ../../mercurial/mpatch.c
51 mpatch-oss-fuzz.o: ../../mercurial/mpatch.c
43 $(CC) $(CFLAGS) -c -o mpatch-oss-fuzz.o ../../mercurial/mpatch.c
52 $(CC) $(CFLAGS) -c -o mpatch-oss-fuzz.o ../../mercurial/mpatch.c
44
53
45 mpatch_fuzzer: mpatch.cc mpatch-oss-fuzz.o $$OUT/mpatch_fuzzer_seed_corpus.zip
54 mpatch_fuzzer: mpatch.cc mpatch-oss-fuzz.o $$OUT/mpatch_fuzzer_seed_corpus.zip
46 $(CXX) $(CXXFLAGS) -std=c++17 -I../../mercurial mpatch.cc \
55 $(CXX) $(CXXFLAGS) -std=c++17 -I../../mercurial mpatch.cc \
47 mpatch-oss-fuzz.o $(LIB_FUZZING_ENGINE) -o \
56 mpatch-oss-fuzz.o $(LIB_FUZZING_ENGINE) -o \
48 $$OUT/mpatch_fuzzer
57 $$OUT/mpatch_fuzzer
49
58
50 fuzz-x%.o: ../../mercurial/thirdparty/xdiff/x%.c ../../mercurial/thirdparty/xdiff/*.h
59 fuzz-x%.o: ../../mercurial/thirdparty/xdiff/x%.c ../../mercurial/thirdparty/xdiff/*.h
51 $(CC) $(CFLAGS) -c \
60 $(CC) $(CFLAGS) -c \
52 -o $@ \
61 -o $@ \
53 $<
62 $<
54
63
55 xdiff_fuzzer: xdiff.cc fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o
64 xdiff_fuzzer: xdiff.cc fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o
56 $(CXX) $(CXXFLAGS) -std=c++17 -I../../mercurial xdiff.cc \
65 $(CXX) $(CXXFLAGS) -std=c++17 -I../../mercurial xdiff.cc \
57 fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o \
66 fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o \
58 $(LIB_FUZZING_ENGINE) -o $$OUT/xdiff_fuzzer
67 $(LIB_FUZZING_ENGINE) -o $$OUT/xdiff_fuzzer
59
68
60 parsers-%.o: ../../mercurial/cext/%.c
69 parsers-%.o: ../../mercurial/cext/%.c
61 $(CC) -I../../mercurial `$(PYTHON_CONFIG) --cflags` $(CFLAGS) -c \
70 $(CC) -I../../mercurial `$(PYTHON_CONFIG) --cflags` $(CFLAGS) -c \
62 -o $@ $<
71 -o $@ $<
63
72
64 PARSERS_OBJS=parsers-manifest.o parsers-charencode.o parsers-parsers.o parsers-dirs.o parsers-pathencode.o parsers-revlog.o
73 PARSERS_OBJS=parsers-manifest.o parsers-charencode.o parsers-parsers.o parsers-dirs.o parsers-pathencode.o parsers-revlog.o
65
74
66 dirs_fuzzer: dirs.cc pyutil.o $(PARSERS_OBJS) $$OUT/dirs_fuzzer_seed_corpus.zip
75 dirs_fuzzer: dirs.cc pyutil.o $(PARSERS_OBJS) $$OUT/dirs_fuzzer_seed_corpus.zip
67 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
76 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
68 -Wno-register -Wno-macro-redefined \
77 -Wno-register -Wno-macro-redefined \
69 -I../../mercurial dirs.cc \
78 -I../../mercurial dirs.cc \
70 pyutil.o $(PARSERS_OBJS) \
79 pyutil.o $(PARSERS_OBJS) \
71 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) $(PYTHON_CONFIG_FLAGS)` \
80 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) $(PYTHON_CONFIG_FLAGS)` \
72 -o $$OUT/dirs_fuzzer
81 -o $$OUT/dirs_fuzzer
73
82
74 fncache_fuzzer: fncache.cc
83 fncache_fuzzer: fncache.cc
75 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
84 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
76 -Wno-register -Wno-macro-redefined \
85 -Wno-register -Wno-macro-redefined \
77 -I../../mercurial fncache.cc \
86 -I../../mercurial fncache.cc \
78 pyutil.o $(PARSERS_OBJS) \
87 pyutil.o $(PARSERS_OBJS) \
79 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) $(PYTHON_CONFIG_FLAGS)` \
88 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) $(PYTHON_CONFIG_FLAGS)` \
80 -o $$OUT/fncache_fuzzer
89 -o $$OUT/fncache_fuzzer
81
90
82 jsonescapeu8fast_fuzzer: jsonescapeu8fast.cc pyutil.o $(PARSERS_OBJS)
91 jsonescapeu8fast_fuzzer: jsonescapeu8fast.cc pyutil.o $(PARSERS_OBJS)
83 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
92 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
84 -Wno-register -Wno-macro-redefined \
93 -Wno-register -Wno-macro-redefined \
85 -I../../mercurial jsonescapeu8fast.cc \
94 -I../../mercurial jsonescapeu8fast.cc \
86 pyutil.o $(PARSERS_OBJS) \
95 pyutil.o $(PARSERS_OBJS) \
87 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) $(PYTHON_CONFIG_FLAGS)` \
96 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) $(PYTHON_CONFIG_FLAGS)` \
88 -o $$OUT/jsonescapeu8fast_fuzzer
97 -o $$OUT/jsonescapeu8fast_fuzzer
89
98
90 manifest_fuzzer: manifest.cc pyutil.o $(PARSERS_OBJS) $$OUT/manifest_fuzzer_seed_corpus.zip
99 manifest_fuzzer: manifest.cc pyutil.o $(PARSERS_OBJS) $$OUT/manifest_fuzzer_seed_corpus.zip
91 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
100 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
92 -Wno-register -Wno-macro-redefined \
101 -Wno-register -Wno-macro-redefined \
93 -I../../mercurial manifest.cc \
102 -I../../mercurial manifest.cc \
94 pyutil.o $(PARSERS_OBJS) \
103 pyutil.o $(PARSERS_OBJS) \
95 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) $(PYTHON_CONFIG_FLAGS)` \
104 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) $(PYTHON_CONFIG_FLAGS)` \
96 -o $$OUT/manifest_fuzzer
105 -o $$OUT/manifest_fuzzer
97
106
98 revlog_fuzzer: revlog.cc pyutil.o $(PARSERS_OBJS) $$OUT/revlog_fuzzer_seed_corpus.zip
107 revlog_fuzzer: revlog.cc pyutil.o $(PARSERS_OBJS) $$OUT/revlog_fuzzer_seed_corpus.zip
99 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
108 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
100 -Wno-register -Wno-macro-redefined \
109 -Wno-register -Wno-macro-redefined \
101 -I../../mercurial revlog.cc \
110 -I../../mercurial revlog.cc \
102 pyutil.o $(PARSERS_OBJS) \
111 pyutil.o $(PARSERS_OBJS) \
103 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) $(PYTHON_CONFIG_FLAGS)` \
112 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) $(PYTHON_CONFIG_FLAGS)` \
104 -o $$OUT/revlog_fuzzer
113 -o $$OUT/revlog_fuzzer
105
114
106 dirstate_fuzzer: dirstate.cc pyutil.o $(PARSERS_OBJS) $$OUT/dirstate_fuzzer_seed_corpus.zip
115 dirstate_fuzzer: dirstate.cc pyutil.o $(PARSERS_OBJS) $$OUT/dirstate_fuzzer_seed_corpus.zip
107 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
116 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
108 -Wno-register -Wno-macro-redefined \
117 -Wno-register -Wno-macro-redefined \
109 -I../../mercurial dirstate.cc \
118 -I../../mercurial dirstate.cc \
110 pyutil.o $(PARSERS_OBJS) \
119 pyutil.o $(PARSERS_OBJS) \
111 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) $(PYTHON_CONFIG_FLAGS)` \
120 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) $(PYTHON_CONFIG_FLAGS)` \
112 -o $$OUT/dirstate_fuzzer
121 -o $$OUT/dirstate_fuzzer
113
122
114 fm1readmarkers_fuzzer: fm1readmarkers.cc pyutil.o $(PARSERS_OBJS) $$OUT/fm1readmarkers_fuzzer_seed_corpus.zip
123 fm1readmarkers_fuzzer: fm1readmarkers.cc pyutil.o $(PARSERS_OBJS) $$OUT/fm1readmarkers_fuzzer_seed_corpus.zip
115 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
124 $(CXX) $(CXXFLAGS) `$(PYTHON_CONFIG) --cflags` \
116 -Wno-register -Wno-macro-redefined \
125 -Wno-register -Wno-macro-redefined \
117 -I../../mercurial fm1readmarkers.cc \
126 -I../../mercurial fm1readmarkers.cc \
118 pyutil.o $(PARSERS_OBJS) \
127 pyutil.o $(PARSERS_OBJS) \
119 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) $(PYTHON_CONFIG_FLAGS)` \
128 $(LIB_FUZZING_ENGINE) `$(PYTHON_CONFIG) $(PYTHON_CONFIG_FLAGS)` \
120 -o $$OUT/fm1readmarkers_fuzzer
129 -o $$OUT/fm1readmarkers_fuzzer
121
130
122 clean:
131 clean:
123 $(RM) *.o *_fuzzer \
132 $(RM) *.o *_fuzzer \
124 bdiff \
133 bdiff \
125 mpatch \
134 mpatch \
126 xdiff
135 xdiff
127
136
128 oss-fuzz: bdiff_fuzzer mpatch_fuzzer xdiff_fuzzer dirs_fuzzer fncache_fuzzer jsonescapeu8fast_fuzzer manifest_fuzzer revlog_fuzzer dirstate_fuzzer fm1readmarkers_fuzzer
137 oss-fuzz: bdiff_fuzzer mpatch_fuzzer xdiff_fuzzer dirs_fuzzer fncache_fuzzer jsonescapeu8fast_fuzzer manifest_fuzzer revlog_fuzzer dirstate_fuzzer fm1readmarkers_fuzzer
129
138
130 .PHONY: all clean oss-fuzz
139 .PHONY: all clean oss-fuzz
General Comments 0
You need to be logged in to leave comments. Login now