-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathMakefile
More file actions
104 lines (80 loc) · 3.72 KB
/
Makefile
File metadata and controls
104 lines (80 loc) · 3.72 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
# Base flags for fuzzing instrumentation
RUSTFLAGS_BASE:=
RUSTFLAGS_BASE+=-g
RUSTFLAGS_BASE+=-Cpasses=sancov-module
RUSTFLAGS_BASE+=-Cllvm-args=-sanitizer-coverage-level=4
RUSTFLAGS_BASE+=-Cllvm-args=-sanitizer-coverage-pc-table
RUSTFLAGS_BASE+=-Clink-dead-code
RUSTFLAGS_BASE+=-Cforce-frame-pointers=yes
RUSTFLAGS_BASE+=-Ctarget-feature=-crt-static
# 8-bit counter mode
RUSTFLAGS_8BIT:=$(RUSTFLAGS_BASE)
RUSTFLAGS_8BIT+=-Cllvm-args=-sanitizer-coverage-inline-8bit-counters
# PC guard mode
RUSTFLAGS_PCGUARD:=$(RUSTFLAGS_BASE)
RUSTFLAGS_PCGUARD+=-Cllvm-args=-sanitizer-coverage-trace-pc-guard
# Honggfuzz mode: PC guards with all trace features
# https://github.com/rust-fuzz/honggfuzz-rs/blob/master/src/bin/cargo-hfuzz.rs
# Note: indirect-calls is enabled via level=4 in RUSTFLAGS_BASE
RUSTFLAGS_HFUZZ:=$(RUSTFLAGS_PCGUARD)
RUSTFLAGS_HFUZZ+=-Cllvm-args=-sanitizer-coverage-trace-compares
RUSTFLAGS_HFUZZ+=-Cllvm-args=-sanitizer-coverage-trace-divs
RUSTFLAGS_HFUZZ+=-Cllvm-args=-sanitizer-coverage-trace-geps
RUSTFLAGS_HFUZZ+=-Cllvm-args=-sanitizer-coverage-stack-depth
RUSTFLAGS:=$(RUSTFLAGS_8BIT)
ifeq ($(ENABLE_COVERAGE),1)
RUSTFLAGS+=-Cinstrument-coverage
$(info "Coverage enabled")
endif
CC:=clang
CARGO?=cargo
.PHONY: build clean binaries shared_obj shared_obj_hfuzz shared_obj_pcguard
all: | shared_obj binaries
# Alias for backwards compatibility
build: | shared_obj
conformance: | shared_obj_debug
shared_obj:
RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) build --target x86_64-unknown-linux-gnu --release --lib
shared_obj_hfuzz:
RUSTFLAGS="$(RUSTFLAGS_HFUZZ)" $(CARGO) build --target x86_64-unknown-linux-gnu --profile release-with-debug --lib --target-dir target/hfuzz
shared_obj_pcguard:
RUSTFLAGS="$(RUSTFLAGS_PCGUARD)" $(CARGO) build --target x86_64-unknown-linux-gnu --release --lib --target-dir target/pcguard
shared_obj_cov:
@# Build the coverage SO with Rust nightly to get a newer LLVM.
@# Stable 1.86 ships LLVM 19 whose llvm-cov chokes on large Rust
@# binaries ("function name is empty"). Nightly ships LLVM 22+
@# which fixes that bug. Only the +cov.so is built with nightly;
@# the regular and hfuzz builds remain on the pinned stable channel.
RUSTFLAGS="$(RUSTFLAGS) -Cinstrument-coverage" $(CARGO) +nightly build --target x86_64-unknown-linux-gnu --release \
--lib --target-dir target/cov
# to avoid conflicts when uploading as GH artifact
cp target/cov/x86_64-unknown-linux-gnu/release/libsolfuzz_agave.so target/x86_64-unknown-linux-gnu/release/libsolfuzz_agave+cov.so
shared_obj_debug:
$(CARGO) build --lib
shared_obj_core_bpf:
./scripts/fetch_program.sh $(PROGRAM)
CARGO=$(CARGO) ./scripts/build_core_bpf.sh $(PROGRAM)
shared_obj_bpf_conformance:
RUSTFLAGS="$(RUSTFLAGS)" BPF_PROGRAM_ID=$(BPF_PROGRAM_ID) BPF_TARGET=$(BPF_TARGET) FORCE_RECOMPILE=true $(CARGO) build \
--target x86_64-unknown-linux-gnu \
--features bpf-program-conformance \
--lib \
--release \
--target-dir target/bpf-conformance
mv target/bpf-conformance/x86_64-unknown-linux-gnu/release/libsolfuzz_agave.so target/bpf-conformance/$(OUTPUT_TARGET_NAME)
shared_obj_bpf_conformance_debug:
BPF_PROGRAM_ID=$(BPF_PROGRAM_ID) BPF_TARGET=$(BPF_TARGET) FORCE_RECOMPILE=true $(CARGO) build \
--target x86_64-unknown-linux-gnu \
--features bpf-program-conformance \
--lib \
--target-dir target/bpf-conformance
mv target/bpf-conformance/x86_64-unknown-linux-gnu/debug/libsolfuzz_agave.so target/bpf-conformance/$(OUTPUT_TARGET_NAME)
binaries:
$(CARGO) build --bins --release
tests/self_test: tests/self_test.c
$(CC) -o $@ $< -Werror=all -pedantic -ldl -fsanitize=address,fuzzer-no-link -fsanitize-coverage=inline-8bit-counters
test:
$(CARGO) check --release
$(CARGO) test --release
clean:
$(CARGO) clean