-
Notifications
You must be signed in to change notification settings - Fork 42
/
Makefile
130 lines (99 loc) · 4.07 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
125
126
127
128
129
130
NIMC=Nim/bin/nim
NLVMC=nlvm/nlvm
NLVMR=nlvm/nlvmr
LLVMPATH=../ext
#NIMFLAGS=--opt:speed --gc:markandsweep
#NIMFLAGS=-d:release
NIMFLAGS=--debuginfo --linedir:on --cc=clang
NLVMFLAGS= --debuginfo --linedir:on --cc=clang
LLVM_MAJ:=$(shell cat llvm/llvm.version | cut -f1 -d.)
LLVM_MIN:=$(shell cat llvm/llvm.version | cut -f2 -d.)
LLVM_PAT:=$(shell cat llvm/llvm.version | cut -f3 -d.)
LLVM_DIR=llvm-$(LLVM_MAJ).$(LLVM_MIN).$(LLVM_PAT).src
ifdef STATIC_LLVM
NLVMCFLAGS=-d:staticLLVM --dynliboverrideall
LLVM_DEP=ext/$(LLVM_DIR)/sta/bin/llvm-config
export PATH := $(PWD)/ext/$(LLVM_DIR)/sta/bin:$(PATH)
else
LLVM_DEP=ext/$(LLVM_DIR)/sha/lib/libLLVM.so.$(LLVM_MAJ).$(LLVM_MIN)
NLVMCFLAGS?=
endif
.PHONY: all
all: $(NLVMC)
Nim/koch:
cd Nim ;\
[ -d csources_v2 ] || git clone -q --depth 1 -b master https://github.com/nim-lang/csources_v2.git ;\
cd csources_v2 ;\
git pull ;\
$(MAKE) -f makefile
cd Nim ; bin/nim c koch
$(NIMC): Nim/koch Nim/compiler/*.nim
cd Nim && ./koch boot -d:release
$(NLVMC): $(LLVM_DEP) $(NIMC) Nim/compiler/*.nim nlvm/*.nim llvm/*.nim nlvm-lib/*.nim
cd nlvm && time ../$(NIMC) $(NIMFLAGS) $(NLVMCFLAGS) c nlvm
$(NLVMR): $(LLVM_DEP) $(NIMC) Nim/compiler/*.nim nlvm/*.nim llvm/*.nim nlvm-lib/*.nim
cd nlvm && time ../$(NIMC) $(NIMFLAGS) -d:release $(NLVMCFLAGS) -o:nlvmr c nlvm
nlvm/nlvm.ll: $(NLVMC) nlvm/*.nim llvm/*.nim nlvm-lib/*.nim
cd nlvm && time ./nlvm $(NLVMFLAGS) -o:nlvm.ll $(NLVMCFLAGS) -c c nlvm
nlvm/nlvm.self: $(NLVMC)
cd nlvm && time ./nlvm -o:nlvm.self $(NLVMFLAGS) $(NLVMCFLAGS) c nlvm
nlvm/nlvmr.self: $(NLVMR)
cd nlvm && time ./nlvmr -o:nlvmr.self -d:release $(NLVMFLAGS) $(NLVMCFLAGS) c nlvm
nlvm/nlvm.self.ll: nlvm/nlvm.self
cd nlvm && time ./nlvm.self -c $(NLVMFLAGS) $(NLVMCFLAGS) -o:nlvm.self.ll c nlvm
.PHONY: compare
compare: nlvm/nlvm.self.ll nlvm/nlvm.ll
diff -u nlvm/nlvm.self.ll nlvm/nlvm.ll
Nim/testament/testament: $(NIMC) Nim/testament/*.nim
$(NIMC) -d:release c Nim/testament/testament
.PHONY: run-testament run-testament-noskip
run-testament: $(NLVMR) Nim/testament/testament
cd Nim; time testament/testament --megatest:off --targets:c "--nim:../nlvm/nlvmr" --skipFrom:../skipped-tests.txt all
run-testament-noskip: $(NLVMR) Nim/testament/testament
-cd Nim; time testament/testament --megatest:off --targets:c "--nim:../nlvm/nlvmr" all
.PHONY: test
test: run-testament
-make stats
update-skipped: run-testament-noskip
# Output suitable for sticking into skipped-tests.txt
-jq -r -s '([.[][]|select(.result != "reSuccess" and .result != "reDisabled")]) | .[].name' Nim/testresults/*json | sort | uniq > skipped-tests.txt
make stats
.PHONY: badeggs.json
badeggs.json:
-jq -s '[.[][]|select(.result != "reSuccess" and .result != "reDisabled" and .result != "reCodeNotFound")]' Nim/testresults/*.json > badeggs.json
.PHONY: stats
stats: badeggs.json
-jq 'group_by(.category)|.[]|((unique_by(.category)|.[].category) + " " + (length| tostring))' badeggs.json
-jq -s '. | flatten | group_by(.result) | map({(first.result): (length)}) | add' Nim/testresults/*json
-jq -s '{bad: ([.[][]|select(.result != "reSuccess" and .result != "reDisabled")]) | length, ok: ([.[][]|select(.result == "reSuccess")]|length)}' Nim/testresults/*json
.PHONY: t2
t2:
cp -r Nim/testresults tr2
.PHONY: self
self: nlvm/nlvm.self
.PHONY: clean
clean:
rm -rf $(NLVMC) $(NLVMR) nlvm/nlvm.ll nlvm/nlvm.self.ll nlvm/nlvm.self Nim/testresults/
ext/$(LLVM_DIR)/sha/lib/libLLVM.so.$(LLVM_MAJ).$(LLVM_MIN):
sh ./make-llvm.sh $(LLVM_MAJ) $(LLVM_MIN) $(LLVM_PAT) sha \
-DLLVM_BUILD_LLVM_DYLIB=1 \
-DLLVM_LINK_LLVM_DYLIB=1 \
-DLLVM_ENABLE_ASSERTIONS=1 \
-DLLVM_INCLUDE_TESTS=Off \
-DLLVM_INCLUDE_BENCHMARKS=Off \
-DCMAKE_BUILD_TYPE=RelWithDebInfo
ext/$(LLVM_DIR)/sta/bin/llvm-config:
sh ./make-llvm.sh $(LLVM_MAJ) $(LLVM_MIN) $(LLVM_PAT) sta \
-DLLVM_BUILD_LLVM_DYLIB=0 \
-DLLVM_LINK_LLVM_DYLIB=0 \
-DLLVM_ENABLE_ASSERTIONS=0 \
-DLLVM_INCLUDE_TESTS=Off \
-DLLVM_INCLUDE_BENCHMARKS=Off \
-DCMAKE_BUILD_TYPE=Release
.PHONY: prepare-llvm
prepare-llvm: $(LLVM_DEP)
.PHONY: prepare-nim
prepare-nim: $(NIMC)
.PHONY: docker
docker:
docker build . -t nlvm --no-cache