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: #
# - SDL 2.0 #
# - libGL #
# - Vulkan headers #
# #
# Optional dependencies: #
# - CURL #
@ -18,11 +19,22 @@
# Platforms: #
# - FreeBSD #
# - Linux #
# - NetBSD #
# - OpenBSD #
# - OS X #
# - 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
# -------------------------
@ -117,6 +129,11 @@ ifdef ASAN
DEBUG=1
endif
# UBSAN includes DEBUG
ifdef UBSAN
DEBUG=1
endif
# ----------
# Base CFLAGS. These may be overridden by the environment.
@ -127,6 +144,9 @@ CFLAGS ?= -O0 -g -Wall -pipe
ifdef ASAN
CFLAGS += -fsanitize=address
endif
ifdef UBSAN
CFLAGS += -fsanitize=undefined
endif
else
CFLAGS ?= -O2 -Wall -pipe -fomit-frame-pointer
endif
@ -288,6 +308,11 @@ ifdef ASAN
LDFLAGS += -fsanitize=address
endif
# Link undefined behavior sanitizer if requested.
ifdef UBSAN
LDFLAGS += -fsanitize=undefined
endif
# Required libraries.
ifeq ($(YQ2_OSTYPE),Linux)
override LDFLAGS += -lm -ldl -rdynamic