Skip to content

Commit

Permalink
[CMAKE] Make LOG_BEFORE_THROW explicit (#16914)
Browse files Browse the repository at this point in the history
This PR introduces an explicit option about log_fatal_before_throw.
  • Loading branch information
tqchen authored Apr 22, 2024
1 parent 29534b7 commit b0143d1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -155,16 +156,20 @@ 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)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
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")
Expand Down
1 change: 1 addition & 0 deletions cmake/modules/LibInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
9 changes: 7 additions & 2 deletions src/support/libinfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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},
Expand Down

0 comments on commit b0143d1

Please sign in to comment.