-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
124 lines (91 loc) · 2.78 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
ifeq ($(CXXSTD),)
CXXSTD := c++17
endif
override CXXFLAGS += -Wall -Wextra -std=$(CXXSTD)
override LDFLAGS +=
RM=rm -f
NUM_TRIALS=10
# $(wildcard *.cpp /xxx/xxx/*.cpp): get all .cpp files from the current directory and dir "/xxx/xxx/"
SRCS := $(wildcard objects/*.cpp stdlib/*/*.cpp *.cpp)
# $(patsubst %.cpp,%.o,$(SRCS)): substitute all ".cpp" file name strings to ".o" file name strings
OBJS := $(patsubst %.cpp,%.o,$(SRCS))
# Allows one to enable verbose builds with VERBOSE=1
V := @
ifeq ($(VERBOSE),1)
V :=
endif
all: release
cgoto: CXXFLAGS += -DNEXT_USE_COMPUTED_GOTO
cgoto: release
release: CXXFLAGS += -O3
release: LDFLAGS += -s
release: next
profile: CXXFLAGS += -DNEXT_USE_COMPUTED_GOTO -O2 -g3
profile: next
debug: CXXFLAGS += -g3 -DDEBUG -DGC_USE_STD_ALLOC
debug: next
debug_ins: CXXFLAGS += -DDEBUG_INS
debug_ins: debug
debug_gc: CXXFLAGS += -DDEBUG_GC
debug_gc: debug
debug_gc_stress: CXXFLAGS += -DGC_STRESS
debug_gc_stress: debug
gc_stress: CXXFLAGS += -DGC_STRESS -DGC_USE_STD_ALLOC
gc_stress: profile
debug_all: CXXFLAGS += -DDEBUG_INS -DDEBUG_CODEGEN -DDEBUG_GC_CLEANUP
debug_all: debug
debug_all_verbose: CXXFLAGS += -DDEBUG_GC
debug_all_verbose: debug_all
debug_scanner: CXXFLAGS += -DDEBUG_SCANNER
debug_scanner: debug_all
coverage: clean
$(RM) *.gcda objects/*.gcda stdlib/*/*.gcda
coverage: CXXFLAGS += -fprofile-arcs -ftest-coverage
coverage: LDFLAGS += -lgcov --coverage
coverage: debug
pgo: merge_profraw pgouse
ifeq ($(findstring clang++,$(CXX)),clang++)
clean_pgodata: clean
$(V) rm -f default_*.profraw default.profdata
else
clean_pgodata: clean
$(V) rm -f *.gcda objects/*.gcda stdlib/*/*.gcda
endif
pgobuild: CXXFLAGS+=-fprofile-generate -march=native
pgobuild: LDFLAGS+=-fprofile-generate -flto
ifeq ($(findstring clang++,$(CXX)),clang++)
pgobuild: CXXFLAGS+=-mllvm -vp-counters-per-site=5
endif
pgobuild: | clean_pgodata cgoto
pgorun: | pgobuild benchmark tests
ifeq ($(findstring clang++,$(CXX)),clang++)
merge_profraw: pgorun
$(V) llvm-profdata merge --output=default.profdata default_*.profraw
else
merge_profraw: pgorun
endif
pgouse: merge_profraw
$(V) $(MAKE) clean
$(V) $(MAKE) cgoto CXXFLAGS=-fprofile-use CXXFLAGS+=-march=native LDFLAGS+=-fprofile-use LDFLAGS+=-flto
$(V) $(MAKE) benchmark
tests: release
$(V) ./next tests/orchestrator.n
next: $(OBJS)
$(V) $(CXX) $(OBJS) $(LDFLAGS) -o next
benchmark: release
$(V) python3 util/benchmark.py -n $(NUM_TRIALS) -l next $(suite)
benchmark_baseline: release
$(V) python3 util/benchmark.py --generate-baseline
benchmark_all: release
$(V) python3 util/benchmark.py -n $(NUM_TRIALS) $(suite)
depend: .depend
.depend: $(SRCS)
$(RM) ./.depend
$(CXX) $(CXXFLAGS) -MM $^>>./.depend;
clean:
$(RM) $(OBJS)
distclean: clean
$(RM) *~ .depend
include .depend
%.o: %.cpp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@