Skip to content

Commit b0143d1

Browse files
authored
[CMAKE] Make LOG_BEFORE_THROW explicit (#16914)
This PR introduces an explicit option about log_fatal_before_throw.
1 parent 29534b7 commit b0143d1

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ tvm_option(USE_PROFILER "Build profiler for the VM and graph executor" ON)
6464
tvm_option(USE_OPENMP "Build with OpenMP thread pool implementation" OFF)
6565
tvm_option(USE_RELAY_DEBUG "Building Relay in debug mode..." OFF)
6666
tvm_option(TVM_DEBUG_WITH_ABI_CHANGE "Enable debug code that may cause ABI changes" OFF)
67+
tvm_option(TVM_LOG_BEFORE_THROW "Whether log before throw, for debugging purposes" OFF)
6768
tvm_option(USE_RTTI "Build with RTTI" ON)
6869
tvm_option(USE_MSVC_MT "Build with MT" OFF)
6970
tvm_option(USE_MICRO "Build with Micro TVM support" OFF)
@@ -155,16 +156,20 @@ if(NOT IS_SUBPROJECT AND NOT DEFINED "${CMAKE_EXPORT_COMPILE_COMMANDS}")
155156
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
156157
endif()
157158

159+
if(TVM_LOG_BEFORE_THROW)
160+
# log error before throw as
161+
# when system have issues with stack trace
162+
add_definitions(-DDMLC_LOG_BEFORE_THROW=1)
163+
endif()
164+
158165
# Generic compilation options
159166
if(MSVC)
160167
add_definitions(-DWIN32_LEAN_AND_MEAN)
161168
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
162169
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
163170
add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE)
164171
add_definitions(-DNOMINMAX)
165-
# log error before throw as usually windows
166-
# may have issues with stack trace
167-
add_definitions(-DDMLC_LOG_BEFORE_THROW=1)
172+
168173
# regeneration does not work well with msbuild custom rules.
169174
set(CMAKE_SUPPRESS_REGENERATION ON)
170175
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")

cmake/modules/LibInfo.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ function(add_lib_info src_file)
114114
TVM_INFO_USE_RANDOM="${USE_RANDOM}"
115115
TVM_INFO_USE_RELAY_DEBUG="${USE_RELAY_DEBUG}"
116116
TVM_INFO_TVM_DEBUG_WITH_ABI_CHANGE="${TVM_DEBUG_WITH_ABI_CHANGE}"
117+
TVM_INFO_TVM_LOG_BEFORE_THROW="${TVM_LOG_BEFORE_THROW}"
117118
TVM_INFO_USE_ROCBLAS="${USE_ROCBLAS}"
118119
TVM_INFO_USE_ROCM="${USE_ROCM}"
119120
TVM_INFO_USE_RCCL="${USE_RCCL}"

src/support/libinfo.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,12 @@
131131
#define TVM_INFO_USE_RELAY_DEBUG "NOT-FOUND"
132132
#endif
133133

134-
#ifndef TVM_INFO_TVM_DEBUG_WITH_ABI_CHANGE
135-
#define TVM_INFO_TVM_DEBUG_WITH_ABI_CHANGE "NOT-FOUND"
134+
#ifndef TVM_INFO_DEBUG_WITH_ABI_CHANGE
135+
#define TVM_INFO_DEBUG_WITH_ABI_CHANGE "NOT-FOUND"
136+
#endif
137+
138+
#ifndef TVM_INFO_LOG_BEFORE_THROW
139+
#define TVM_INFO_LOG_BEFORE_THROW "NOT-FOUND"
136140
#endif
137141

138142
#ifndef TVM_INFO_USE_RTTI
@@ -354,6 +358,7 @@ TVM_DLL Map<String, String> GetLibInfo() {
354358
{"USE_RANDOM", TVM_INFO_USE_RANDOM},
355359
{"USE_RELAY_DEBUG", TVM_INFO_USE_RELAY_DEBUG},
356360
{"TVM_DEBUG_WITH_ABI_CHANGE", TVM_INFO_TVM_DEBUG_WITH_ABI_CHANGE},
361+
{"TVM_LOG_BEFORE_THROW", TVM_INFO_TVM_LOG_BEFORE_THROW},
357362
{"USE_ROCBLAS", TVM_INFO_USE_ROCBLAS},
358363
{"USE_ROCM", TVM_INFO_USE_ROCM},
359364
{"USE_RCCL", TVM_INFO_USE_RCCL},

0 commit comments

Comments
 (0)