Skip to content
Snippets Groups Projects
Commit 5e55a29b authored by Vlad Zolotarov's avatar Vlad Zolotarov Committed by Pekka Enberg
Browse files

build.mk: Add -DNDEBUG when mode!=debug


 - Add -DNDEBUG to the compiler flags when mode!=debug.
 - Prevent assert() from compiling out in kernel when mode=release

Signed-off-by: default avatarVlad Zolotarov <vladz@cloudius-systems.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent 6f3a966a
No related branches found
No related tags found
No related merge requests found
...@@ -82,6 +82,11 @@ CFLAGS += -Wno-maybe-uninitialized ...@@ -82,6 +82,11 @@ CFLAGS += -Wno-maybe-uninitialized
CXXFLAGS += -Wno-maybe-uninitialized CXXFLAGS += -Wno-maybe-uninitialized
endif endif
# Add -DNDEBUG if conf-DEBUG_BUILD is set to 0 in *.mak files above
ifeq ($(conf-DEBUG_BUILD),0)
configuration += -DNDEBUG
endif
arch-cflags = -msse4.1 arch-cflags = -msse4.1
......
...@@ -4,3 +4,8 @@ conf-debug_memory=0 ...@@ -4,3 +4,8 @@ conf-debug_memory=0
# debug level logging (enabled automatically in mode=debug) # debug level logging (enabled automatically in mode=debug)
conf-logger_debug=0 conf-logger_debug=0
# Set to 1 in mode=debug.
# This macro controls the NDEBUG macro that is used to identify the debug
# build variant in the code.
conf-DEBUG_BUILD=0
conf-opt = $(gcc-opt-Og) conf-opt = $(gcc-opt-Og)
conf-logger_debug=1 conf-logger_debug=1
conf-DEBUG_BUILD=1
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
#undef assert #undef assert
#ifdef NDEBUG /* We want the assert() not to be compiled out in the kernel */
#if defined NDEBUG && !defined _KERNEL
#define assert(x) (void)0 #define assert(x) (void)0
#else #else
#define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__),0))) #define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__),0)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment