##// END OF EJS Templates
fuzz: more correctly specify CFLAGS and LDFLAGS when building Python...
Augie Fackler -
r40845:177b47ce default
parent child Browse files
Show More
@@ -1,128 +1,128 b''
1 1 CC = clang
2 2 CXX = clang++
3 3
4 4 all: bdiff mpatch xdiff
5 5
6 6 fuzzutil.o: fuzzutil.cc fuzzutil.h
7 7 $(CXX) $(CXXFLAGS) -g -O1 -fsanitize=fuzzer-no-link,address \
8 8 -std=c++17 \
9 9 -I../../mercurial -c -o fuzzutil.o fuzzutil.cc
10 10
11 11 fuzzutil-oss-fuzz.o: fuzzutil.cc fuzzutil.h
12 12 $(CXX) $(CXXFLAGS) -std=c++17 \
13 13 -I../../mercurial -c -o fuzzutil-oss-fuzz.o fuzzutil.cc
14 14
15 15 bdiff.o: ../../mercurial/bdiff.c
16 16 $(CC) $(CFLAGS) -fsanitize=fuzzer-no-link,address -c -o bdiff.o \
17 17 ../../mercurial/bdiff.c
18 18
19 19 bdiff: bdiff.cc bdiff.o fuzzutil.o
20 20 $(CXX) $(CXXFLAGS) -DHG_FUZZER_INCLUDE_MAIN=1 -g -O1 -fsanitize=fuzzer-no-link,address \
21 21 -std=c++17 \
22 22 -I../../mercurial bdiff.cc bdiff.o fuzzutil.o -o bdiff
23 23
24 24 bdiff-oss-fuzz.o: ../../mercurial/bdiff.c
25 25 $(CC) $(CFLAGS) -c -o bdiff-oss-fuzz.o ../../mercurial/bdiff.c
26 26
27 27 bdiff_fuzzer: bdiff.cc bdiff-oss-fuzz.o fuzzutil-oss-fuzz.o
28 28 $(CXX) $(CXXFLAGS) -std=c++17 -I../../mercurial bdiff.cc \
29 29 bdiff-oss-fuzz.o fuzzutil-oss-fuzz.o -lFuzzingEngine -o \
30 30 $$OUT/bdiff_fuzzer
31 31
32 32 mpatch.o: ../../mercurial/mpatch.c
33 33 $(CC) -g -O1 -fsanitize=fuzzer-no-link,address -c -o mpatch.o \
34 34 ../../mercurial/mpatch.c
35 35
36 36 mpatch: CXXFLAGS += -std=c++17
37 37 mpatch: mpatch.cc mpatch.o fuzzutil.o
38 38 $(CXX) $(CXXFLAGS) -DHG_FUZZER_INCLUDE_MAIN=1 -g -O1 -fsanitize=fuzzer-no-link,address \
39 39 -I../../mercurial mpatch.cc mpatch.o fuzzutil.o -o mpatch
40 40
41 41 mpatch-oss-fuzz.o: ../../mercurial/mpatch.c
42 42 $(CC) $(CFLAGS) -c -o mpatch-oss-fuzz.o ../../mercurial/mpatch.c
43 43
44 44 mpatch_fuzzer: mpatch.cc mpatch-oss-fuzz.o fuzzutil-oss-fuzz.o
45 45 $(CXX) $(CXXFLAGS) -std=c++17 -I../../mercurial mpatch.cc \
46 46 mpatch-oss-fuzz.o fuzzutil-oss-fuzz.o -lFuzzingEngine -o \
47 47 $$OUT/mpatch_fuzzer
48 48
49 49 mpatch_corpus.zip:
50 50 python mpatch_corpus.py $$OUT/mpatch_fuzzer_seed_corpus.zip
51 51
52 52 x%.o: ../../mercurial/thirdparty/xdiff/x%.c ../../mercurial/thirdparty/xdiff/*.h
53 53 $(CC) -g -O1 -fsanitize=fuzzer-no-link,address -c \
54 54 -o $@ \
55 55 $<
56 56
57 57 xdiff: CXXFLAGS += -std=c++17
58 58 xdiff: xdiff.cc xdiffi.o xprepare.o xutils.o fuzzutil.o
59 59 $(CXX) $(CXXFLAGS) -DHG_FUZZER_INCLUDE_MAIN=1 -g -O1 -fsanitize=fuzzer-no-link,address \
60 60 -I../../mercurial xdiff.cc \
61 61 xdiffi.o xprepare.o xutils.o fuzzutil.o -o xdiff
62 62
63 63 fuzz-x%.o: ../../mercurial/thirdparty/xdiff/x%.c ../../mercurial/thirdparty/xdiff/*.h
64 64 $(CC) $(CFLAGS) -c \
65 65 -o $@ \
66 66 $<
67 67
68 68 xdiff_fuzzer: xdiff.cc fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o fuzzutil-oss-fuzz.o
69 69 $(CXX) $(CXXFLAGS) -std=c++17 -I../../mercurial xdiff.cc \
70 70 fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o fuzzutil-oss-fuzz.o \
71 71 -lFuzzingEngine -o $$OUT/xdiff_fuzzer
72 72
73 73 # TODO use the $OUT env var instead of hardcoding /out
74 74 /out/sanpy/bin/python:
75 cd /Python-2.7.15/ && ./configure --without-pymalloc --prefix=$$OUT/sanpy CFLAGS='-O1 -fno-omit-frame-pointer -g -fwrapv -fstack-protector-strong' LDFLAGS=-lasan && ASAN_OPTIONS=detect_leaks=0 make && make install
75 cd /Python-2.7.15/ && ./configure --without-pymalloc --prefix=$$OUT/sanpy CFLAGS="$(CFLAGS)" LDFLAGS=$$PYLDFLAGS && ASAN_OPTIONS=detect_leaks=0 make && make install
76 76
77 77 sanpy: /out/sanpy/bin/python
78 78
79 79 manifest.o: sanpy ../../mercurial/cext/manifest.c
80 80 $(CC) $(CFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \
81 81 -I../../mercurial \
82 82 -c -o manifest.o ../../mercurial/cext/manifest.c
83 83
84 84 charencode.o: sanpy ../../mercurial/cext/charencode.c
85 85 $(CC) $(CFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \
86 86 -I../../mercurial \
87 87 -c -o charencode.o ../../mercurial/cext/charencode.c
88 88
89 89 parsers.o: sanpy ../../mercurial/cext/parsers.c
90 90 $(CC) $(CFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \
91 91 -I../../mercurial \
92 92 -c -o parsers.o ../../mercurial/cext/parsers.c
93 93
94 94 dirs.o: sanpy ../../mercurial/cext/dirs.c
95 95 $(CC) $(CFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \
96 96 -I../../mercurial \
97 97 -c -o dirs.o ../../mercurial/cext/dirs.c
98 98
99 99 pathencode.o: sanpy ../../mercurial/cext/pathencode.c
100 100 $(CC) $(CFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \
101 101 -I../../mercurial \
102 102 -c -o pathencode.o ../../mercurial/cext/pathencode.c
103 103
104 104 revlog.o: sanpy ../../mercurial/cext/revlog.c
105 105 $(CC) $(CFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \
106 106 -I../../mercurial \
107 107 -c -o revlog.o ../../mercurial/cext/revlog.c
108 108
109 109 manifest_fuzzer: sanpy manifest.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o
110 110 $(CXX) $(CXXFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \
111 111 -Wno-register -Wno-macro-redefined \
112 112 -I../../mercurial manifest.cc \
113 113 manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o \
114 114 -lFuzzingEngine `$$OUT/sanpy/bin/python-config --ldflags` \
115 115 -o $$OUT/manifest_fuzzer
116 116
117 117 manifest_corpus.zip:
118 118 python manifest_corpus.py $$OUT/manifest_fuzzer_seed_corpus.zip
119 119
120 120 clean:
121 121 $(RM) *.o *_fuzzer \
122 122 bdiff \
123 123 mpatch \
124 124 xdiff
125 125
126 126 oss-fuzz: bdiff_fuzzer mpatch_fuzzer mpatch_corpus.zip xdiff_fuzzer manifest_fuzzer manifest_corpus.zip
127 127
128 128 .PHONY: all clean oss-fuzz sanpy
General Comments 0
You need to be logged in to leave comments. Login now