add debug_asan config
This commit is contained in:
parent
bd8f5e7f01
commit
f78837ca8a
3
.gitignore
vendored
3
.gitignore
vendored
@ -4,9 +4,8 @@
|
||||
*.10x
|
||||
*.cap
|
||||
*.tracy
|
||||
*.pdb
|
||||
.vs/*
|
||||
|
||||
# Unused
|
||||
unused/
|
||||
|
||||
# Build / output directories
|
||||
|
||||
@ -3,12 +3,13 @@ project(powerplay)
|
||||
|
||||
# Options below are laid out so that running cmake with all "OFF" results in the "release" / "user" build
|
||||
|
||||
option(RTC "Should the build compile with runtime checks enabled (asserts, asan, etc.) - REQUIRES CRTLIB ON" OFF)
|
||||
option(CRTLIB "Should the build link with the CRTLIB" OFF)
|
||||
option(DEBINFO "Should the build compile with debug info" OFF)
|
||||
option(DEVELOPER "Should the build compile with developer mode enabled" OFF)
|
||||
option(PROFILING "Should the build compile with profiling enabled - REQUIRES CRTLIB ON" OFF)
|
||||
option(UNOPTIMIZED "Should the build compile with optimization disabled" OFF)
|
||||
option(RTC "Should the build compile with runtime checks enabled (asserts, asan, etc.) - REQUIRES CRTLIB ON" OFF)
|
||||
option(ASAN "Should the build compile with the address sanitizer enabled (asserts, asan, etc.) - REQUIRES CRTLIB ON" OFF)
|
||||
option(CRTLIB "Should the build link with the CRTLIB" OFF)
|
||||
option(DEBINFO "Should the build compile with debug info" OFF)
|
||||
option(DEVELOPER "Should the build compile with developer mode enabled" OFF)
|
||||
option(PROFILING "Should the build compile with profiling enabled - REQUIRES CRTLIB ON" OFF)
|
||||
option(UNOPTIMIZED "Should the build compile with optimization disabled" OFF)
|
||||
|
||||
################################################################################
|
||||
# Source files
|
||||
@ -136,11 +137,6 @@ target_precompile_headers(powerplay_exe PRIVATE src/common.h)
|
||||
# Compiler flags
|
||||
################################################################################
|
||||
|
||||
# TODO:
|
||||
# Enable -
|
||||
# -Wconversion \
|
||||
# -Wno-sign-conversion \
|
||||
|
||||
# Common flags
|
||||
set(COMPILER_FLAGS "
|
||||
-fno-strict-aliasing \
|
||||
@ -149,21 +145,27 @@ set(COMPILER_FLAGS "
|
||||
-msse4.2 \
|
||||
")
|
||||
|
||||
# TODO:
|
||||
# Enable -
|
||||
# -Wconversion \
|
||||
# -Wno-sign-conversion \
|
||||
|
||||
set(COMPILER_WARNINGS " \
|
||||
-Weverything -Werror \
|
||||
-Wno-unused-macros -Wno-gnu-zero-variadic-macro-arguments -Wno-documentation \
|
||||
-Wno-old-style-cast -Wno-reserved-identifier -Wno-reserved-macro-identifier \
|
||||
-Wno-old-style-cast \
|
||||
-Wno-conversion -Wno-sign-conversion -Wno-declaration-after-statement -Wno-extra-semi \
|
||||
-Wno-extra-semi-stmt -Wno-bad-function-cast -Wno-class-varargs \
|
||||
-Wno-unreachable-code-break -Wno-cast-align -Wno-float-equal \
|
||||
-Wno-zero-as-null-pointer-constant -Wno-cast-qual -Wno-missing-noreturn \
|
||||
-Wno-missing-field-initializers -Wno-missing-braces -Wno-initializer-overrides \
|
||||
-Wno-c99-extensions -Wno-c++98-compat-pedantic -Wno-c++98-compat \
|
||||
-Wno-switch-enum -Wno-unsafe-buffer-usage \
|
||||
-Wno-switch-enum -Wno-switch-default \
|
||||
-Wno-reserved-identifier -Wno-reserved-macro-identifier \
|
||||
-Wno-unsafe-buffer-usage \
|
||||
")
|
||||
# -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-parameter
|
||||
|
||||
|
||||
set(LINKER_FLAGS " \
|
||||
-fuse-ld=lld-link \
|
||||
${rc_res_sources} \
|
||||
@ -175,12 +177,11 @@ if (RTC)
|
||||
if (NOT CRTLIB)
|
||||
message(FATAL_ERROR "CRTLIB (C runtime library) Must be enabled when compiling with RTC (runtime checks)")
|
||||
endif()
|
||||
# NOTE: Adress sanitizer is disabled for now because for some reason it's screwing up viewing local variables while debugging.
|
||||
set(COMPILER_FLAGS "${COMPILER_FLAGS} -DRTC=1")
|
||||
set(COMPILER_FLAGS "${COMPILER_FLAGS} -fsanitize=undefined -fsanitize-trap=undefined -DRTC=1")
|
||||
# Enable UBSan
|
||||
set(COMPILER_FLAGS "${COMPILER_FLAGS} -fsanitize=undefined -fsanitize-trap=all -DRTC=1")
|
||||
set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=undefined -fsanitize-trap=all")
|
||||
# set(COMPILER_FLAGS "${COMPILER_FLAGS} -fsanitize=undefined -DRTC=1")
|
||||
# set(COMPILER_FLAGS "${COMPILER_FLAGS} -fsanitize=address -fsanitize=undefined -DRTC=1")
|
||||
# set(COMPILER_FLAGS "${COMPILER_FLAGS} -fsanitize=address -fsanitize=undefined -fno-sanitize=alignment -DRTC=1")
|
||||
# set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=undefined")
|
||||
endif()
|
||||
|
||||
# CRTLIB (C runtime library)
|
||||
@ -206,8 +207,17 @@ if (DEBINFO)
|
||||
set(LINKER_FLAGS "${LINKER_FLAGS} -g")
|
||||
endif()
|
||||
|
||||
# ASAN
|
||||
if (ASAN)
|
||||
set(COMPILER_FLAGS "${COMPILER_FLAGS} -fsanitize=address -DASAN=1")
|
||||
set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=address")
|
||||
endif()
|
||||
|
||||
# Developer mode
|
||||
if(DEVELOPER)
|
||||
if (NOT CRTLIB)
|
||||
message(FATAL_ERROR "CRTLIB (C runtime library) Must be enabled when compiling with ASAN")
|
||||
endif()
|
||||
set(COMPILER_FLAGS "${COMPILER_FLAGS} -DDEVELOPER=1")
|
||||
endif()
|
||||
|
||||
|
||||
37
build.bat
37
build.bat
@ -5,13 +5,15 @@ setlocal
|
||||
::
|
||||
:: - Configuration
|
||||
:: 1. debug: The target is intended to run in a debugger
|
||||
:: 2. debug_asan: The target is intended to run in a debugger with address sanitization enabled
|
||||
:: 3. profiling: The target is compiled with optimizations, debug info, and profiler timing info
|
||||
:: 2. release: The target is compiled with optimizations and no debug info
|
||||
:: 4. release: The target is compiled with optimizations and no debug info
|
||||
::
|
||||
:: - Platform
|
||||
:: 1. developer: The target will include all developer tooling
|
||||
:: 2. user: The target will not include any developer tooling
|
||||
|
||||
echo ---------------
|
||||
where /q cmake || (
|
||||
echo ERROR: "cmake" not found - please install it and add the executable to your path
|
||||
exit /b 1
|
||||
@ -21,20 +23,34 @@ where /q clang.exe || (
|
||||
echo ERROR: "clang.exe" not found - please run this from the MSVC x64 native tools command prompt.
|
||||
exit /b 1
|
||||
)
|
||||
clang -v
|
||||
echo ---------------
|
||||
|
||||
if "%Platform%" neq "x64" (
|
||||
echo ERROR: Platform is not "x64" - please run this from the MSVC x64 native tools command prompt.
|
||||
exit /b 1
|
||||
where /q lld-link || (
|
||||
echo ERROR: "lld-link.exe" not found - please run this from the MSVC x64 native tools command prompt.
|
||||
exit /b 1
|
||||
)
|
||||
echo lld-link version:
|
||||
lld-link --version
|
||||
echo ---------------
|
||||
|
||||
where /q ninja.exe || (
|
||||
echo ERROR: "ninja.exe" not found - please run this from the MSVC x64 native tools command prompt.
|
||||
exit /b 1
|
||||
)
|
||||
echo ninja version:
|
||||
ninja --version
|
||||
echo ---------------
|
||||
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
:: Configuration
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
set config_default=-DRTC=0 -DCRTLIB=0 -DDEBINFO=0 -DDEVELOPER=0 -DPROFILING=0 -DUNOPTIMIZED=0
|
||||
set config_default=-DRTC=0 -DASAN=0 -DCRTLIB=0 -DDEBINFO=0 -DDEVELOPER=0 -DPROFILING=0 -DUNOPTIMIZED=0
|
||||
|
||||
:: Arg1 -> compiler options mappings
|
||||
set config1_debug=-DRTC=1 -DCRTLIB=1 -DDEBINFO=1 -DUNOPTIMIZED=1
|
||||
set config1_debug_asan=%config1_debug% -DASAN=1
|
||||
set config1_profiling=-DPROFILING=1 -DCRTLIB=1 -DDEBINFO=1
|
||||
set config1_release=
|
||||
|
||||
@ -51,10 +67,12 @@ set argerror=false
|
||||
:: Check arg 1
|
||||
set arg_config=%1%
|
||||
if /I "%arg_config%" neq "debug" (
|
||||
if /I "%arg_config%" neq "profiling" (
|
||||
if /I "%arg_config%" neq "release" (
|
||||
echo ERROR: must specify either 'debug', 'release', or 'profiling' as first argument
|
||||
set argerror=true
|
||||
if /I "%arg_config%" neq "debug_asan" (
|
||||
if /I "%arg_config%" neq "profiling" (
|
||||
if /I "%arg_config%" neq "release" (
|
||||
echo ERROR: must specify either 'debug', 'debug_asan', 'profiling', or 'release' as first argument
|
||||
set argerror=true
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -79,6 +97,7 @@ if %argerror% neq false (
|
||||
|
||||
set opt_config1=
|
||||
if "%arg_config%" equ "debug" set opt_config1=%config1_debug%
|
||||
if "%arg_config%" equ "debug_asan" set opt_config1=%config1_debug_asan%
|
||||
if "%arg_config%" equ "profiling" set opt_config1=%config1_profiling%
|
||||
if "%arg_config%" equ "release" set opt_config1=%config1_release%
|
||||
|
||||
|
||||
26
src/common.h
26
src/common.h
@ -40,6 +40,10 @@ extern "C" {
|
||||
# define RTC 0
|
||||
#endif
|
||||
|
||||
#ifndef ASAN
|
||||
# define ASAN 0
|
||||
#endif
|
||||
|
||||
#ifndef CRTLIB
|
||||
# define CRTLIB 0
|
||||
#endif
|
||||
@ -126,10 +130,17 @@ extern "C" {
|
||||
#define DEBUGBREAK __builtin_debugtrap()
|
||||
#define DEBUGBREAKABLE { volatile i32 __DEBUGBREAKABLE_VAR = 0; (UNUSED) __DEBUGBREAKABLE_VAR; }
|
||||
|
||||
#else
|
||||
|
||||
#define ASSERT(cond) (void)(0)
|
||||
#define DEBUGBREAK
|
||||
|
||||
#endif
|
||||
|
||||
/* Address sanitization */
|
||||
#if 0
|
||||
void __asan_poison_memory_region(void *, size_t);
|
||||
void __asan_unpoison_memory_region(void *, size_t);
|
||||
#if ASAN
|
||||
void __asan_poison_memory_region(void *, size_t);
|
||||
void __asan_unpoison_memory_region(void *, size_t);
|
||||
# define ASAN_POISON(addr, size) __asan_poison_memory_region(addr, size);
|
||||
# define ASAN_UNPOISON(addr, size) __asan_unpoison_memory_region(addr, size);
|
||||
#else
|
||||
@ -137,15 +148,6 @@ extern "C" {
|
||||
# define ASAN_UNPOISON(addr, size)
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define ASSERT(cond) (void)(0)
|
||||
#define DEBUGBREAK
|
||||
#define ASAN_POISON(addr, size)
|
||||
#define ASAN_UNPOISON(addr, size)
|
||||
|
||||
#endif
|
||||
|
||||
/* ========================== *
|
||||
* Common macros
|
||||
* ========================== */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user