diff options
author | Jared Van Bortel <jared@nomic.ai> | 2023-12-01 13:18:35 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-01 20:18:35 +0200 |
commit | 511f52c334e37033f9c9de07b98fca4abc9470bd (patch) | |
tree | 86d014fe5d166a9dbd5ef5ca943a9c26e0483811 | |
parent | 03562f3a86d6706eea9f4fc09b532946c191b34e (diff) |
build : enable libstdc++ assertions for debug builds (#4275)
-rw-r--r-- | CMakeLists.txt | 5 | ||||
-rw-r--r-- | Makefile | 4 |
2 files changed, 9 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f35a25d..0639518d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -116,6 +116,11 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) include(CheckCXXCompilerFlag) +# enable libstdc++ assertions for debug builds +if (CMAKE_SYSTEM_NAME MATCHES "Linux") + add_compile_definitions($<$<CONFIG:Debug>:_GLIBCXX_ASSERTIONS>) +endif() + if (NOT MSVC) if (LLAMA_SANITIZE_THREAD) add_compile_options(-fsanitize=thread) @@ -174,6 +174,10 @@ ifdef LLAMA_DEBUG MK_CFLAGS += -O0 -g MK_CXXFLAGS += -O0 -g MK_LDFLAGS += -g + + ifeq ($(UNAME_S),Linux) + MK_CXXFLAGS += -Wp,-D_GLIBCXX_ASSERTIONS + endif else MK_CPPFLAGS += -DNDEBUG endif |