This is an automated email from the ASF dual-hosted git repository.
ruihangl pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new b0143d106f [CMAKE] Make LOG_BEFORE_THROW explicit (#16914)
b0143d106f is described below
commit b0143d106f53ed811ec81612b2c88bea988b4323
Author: Tianqi Chen <[email protected]>
AuthorDate: Mon Apr 22 09:34:19 2024 -0400
[CMAKE] Make LOG_BEFORE_THROW explicit (#16914)
This PR introduces an explicit option about log_fatal_before_throw.
---
CMakeLists.txt | 11 ++++++++---
cmake/modules/LibInfo.cmake | 1 +
src/support/libinfo.cc | 9 +++++++--
3 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 94b1e4f86f..683ce819db 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -64,6 +64,7 @@ tvm_option(USE_PROFILER "Build profiler for the VM and graph
executor" ON)
tvm_option(USE_OPENMP "Build with OpenMP thread pool implementation" OFF)
tvm_option(USE_RELAY_DEBUG "Building Relay in debug mode..." OFF)
tvm_option(TVM_DEBUG_WITH_ABI_CHANGE "Enable debug code that may cause ABI
changes" OFF)
+tvm_option(TVM_LOG_BEFORE_THROW "Whether log before throw, for debugging
purposes" OFF)
tvm_option(USE_RTTI "Build with RTTI" ON)
tvm_option(USE_MSVC_MT "Build with MT" OFF)
tvm_option(USE_MICRO "Build with Micro TVM support" OFF)
@@ -155,6 +156,12 @@ if(NOT IS_SUBPROJECT AND NOT DEFINED
"${CMAKE_EXPORT_COMPILE_COMMANDS}")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
endif()
+if(TVM_LOG_BEFORE_THROW)
+ # log error before throw as
+ # when system have issues with stack trace
+ add_definitions(-DDMLC_LOG_BEFORE_THROW=1)
+endif()
+
# Generic compilation options
if(MSVC)
add_definitions(-DWIN32_LEAN_AND_MEAN)
@@ -162,9 +169,7 @@ if(MSVC)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE)
add_definitions(-DNOMINMAX)
- # log error before throw as usually windows
- # may have issues with stack trace
- add_definitions(-DDMLC_LOG_BEFORE_THROW=1)
+
# regeneration does not work well with msbuild custom rules.
set(CMAKE_SUPPRESS_REGENERATION ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
diff --git a/cmake/modules/LibInfo.cmake b/cmake/modules/LibInfo.cmake
index 6c13a42777..c4637a0c17 100644
--- a/cmake/modules/LibInfo.cmake
+++ b/cmake/modules/LibInfo.cmake
@@ -114,6 +114,7 @@ function(add_lib_info src_file)
TVM_INFO_USE_RANDOM="${USE_RANDOM}"
TVM_INFO_USE_RELAY_DEBUG="${USE_RELAY_DEBUG}"
TVM_INFO_TVM_DEBUG_WITH_ABI_CHANGE="${TVM_DEBUG_WITH_ABI_CHANGE}"
+ TVM_INFO_TVM_LOG_BEFORE_THROW="${TVM_LOG_BEFORE_THROW}"
TVM_INFO_USE_ROCBLAS="${USE_ROCBLAS}"
TVM_INFO_USE_ROCM="${USE_ROCM}"
TVM_INFO_USE_RCCL="${USE_RCCL}"
diff --git a/src/support/libinfo.cc b/src/support/libinfo.cc
index de21a76beb..561e495a35 100644
--- a/src/support/libinfo.cc
+++ b/src/support/libinfo.cc
@@ -131,8 +131,12 @@
#define TVM_INFO_USE_RELAY_DEBUG "NOT-FOUND"
#endif
-#ifndef TVM_INFO_TVM_DEBUG_WITH_ABI_CHANGE
-#define TVM_INFO_TVM_DEBUG_WITH_ABI_CHANGE "NOT-FOUND"
+#ifndef TVM_INFO_DEBUG_WITH_ABI_CHANGE
+#define TVM_INFO_DEBUG_WITH_ABI_CHANGE "NOT-FOUND"
+#endif
+
+#ifndef TVM_INFO_LOG_BEFORE_THROW
+#define TVM_INFO_LOG_BEFORE_THROW "NOT-FOUND"
#endif
#ifndef TVM_INFO_USE_RTTI
@@ -354,6 +358,7 @@ TVM_DLL Map<String, String> GetLibInfo() {
{"USE_RANDOM", TVM_INFO_USE_RANDOM},
{"USE_RELAY_DEBUG", TVM_INFO_USE_RELAY_DEBUG},
{"TVM_DEBUG_WITH_ABI_CHANGE", TVM_INFO_TVM_DEBUG_WITH_ABI_CHANGE},
+ {"TVM_LOG_BEFORE_THROW", TVM_INFO_TVM_LOG_BEFORE_THROW},
{"USE_ROCBLAS", TVM_INFO_USE_ROCBLAS},
{"USE_ROCM", TVM_INFO_USE_ROCM},
{"USE_RCCL", TVM_INFO_USE_RCCL},