Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(796)

Side by Side Diff: src/trusted/validator_ragel/Makefile

Issue 9348082: Move unreviewed files to unreviewed subdirectory (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/trusted/validator_ragel/decoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2012 The Native Client Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 # A temporary Makefile to build the DFA-based validator, decoder, tests. This
6 # will likely go away as soon we integrate with the NaCl build system(s).
7
8 OUT = out
9 OUT_DIRS = $(OUT)/build/objs \
10 $(OUT)/tarballs \
11 $(OUT)/timestamps \
12 $(OUT)/test
13 OBJD=$(OUT)/build/objs
14
15 PYTHON2X=/usr/bin/python2.6
16 CC = gcc -std=gnu99 -Wdeclaration-after-statement -Wall -pedantic -Wextra \
17 -Wno-long-long -Wswitch-enum -Wsign-compare -Wno-variadic-macros -Werror \
18 -O3 -finline-limit=10000
19 CXX = g++ -std=c++0x -O3 -finline-limit=10000
20 RAGEL = ragel
21 CFLAGS = -g
22 CXXFLAGS = -g
23 LDFLAGS = -g
24 INST_DEFS = general-purpose-instructions.def \
25 system-instructions.def \
26 x87-instructions.def \
27 mmx-instructions.def \
28 xmm-instructions.def
29
30 FAST_TMP_FOR_TEST=/dev/shm
31
32 # Default rule.
33 all: outdirs $(OBJD)/decoder-test $(OBJD)/validator-test
34
35 # Create all prerequisite directories.
36 .PHONY: outdirs
37 outdirs: | $(OUT_DIRS)
38 $(OUT_DIRS):
39 install -m 755 -d $@
40
41 # Pattern rules.
42 $(OBJD)/%.o: $(OBJD)/%.c
43 $(CC) $(CFLAGS) -I. -I$(OBJD) -c $< -o $@
44
45 $(OBJD)/%.c: %.rl
46 $(RAGEL) -G2 -I$(OBJD) $< -o $@
47
48 # Decoder, validator, etc.
49 $(OBJD)/decoder-test: \
50 $(OBJD)/decoder-x86_32.o $(OBJD)/decoder-x86_64.o $(OBJD)/decoder-test.o
51 $(OBJD)/validator-test: \
52 $(OBJD)/validator-x86_32.o $(OBJD)/validator-x86_64.o $(OBJD)/validator-test .o
53
54 GEN_DECODER=$(OBJD)/gen-decoder
55 $(GEN_DECODER): gen-decoder.C
56 $(CXX) $(CXXFLAGS) $< -o $(GEN_DECODER)
57
58 $(OBJD)/decoder-x86_32.c: $(OBJD)/decoder-x86_32-instruction-consts.c
59 $(OBJD)/decoder-x86_32.c: $(OBJD)/decoder-x86_32-instruction.rl
60 $(OBJD)/decoder-x86_32-instruction-consts.c \
61 $(OBJD)/decoder-x86_32-instruction.rl: $(GEN_DECODER) $(INST_DEFS)
62 $(GEN_DECODER) -o $(OBJD)/decoder-x86_32-instruction.rl $(INST_DEFS) \
63 -d check_access,opcode,parse_operands_states,mark_data_fields
64
65 $(OBJD)/decoder-x86_64.c: $(OBJD)/decoder-x86_64-instruction-consts.c
66 $(OBJD)/decoder-x86_64.c: $(OBJD)/decoder-x86_64-instruction.rl
67 $(OBJD)/decoder-x86_64-instruction-consts.c \
68 $(OBJD)/decoder-x86_64-instruction.rl: $(GEN_DECODER) $(INST_DEFS)
69 $(GEN_DECODER) -o $(OBJD)/decoder-x86_64-instruction.rl $(INST_DEFS) \
70 -d check_access,opcode,parse_operands_states,mark_data_fields \
71 -m amd64
72
73 $(OBJD)/validator-x86_32.c: $(OBJD)/validator-x86_32-instruction.rl
74 $(OBJD)/validator-x86_32-instruction-consts.c \
75 $(OBJD)/validator-x86_32-instruction.rl: $(GEN_DECODER) $(INST_DEFS)
76 $(GEN_DECODER) -o $(OBJD)/validator-x86_32-instruction.rl $(INST_DEFS) \
77 -d check_access,opcode,parse_operands,parse_operands_states \
78 -d instruction_name,mark_data_fields,nacl-forbidden \
79 -d imm_operand_action,rel_operand_action nops.def
80
81 $(OBJD)/validator-x86_64.c: $(OBJD)/validator-x86_64-instruction-consts.c
82 $(OBJD)/validator-x86_64.c: $(OBJD)/validator-x86_64-instruction.rl
83 $(OBJD)/validator-x86_64-instruction-consts.c \
84 $(OBJD)/validator-x86_64-instruction.rl: $(GEN_DECODER) $(INST_DEFS)
85 $(GEN_DECODER) -o $(OBJD)/validator-x86_64-instruction.rl $(INST_DEFS) \
86 -d opcode,instruction_name,mark_data_fields,rel_operand_action \
87 -d nacl-forbidden nops.def -m amd64
88
89 # Facilities for testing:
90 # one-instruction.dot: the description of the DFA that accepts all instruction
91 # the decoder is able to decode.
92 # decoder-test-x86-64: the decoder that follows the objdump format
93 $(OBJD)/one-instruction-x86_32.dot: one-instruction-x86_32.rl \
94 $(OBJD)/one-valid-instruction-x86_32-consts.c \
95 $(OBJD)/one-valid-instruction-x86_32.rl
96 $(RAGEL) -V -I$(OBJD) $< -o $@
97
98 $(OBJD)/one-instruction-x86_64.dot: one-instruction-x86_64.rl \
99 $(OBJD)/one-valid-instruction-x86_64-consts.c \
100 $(OBJD)/one-valid-instruction-x86_64.rl
101 $(RAGEL) -V -I$(OBJD) $< -o $@
102
103 $(OBJD)/one-valid-instruction-x86_32-consts.c \
104 $(OBJD)/one-valid-instruction-x86_32.rl: $(GEN_DECODER) $(INST_DEFS)
105 $(GEN_DECODER) -o $(OBJD)/one-valid-instruction-x86_32.rl $(INST_DEFS) \
106 -d check_access,rex_prefix,vex_prefix,opcode,parse_operands \
107 -d parse_operands_states
108
109 $(OBJD)/one-valid-instruction-x86_64-consts.c \
110 $(OBJD)/one-valid-instruction-x86_64.rl: $(GEN_DECODER) $(INST_DEFS)
111 $(GEN_DECODER) -o $(OBJD)/one-valid-instruction-x86_64.rl $(INST_DEFS) \
112 -d check_access,rex_prefix,vex_prefix,opcode,parse_operands \
113 -d parse_operands_states -m amd64
114
115 $(OBJD)/decoder-test.o: decoder-test.c
116 $(CC) $(CFLAGS) -c $< -o $@
117
118 $(OBJD)/validator-test.o: validator-test.c
119 $(CC) $(CFLAGS) -c $< -o $@
120
121 $(OBJD)/validator-x86_64.o: $(OBJD)/validator-x86_64.c
122 if [ -e nacl_irt_x86_32.nexe ] && [-e nacl_irt_x86_64.nexe ]; then \
123 $(CC) $(CFLAGS) -I. -I$(OBJD) -fprofile-generate -c $< -o $@-pf && \
124 $(CC) $(CFLAGS) -I. -I$(OBJD) -fprofile-generate -c \
125 $(OBJD)/validator-x86_64.c -o $(OBJD)/validator-x86_64.o-pf && \
126 $(CC) $(CFLAGS) -fprofile-generate $@-pf \
127 $(OBJD)/validator-x86_64.o-pf validator-test.c \
128 -o $(OBJD)/ncval_train && \
129 $(OBJD)/ncval_train nacl_irt_x86_32.nexe && \
130 $(OBJD)/ncval_train nacl_irt_x86_64.nexe && \
131 rm validator-test.gcda && \
132 $(CC) $(CFLAGS) -I. -I$(OBJD) -fprofile-use -c $< -o $@ && \
133 $(CC) $(CFLAGS) -I. -I$(OBJD) -fprofile-use -c \
134 $(OBJD)/validator-x86_64.c -o $(OBJD)/validator-x86_64.o ; \
135 else \
136 $(CC) $(CFLAGS) -I. -I$(OBJD) -c $< -o $@ ; \
137 fi
138
139 # To test the decoder compare its output with output from objdump. This
140 # allows to match instruction opcode, length and operands.
141 #
142 # Disassemblers in different versions of binutils produce slightly different
143 # output. Do not take binutils as installed on the system, instead download and
144 # build it.
145 #
146 # Original source is located here:
147 # BINUTILS_URL_BASE = http://ftp.gnu.org/gnu/binutils
148 BINUTILS_URL_BASE = http://commondatastorage.googleapis.com/nativeclient-mirror/ toolchain/binutils
149 BINUTILS_VER = binutils-2.22
150 BINUTILS_TARBALL = $(OUT)/tarballs/$(BINUTILS_VER).tar.bz2
151 BINUTILS_BUILD_DIR = $(OUT)/build/build-$(BINUTILS_VER)
152 BINUTILS_STAMP = $(OUT)/timestamps/binutils
153 OBJDUMP = $(BINUTILS_BUILD_DIR)/binutils/objdump
154 GAS = $(BINUTILS_BUILD_DIR)/gas/as-new
155
156 $(BINUTILS_TARBALL): | $(OUT_DIRS)
157 rm -f $(BINUTILS_TARBALL)
158 cd $(OUT)/tarballs && wget $(BINUTILS_URL_BASE)/$(BINUTILS_VER).tar.bz2
159
160 $(BINUTILS_STAMP): $(BINUTILS_TARBALL) | $(OUT_DIRS)
161 rm -rf $(OUT)/build/$(BINUTILS_VER)
162 cd $(OUT)/build && \
163 tar jxf $(CURDIR)/$(OUT)/tarballs/$(BINUTILS_VER).tar.bz2
164 rm -rf $(BINUTILS_BUILD_DIR)
165 mkdir -p $(BINUTILS_BUILD_DIR)
166 cd $(BINUTILS_BUILD_DIR) && \
167 $(CURDIR)/$(OUT)/build/$(BINUTILS_VER)/configure
168 $(MAKE) -C $(BINUTILS_BUILD_DIR)
169 touch $@
170
171 .PHONY: binutils
172 binutils: $(BINUTILS_STAMP)
173
174 # Clean all build artifacts except the binutils' binaries.
175 .PHONY: clean
176 clean:
177 rm -rf "$(OBJD)" "$(OUT)"/test \
178 "$(FAST_TMP_FOR_TEST)"/_test_dfa_insts*
179
180 # Clean everything not including the downloaded tarballs.
181 .PHONY: clean-all
182 clean-all: clean
183 rm -rf "$(OUT)"/timestamps "$(OUT)"/build
184
185 # Clean side effects created while running tests.
186 .PHONY: clean-tests
187 clean-tests:
188 rm -rf "$(OUT)"/test "$(FAST_TMP_FOR_TEST)"/_test_dfa_insts*
189 rm -f dfa_ncval
190
191 # The target for all short-running tests.
192 .PHONY: check
193 check: check-irt check-as-alt-validator
194
195 # Checks that the IRT is not rejected by the validator.
196 .PHONY: check-irt
197 check-irt: outdirs $(OBJD)/validator-test
198 $(OBJD)/validator-test nacl_irt_x86_64.nexe
199
200 .PHONY: check-as-alt-validator
201 check-as-alt-validator: $(OBJD)/validator-test
202 ln -sfn $(OBJD)/validator-test dfa_ncval
203 $(PYTHON2X) validator_test.py
204 rm -f dfa_ncval
205
206 # Checks that all byte sequences accepted by the DFA are decoded identically to
207 # the objdump. A long-running test.
208 .PHONY: check-decoder
209 check-decoder: outdirs $(BINUTILS_STAMP) $(OBJD)/one-instruction-x86_32.dot \
210 $(OBJD)/one-instruction-x86_64.dot $(OBJD)/decoder-test
211 $(PYTHON2X) parse_dfa.py <"$(OBJD)/one-instruction-x86_32.dot" \
212 > "$(OUT)/test/test_dfa_transitions-x86_32.c"
213 $(CC) $(CFLAGS) -c test_dfa.c -o "$(OUT)/test/test_dfa.o"
214 $(CC) $(CFLAGS) -O0 -I. -c "$(OUT)/test/test_dfa_transitions-x86_32.c" \
215 -o "$(OUT)/test/test_dfa_transitions-x86_32.o"
216 $(CC) $(LDFLAGS) "$(OUT)/test/test_dfa.o" \
217 "$(OUT)/test/test_dfa_transitions-x86_32.o" \
218 -o $(OUT)/test/test_dfa-x86_32
219 $(PYTHON2X) run_objdump_test.py \
220 --gas="$(GAS) --32" \
221 --objdump="$(OBJDUMP)" \
222 --decoder="$(OBJD)/decoder-test" \
223 --tester=./decoder_test_one_file.sh \
224 --nthreads=`cat /proc/cpuinfo | grep processor | wc -l` -- \
225 "$(OUT)/test/test_dfa-x86_32" "$(FAST_TMP_FOR_TEST)"
226 $(PYTHON2X) parse_dfa.py <"$(OBJD)/one-instruction-x86_64.dot" \
227 > "$(OUT)/test/test_dfa_transitions-x86_64.c"
228 $(CC) $(CFLAGS) -O0 -I. -c "$(OUT)/test/test_dfa_transitions-x86_64.c" \
229 -o "$(OUT)/test/test_dfa_transitions-x86_64.o"
230 $(CC) $(LDFLAGS) "$(OUT)/test/test_dfa.o" \
231 "$(OUT)/test/test_dfa_transitions-x86_64.o" \
232 -o $(OUT)/test/test_dfa-x86_64
233 $(PYTHON2X) run_objdump_test.py \
234 --gas="$(GAS) --64" \
235 --objdump="$(OBJDUMP)" \
236 --decoder="$(OBJD)/decoder-test" \
237 --tester=./decoder_test_one_file.sh \
238 --nthreads=`cat /proc/cpuinfo | grep processor | wc -l` -- \
239 "$(OUT)/test/test_dfa-x86_64" "$(FAST_TMP_FOR_TEST)"
OLDNEW
« no previous file with comments | « no previous file | src/trusted/validator_ragel/decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698