-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
57 lines (48 loc) · 1.33 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
CFLAGS = -fPIC -g -pedantic -Wextra
LDFLAGS = -shared -pthread
DEBUG = -g -D=DEBUG
LDPRELOAD = LD_PRELOAD=./libqueuemydata.so
TEST = sync; cat counters.log debug.log
BIN = libqueuemydata.so
SRC = src/queuemydata.c
.PHONY: all
all: shared-debug
.PHONY: shared-debug
shared-debug:
gcc -o $(BIN) $(SRC) $(CFLAGS) $(LDFLAGS) $(DEBUG)
shared:
gcc -o $(BIN) $(SRC) $(CFLAGS) $(LDFLAGS)
.PHONY: clean
clean:
rm libqueuemydata.so counters.log debug.log
.PHONY: test
test: shared-debug
$(LDPRELOAD) $(TEST)
.PHONY: fmt
fmt:
clang-format-11 -i src/queuemydata.c
.PHONY: test-valgrind
test-valgrind: all
$(LDPRELOAD) valgrind \
--leak-check=full \
--track-origins=yes \
--exit-on-first-error=yes \
--show-leak-kinds=all \
$(TEST)
.PHONY: test-asan
test-asan:
clang -O1 $(CFLAGS) \
-fsanitize=address \
-shared-libasan \
-fno-omit-frame-pointer \
-fno-optimize-sibling-calls \
$(SRC) $(LDFLAGS) -o $(BIN)
LD_PRELOAD="/usr/lib/llvm-14/lib/clang/14.0.6/lib/linux/libclang_rt.asan-x86_64.so ./libqueuemydata.so" $(TEST)
.PHONY: test-leak
test-leak:
clang -O1 $(CFLAGS) \
-fsanitize=leak \
-fno-omit-frame-pointer \
-fno-optimize-sibling-calls \
$(SRC) $(LDFLAGS) -o $(BIN)
ASAN_OPTIONS=detect_leaks=1 $(LDPRELOAD) $(TEST)