summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathaniel Brough <[email protected]>2022-12-28 20:37:12 +0000
committerNathaniel Brough <[email protected]>2022-12-28 21:07:29 +0000
commit1dcffc655d8b42a850c8cd16cdf66caab1c9549d (patch)
treeabd34a83b267b5fe3c181f1e154fa21de4063fa7
parent549bee94add9d8f1c346bfa0fa6b25481db3f191 (diff)
fix(fuzz): Make sanitizer flags optional
Currently OSS fuzz expects to have complete control over the sanitizer flags. As we currently have these set it's causing problems with the OSS fuzz build. Instead we should use the provided variables from the OSS fuzz build environment. For local testing we'll create a set a well defined defaults.
-rw-r--r--.github/workflows/pre-commit.yml2
-rw-r--r--test/fuzz/make.mk16
2 files changed, 12 insertions, 6 deletions
diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml
index 8a1101ac0..d2150d13f 100644
--- a/.github/workflows/pre-commit.yml
+++ b/.github/workflows/pre-commit.yml
@@ -38,6 +38,8 @@ jobs:
- name: Build Fuzzer
run: |
+ export CC=clang
+ export CXX=clang++
fuzz_harness=$(ls -d test/fuzz/device/*/)
for h in $fuzz_harness
do
diff --git a/test/fuzz/make.mk b/test/fuzz/make.mk
index 03254112f..6717ebc80 100644
--- a/test/fuzz/make.mk
+++ b/test/fuzz/make.mk
@@ -16,9 +16,9 @@ __check_defined = \
#-------------- Fuzz harness compiler ------------
-CC = clang
-CXX = clang++
-GDB = gdb
+CC ?= clang
+CXX ?= clang++
+GDB ?= gdb
OBJCOPY = objcopy
SIZE = size
MKDIR = mkdir
@@ -34,6 +34,13 @@ else
PYTHON = python3
endif
+#-------------- Fuzz harness flags ------------
+COVERAGE_FLAGS ?= -fsanitize-coverage=trace-pc-guard
+SANITIZER_FLAGS ?= -fsanitize=fuzzer \
+ -fsanitize=address
+
+CFLAGS += $(COVERAGE_FLAGS) $(SANITIZER_FLAGS)
+
#-------------- Source files and compiler flags --------------
@@ -42,9 +49,6 @@ INC += $(TOP)/test
# Compiler Flags
CFLAGS += \
-ggdb \
- -fsanitize=fuzzer \
- -fsanitize=address \
- -fsanitize=undefined \
-fdata-sections \
-ffunction-sections \
-fno-strict-aliasing \