Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Add STL checks via -D_GLIBCXX_ASSERTIONS in debug mode (#14896)
Browse files Browse the repository at this point in the history
* Add STL checks via -D_GLIBCXX_ASSERTIONS in debug mode

* Also add to Makefile

* Fix warning (fpermissive) sleep definition not available
  • Loading branch information
larroy authored and szha committed May 21, 2019
1 parent 2cc822a commit 789a6be
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,11 @@ else(MSVC)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_ASSERTIONS")
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
add_definitions(-DNDEBUG=1)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_ASSERTIONS")
else()
add_definitions(-DNDEBUG=1)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
Expand All @@ -159,7 +161,7 @@ else(MSVC)
elseif(SUPPORT_MSSE2)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
endif()
set(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}")
if(SUPPORT_CXX14)
add_definitions(-DDMLC_USE_CXX11=1)
add_definitions(-DDMLC_USE_CXX14=1)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ endif

# CFLAGS for debug
ifeq ($(DEBUG), 1)
CFLAGS += -g -O0
CFLAGS += -g -O0 -D_GLIBCXX_ASSERTIONS
else
CFLAGS += -O3 -DNDEBUG=1
endif
Expand Down
1 change: 1 addition & 0 deletions src/operator/random/shuffle_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <vector>
#include <cstring>
#ifdef USE_GNU_PARALLEL_SHUFFLE
#include <unistd.h>
#include <parallel/algorithm>
#endif
#include "../elemwise_op_common.h"
Expand Down

0 comments on commit 789a6be

Please sign in to comment.