diff options
| author | Ha Thach <[email protected]> | 2022-12-08 12:18:32 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-12-08 12:18:32 +0700 |
| commit | d4620d99d31b5566248d2f3a182d7c84633601af (patch) | |
| tree | 2d3ac0023cdbf5dae7e5f7df2575d3dbc420abd8 /test/fuzz/make.mk | |
| parent | ab8cfb3d5bbefcc3ff19a086070b0c83581d789d (diff) | |
| parent | c19bffb1d91dd7dad3365fce938b6d6687d4e5b0 (diff) | |
Merge pull request #1716 from silvergasp/master
fuzz: Add support for fuzzing
Diffstat (limited to 'test/fuzz/make.mk')
| -rw-r--r-- | test/fuzz/make.mk | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/test/fuzz/make.mk b/test/fuzz/make.mk new file mode 100644 index 000000000..03254112f --- /dev/null +++ b/test/fuzz/make.mk @@ -0,0 +1,104 @@ +# --------------------------------------- +# Common make definition for all examples +# --------------------------------------- + +# Build directory +BUILD := _build +PROJECT := $(notdir $(CURDIR)) + +# Handy check parameter function +check_defined = \ + $(strip $(foreach 1,$1, \ + $(call __check_defined,$1,$(strip $(value 2))))) +__check_defined = \ + $(if $(value $1),, \ + $(error Undefined make flag: $1$(if $2, ($2)))) + +#-------------- Fuzz harness compiler ------------ + +CC = clang +CXX = clang++ +GDB = gdb +OBJCOPY = objcopy +SIZE = size +MKDIR = mkdir + +ifeq ($(CMDEXE),1) + CP = copy + RM = del + PYTHON = python +else + SED = sed + CP = cp + RM = rm + PYTHON = python3 +endif + +#-------------- Source files and compiler flags -------------- + + +INC += $(TOP)/test + +# Compiler Flags +CFLAGS += \ + -ggdb \ + -fsanitize=fuzzer \ + -fsanitize=address \ + -fsanitize=undefined \ + -fdata-sections \ + -ffunction-sections \ + -fno-strict-aliasing \ + -Wall \ + -Wextra \ + -Werror \ + -Wfatal-errors \ + -Wdouble-promotion \ + -Wstrict-prototypes \ + -Wstrict-overflow \ + -Werror-implicit-function-declaration \ + -Wfloat-equal \ + -Wundef \ + -Wshadow \ + -Wwrite-strings \ + -Wsign-compare \ + -Wmissing-format-attribute \ + -Wunreachable-code \ + -Wcast-align \ + -Wcast-qual \ + -Wnull-dereference \ + -Wuninitialized \ + -Wunused \ + -Wredundant-decls \ + -O1 + +CFLAGS += \ + -Wno-error=unreachable-code \ + -DOPT_MCU_FUZZ=1 \ + -DCFG_TUSB_MCU=OPT_MCU_FUZZ + +CXXFLAGS += \ + -xc++ \ + -Wno-c++11-narrowing \ + -fno-implicit-templates + +# conversion is too strict for most mcu driver, may be disable sign/int/arith-conversion +# -Wconversion + +# Debugging/Optimization +ifeq ($(DEBUG), 1) + CFLAGS += -Og +else + CFLAGS += $(CFLAGS_OPTIMIZED) +endif + +# Log level is mapped to TUSB DEBUG option +ifneq ($(LOG),) + CMAKE_DEFSYM += -DLOG=$(LOG) + CFLAGS += -DCFG_TUSB_DEBUG=$(LOG) +endif + +# Logger: default is uart, can be set to rtt or swo +ifneq ($(LOGGER),) + CMAKE_DEFSYM += -DLOGGER=$(LOGGER) +endif + |
