Makefile
1 ############################################################################### 2 # Configuration Options 3 ############################################################################### 4 5 CC = clang 6 7 FIELD_ELEMENTS_PER_BLOB ?= 4096 8 9 CFLAGS += -I../inc 10 CFLAGS += -Wall -Wextra -Werror -O0 11 CFLAGS += -DFIELD_ELEMENTS_PER_BLOB=$(FIELD_ELEMENTS_PER_BLOB) 12 CFLAGS += -g -fsanitize=fuzzer 13 14 BLST = -L../lib -lblst 15 LIBBLST = ../lib/libblst.a 16 17 # Default to no threads, to use all cores specify -1. 18 THREADS ?= 0 19 ifeq ($(THREADS), -1) 20 override THREADS = $(shell nproc --all) 21 endif 22 23 # On macOS, you need to use clang from the llvm package. 24 ifneq ($(OS),Windows_NT) 25 UNAME_S := $(shell uname -s) 26 ifeq ($(UNAME_S),Darwin) 27 ENV_OPTS += PATH=$(shell brew --prefix llvm)/bin:$(PATH) 28 endif 29 endif 30 31 ############################################################################### 32 # Helper targets 33 ############################################################################### 34 35 .PHONY: targets 36 targets: 37 @echo Available targets: 38 @# List targets | filter fuzz targets | remove deps | add prefix 39 @make -qp | grep "^fuzz_" | sed 's/:.*//' | sed 's/^/ - /' | sort | uniq 40 41 $(LIBBLST): 42 @echo [+] Building blst 43 @make -C../src blst 44 45 .PRECIOUS: %/corpus 46 %/corpus: 47 @echo [+] Generating corpus 48 @cd gen_corpus && go run . 49 50 .PRECIOUS: %/fuzz 51 %/fuzz: %/fuzz.c ../src/c_kzg_4844.c %/corpus $(LIBBLST) 52 @echo [+] Compiling $* fuzzer 53 @$(ENV_OPTS) $(CC) $(CFLAGS) -o $@ $< $(BLST) 54 55 .PHONY: run_fuzz_% 56 run_fuzz_%: %/fuzz 57 @echo [+] Starting $* fuzzer 58 @-./$< \ 59 -artifact_prefix=./$*/ \ 60 -workers=$(THREADS) \ 61 -jobs=$(THREADS) \ 62 -max_len=$(LEN) \ 63 ./$*/corpus 64 65 ############################################################################### 66 # Fuzzing targets 67 ############################################################################### 68 69 # Length is (4096 * 32). 70 fuzz_blob_to_kzg_commitment: LEN=131072 71 fuzz_blob_to_kzg_commitment: run_fuzz_blob_to_kzg_commitment 72 73 # Length is (4096 * 32) + 32. 74 fuzz_compute_kzg_proof: LEN=131104 75 fuzz_compute_kzg_proof: run_fuzz_compute_kzg_proof 76 77 # Length is (4096 * 32) + 48. 78 fuzz_compute_blob_kzg_proof: LEN=131120 79 fuzz_compute_blob_kzg_proof: run_fuzz_compute_blob_kzg_proof 80 81 # Length is 48 + 32 + 32 + 48. 82 fuzz_verify_kzg_proof: LEN=160 83 fuzz_verify_kzg_proof: run_fuzz_verify_kzg_proof 84 85 # Length is (4096 * 32) + 48 + 48. 86 fuzz_verify_blob_kzg_proof: LEN=131168 87 fuzz_verify_blob_kzg_proof: run_fuzz_verify_blob_kzg_proof 88 89 # Length is (3 * 4096 * 32) + (3 * 48) + (3 * 48). 90 fuzz_verify_blob_kzg_proof_batch: LEN=393504 91 fuzz_verify_blob_kzg_proof_batch: run_fuzz_verify_blob_kzg_proof_batch