forked from 0xMiden/miden-vm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
273 lines (214 loc) · 10.3 KB
/
Makefile
File metadata and controls
273 lines (214 loc) · 10.3 KB
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# -------------------------------------------------------------------------------------------------
# Makefile
# -------------------------------------------------------------------------------------------------
.DEFAULT_GOAL := help
# -- help -----------------------------------------------------------------------------------------
.PHONY: help
help:
@printf "\nTargets:\n\n"
@awk 'BEGIN {FS = ":.*##"; OFS = ""} /^[a-zA-Z0-9_.-]+:.*?##/ { printf " \033[36m%-24s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
@printf "\nCrate Testing:\n"
@printf " make test-air # Test air crate\n"
@printf " make test-assembly # Test assembly crate\n"
@printf " make test-assembly-syntax # Test assembly-syntax crate\n"
@printf " make test-core # Test core crate\n"
@printf " make test-vm # Test miden-vm crate\n"
@printf " make test-processor # Test processor crate\n"
@printf " make test-prover # Test prover crate\n"
@printf " make test-core-lib # Test core-lib crate\n"
@printf " make test-verifier # Test verifier crate\n"
@printf "\nExamples:\n"
@printf " make test-air test=\"some_test\" # Test specific function\n"
@printf " make test-fast # Fast tests (no proptests/CLI)\n"
@printf " make test-skip-proptests # All tests except proptests\n"
@printf " make check-features # Check all feature combinations with cargo-hack\n\n"
# -- environment toggles --------------------------------------------------------------------------
BACKTRACE := RUST_BACKTRACE=1
WARNINGS := RUSTDOCFLAGS="-D warnings"
BUILDDOCS := MIDEN_BUILD_LIB_DOCS=1
# -- feature configuration ------------------------------------------------------------------------
ALL_FEATURES := --all-features
# Workspace-wide test features
WORKSPACE_TEST_FEATURES := concurrent,testing,executable
FAST_TEST_FEATURES := concurrent,testing
# Feature sets for executable builds
FEATURES_CONCURRENT_EXEC := --features concurrent,executable
FEATURES_METAL_EXEC := --features concurrent,executable,tracing-forest
FEATURES_LOG_TREE := --features concurrent,executable,tracing-forest
# Per-crate default features
FEATURES_air := testing
FEATURES_assembly := testing
FEATURES_assembly-syntax := testing,serde
FEATURES_core :=
FEATURES_vm := concurrent,executable,internal
FEATURES_processor := concurrent,testing,bus-debugger
FEATURES_prover := concurrent
FEATURES_core-lib :=
FEATURES_verifier :=
# -- linting --------------------------------------------------------------------------------------
.PHONY: clippy
clippy: ## Runs Clippy with configs
cargo +nightly clippy --workspace --all-targets ${ALL_FEATURES} -- -D warnings
.PHONY: fix
fix: ## Runs Fix with configs
cargo +nightly fix --allow-staged --allow-dirty --all-targets ${ALL_FEATURES}
.PHONY: format
format: ## Runs Format using nightly toolchain
cargo +nightly fmt --all
.PHONY: format-check
format-check: ## Runs Format using nightly toolchain but only in check mode
cargo +nightly fmt --all --check
.PHONY: lint
lint: format fix clippy ## Runs all linting tasks at once (Clippy, fixing, formatting)
# --- docs ----------------------------------------------------------------------------------------
.PHONY: doc
doc: ## Generates & checks documentation
$(WARNINGS) $(BUILDDOCS) cargo doc ${ALL_FEATURES} --keep-going --release
.PHONY: serve-docs
serve-docs: ## Serves the docs
mkdir -p docs/external && cd docs/external && npm run start:dev
# -- core knobs (overridable from CLI or by caller targets) --------------------
# Advanced usage (most users should use pattern rules like 'make test-air'):
# make core-test CRATE=miden-air FEATURES=testing
# make core-test CARGO_PROFILE=test-dev FEATURES=testing
# make core-test CRATE=miden-processor FEATURES=testing EXPR="-E 'not test(#*proptest)'"
NEXTEST_PROFILE ?= default
CARGO_PROFILE ?= test-dev
CRATE ?=
FEATURES ?=
# Filter expression/selector passed through to nextest, e.g.:
# -E 'not test(#*proptest)' or 'my::module::test_name'
EXPR ?=
# Extra args to nextest (e.g., --no-run)
EXTRA ?=
define _CARGO_NEXTEST
$(BACKTRACE) cargo nextest run \
--profile $(NEXTEST_PROFILE) \
--cargo-profile $(CARGO_PROFILE) \
$(if $(FEATURES),--features $(FEATURES),) \
$(if $(CRATE),-p $(CRATE),) \
$(EXTRA) $(EXPR)
endef
.PHONY: core-test core-test-build
## Core: run tests with overridable CRATE/FEATURES/PROFILES/EXPR/EXTRA
core-test:
$(BUILDDOCS) $(_CARGO_NEXTEST)
## Core: build test binaries only (no run)
core-test-build:
$(MAKE) core-test EXTRA="--no-run"
# -- pattern rule: `make test-<crate> [test=...]` ------------------------------
# Primary method for testing individual crates (automatically uses correct features):
# make test-air # Test air crate with default features
# make test-processor # Test processor crate with default features
# make test-air test="'my::mod::some_test'" # Test specific function in air crate
.PHONY: test-%
test-%: ## Tests a specific crate; accepts 'test=' to pass a selector or nextest expr
$(MAKE) core-test \
CRATE=miden-$* \
FEATURES=$(FEATURES_$*) \
EXPR=$(if $(test),$(test),)
# -- workspace-wide tests -------------------------------------------------------------------------
.PHONY: test-build
test-build: ## Build the test binaries for the workspace (no run)
$(MAKE) core-test-build NEXTEST_PROFILE=ci FEATURES="$(WORKSPACE_TEST_FEATURES)"
.PHONY: test
test: ## Run all tests for the workspace
$(MAKE) core-test NEXTEST_PROFILE=ci FEATURES="$(WORKSPACE_TEST_FEATURES)"
.PHONY: test-docs
test-docs: ## Run documentation tests (cargo test - nextest doesn't support doctests)
$(BUILDDOCS) cargo test --doc $(ALL_FEATURES)
# -- filtered test runs ---------------------------------------------------------------------------
.PHONY: test-fast
test-fast: ## Runs fast tests (excludes all CLI tests and proptests)
$(MAKE) core-test \
FEATURES="$(FAST_TEST_FEATURES)" \
EXPR="-E 'not test(#*proptest) and not test(cli_)'"
.PHONY: test-skip-proptests
test-skip-proptests: ## Runs all tests, except property-based tests
$(MAKE) core-test \
FEATURES="$(WORKSPACE_TEST_FEATURES)" \
EXPR="-E 'not test(#*proptest)'"
.PHONY: test-loom
test-loom: ## Runs all loom-based tests
RUSTFLAGS="--cfg loom" $(MAKE) core-test \
CRATE=miden-utils-sync \
FEATURES= \
EXPR="-E 'test(#*loom)'"
# --- checking ------------------------------------------------------------------------------------
.PHONY: check
check: ## Checks all targets and features for errors without code generation
$(BUILDDOCS) cargo check --all-targets ${ALL_FEATURES}
.PHONY: check-features
check-features: ## Checks all feature combinations compile without warnings using cargo-hack
@scripts/check-features.sh
# --- building ------------------------------------------------------------------------------------
.PHONY: build
build: ## Builds with default parameters
$(BUILDDOCS) cargo build --release --features concurrent
.PHONY: build-no-std
build-no-std: ## Builds without the standard library
$(BUILDDOCS) cargo build --no-default-features --target wasm32-unknown-unknown --workspace
# --- executable ----------------------------------------------------------------------------------
.PHONY: exec
exec: ## Builds an executable with optimized profile and features
cargo build --profile optimized $(FEATURES_CONCURRENT_EXEC)
.PHONY: exec-single
exec-single: ## Builds a single-threaded executable
cargo build --profile optimized --features executable
.PHONY: exec-avx2
exec-avx2: ## Builds an executable with AVX2 acceleration enabled
RUSTFLAGS="-C target-feature=+avx2" cargo build --profile optimized $(FEATURES_CONCURRENT_EXEC)
.PHONY: exec-sve
exec-sve: ## Builds an executable with SVE acceleration enabled
RUSTFLAGS="-C target-feature=+sve" cargo build --profile optimized $(FEATURES_CONCURRENT_EXEC)
.PHONY: exec-info
exec-info: ## Builds an executable with log tree enabled
cargo build --profile optimized $(FEATURES_LOG_TREE)
# --- examples ------------------------------------------------------------------------------------
.PHONY: run-examples
run-examples: exec ## Runs all masm examples to verify they execute correctly
@echo "Running masm examples..."
@failed=0; \
for masm in miden-vm/masm-examples/*/*.masm miden-vm/masm-examples/*/*/*.masm; do \
[ -f "$$masm" ] || continue; \
echo " $$masm"; \
if ! ./target/optimized/miden-vm run "$$masm" > /dev/null 2>&1; then \
echo " FAILED: $$masm"; \
failed=1; \
fi; \
done; \
if [ $$failed -eq 1 ]; then \
echo "Some examples failed!"; \
exit 1; \
fi; \
echo "All examples passed."
# --- benchmarking --------------------------------------------------------------------------------
.PHONY: check-bench
check-bench: ## Builds all benchmarks
cargo check --benches --features internal
.PHONY: bench
bench: ## Runs benchmarks
cargo bench --profile optimized --features internal
# ============================================================
# Fuzzing targets
# ============================================================
.PHONY: fuzz-mast-forest
fuzz-mast-forest: ## Run fuzzing for MastForest deserialization
-@cargo +nightly fuzz run mast_forest_deserialize --release --fuzz-dir miden-core-fuzz
.PHONY: fuzz-mast-validate
fuzz-mast-validate: ## Run fuzzing for UntrustedMastForest validation
-@cargo +nightly fuzz run mast_forest_validate --release --fuzz-dir miden-core-fuzz
.PHONY: fuzz-all
fuzz-all: ## Run all fuzz targets (in sequence)
-@cargo +nightly fuzz run mast_forest_deserialize --release --fuzz-dir miden-core-fuzz -- -max_total_time=300
-@cargo +nightly fuzz run mast_forest_validate --release --fuzz-dir miden-core-fuzz -- -max_total_time=300
.PHONY: fuzz-list
fuzz-list: ## List available fuzz targets
cargo +nightly fuzz list --fuzz-dir miden-core-fuzz
.PHONY: fuzz-coverage
fuzz-coverage: ## Generate coverage report for fuzz targets
cargo +nightly fuzz coverage mast_forest_deserialize --fuzz-dir miden-core-fuzz
cargo +nightly fuzz coverage mast_forest_validate --fuzz-dir miden-core-fuzz
.PHONY: fuzz-seeds
fuzz-seeds: ## Generate seed corpus files for fuzzing
cargo test -p miden-core generate_fuzz_seeds -- --ignored --nocapture