diff --git a/CMakeLists.txt b/CMakeLists.txt index 94b1e4f86fa0..683ce819dbdb 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 6c13a4277789..c4637a0c17f7 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 de21a76beb34..561e495a357d 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 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},