From 02a15aeffb5710e5283d85f6e067b053473a6a0a Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Tue, 20 Apr 2021 23:32:01 +0000 Subject: [PATCH] chore: Add clang sanizer boilerplate --- runtime/Makefile | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/runtime/Makefile b/runtime/Makefile index 52ba746..2d24542 100644 --- a/runtime/Makefile +++ b/runtime/Makefile @@ -6,7 +6,7 @@ endif endif TOTAL_CORES := $(shell getconf _NPROCESSORS_CONF) -PAGE_SIZE=$(shell getconf PAGESIZE) +PAGE_SIZE := $(shell getconf PAGESIZE) # Compiler Settings CC=clang @@ -15,16 +15,36 @@ CC_OPTIONS = -O3 -flto -g -pthread -D_GNU_SOURCE # CC_OPTIONS for Debugging # CC_OPTIONS = -O0 -g -pthread -D_GNU_SOURCE +# CFI Sanitizer +# CC_OPTIONS = -O0 -g -pthread -D_GNU_SOURCE -flto -fvisibility=default -fsanitize=cfi + +# Undefined Sanitizer +# CC_OPTIONS = -O0 -g -pthread -D_GNU_SOURCE -fsanitize=undefined,float-divide-by-zero,unsigned-integer-overflow,implicit-conversion,local-bounds + +# Clang SafeStack +# This actually seems to "solve" the segfaults +# https://clang.llvm.org/docs/SafeStack.html +# CC_OPTIONS = -O0 -g -pthread -D_GNU_SOURCE -fsanitize=safe-stack + +# Memory Sanitizer +# https://clang.llvm.org/docs/MemorySanitizer.html +# https://github.com/google/sanitizers/wiki/MemorySanitizer +# CC_OPTIONS = -O0 -g -pthread -D_GNU_SOURCE -fsanitize=memory -fno-omit-frame-pointer + +# Address Sanitizer +# https://clang.llvm.org/docs/AddressSanitizer.html +# CC_OPTIONS = -O0 -g -pthread -D_GNU_SOURCE -fsanitize=address -fno-omit-frame-pointer + BINARY_NAME=sledgert # Feature Toggles -CFLAGS += -DADMISSIONS_CONTROL +# CFLAGS += -DADMISSIONS_CONTROL # Debugging Flags # Strips out calls to assert() and disables debuglog -CFLAGS += -DNDEBUG +# CFLAGS += -DNDEBUG # Redirects debuglogs to /runtime/bin/sledge.log # CFLAGS += -DLOG_TO_FILE