Add undefined behaviour sanitizer to the Makefile.

While here update some comments and add a comment sections for the
command line variables.
This commit is contained in:
Yamagi 2021-01-10 18:55:42 +01:00
parent a98d533ae1
commit a52402fd3c

View file

@ -10,6 +10,7 @@
# Base dependencies: # # Base dependencies: #
# - SDL 2.0 # # - SDL 2.0 #
# - libGL # # - libGL #
# - Vulkan headers #
# # # #
# Optional dependencies: # # Optional dependencies: #
# - CURL # # - CURL #
@ -18,11 +19,22 @@
# Platforms: # # Platforms: #
# - FreeBSD # # - FreeBSD #
# - Linux # # - Linux #
# - NetBSD #
# - OpenBSD # # - OpenBSD #
# - OS X # # - OS X #
# - Windows (MinGW) # # - Windows (MinGW) #
# ------------------------------------------------------ # # ------------------------------------------------------ #
# Variables
# ---------
# - ASAN: Builds with address sanitizer, includes DEBUG.
# - DEBUG: Builds a debug build, forces -O0 and adds debug symbols.
# - VERBOSE: Prints full compile, linker and misc commands.
# - UBSAN: Builds with undefined behavior sanitizer, includes DEBUG.
# ----------
# User configurable options # User configurable options
# ------------------------- # -------------------------
@ -117,6 +129,11 @@ ifdef ASAN
DEBUG=1 DEBUG=1
endif endif
# UBSAN includes DEBUG
ifdef UBSAN
DEBUG=1
endif
# ---------- # ----------
# Base CFLAGS. These may be overridden by the environment. # Base CFLAGS. These may be overridden by the environment.
@ -127,6 +144,9 @@ CFLAGS ?= -O0 -g -Wall -pipe
ifdef ASAN ifdef ASAN
CFLAGS += -fsanitize=address CFLAGS += -fsanitize=address
endif endif
ifdef UBSAN
CFLAGS += -fsanitize=undefined
endif
else else
CFLAGS ?= -O2 -Wall -pipe -fomit-frame-pointer CFLAGS ?= -O2 -Wall -pipe -fomit-frame-pointer
endif endif
@ -288,6 +308,11 @@ ifdef ASAN
LDFLAGS += -fsanitize=address LDFLAGS += -fsanitize=address
endif endif
# Link undefined behavior sanitizer if requested.
ifdef UBSAN
LDFLAGS += -fsanitize=undefined
endif
# Required libraries. # Required libraries.
ifeq ($(YQ2_OSTYPE),Linux) ifeq ($(YQ2_OSTYPE),Linux)
override LDFLAGS += -lm -ldl -rdynamic override LDFLAGS += -lm -ldl -rdynamic