This is an automated email from the ASF dual-hosted git repository.

tqchen 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 d5371954d4 [chore] cleanup unsed legacy backtrac code in logging 
(#18781)
d5371954d4 is described below

commit d5371954d405206dac7a7e01524c21ce32750d65
Author: Tianqi Chen <[email protected]>
AuthorDate: Sun Feb 15 12:57:38 2026 -0500

    [chore] cleanup unsed legacy backtrac code in logging (#18781)
    
    This PR cleans up unused legacy code in logging
---
 .gitmodules                            |   6 -
 3rdparty/cutlass_fpA_intB_gemm         |   2 +-
 3rdparty/dmlc-core                     |   1 -
 3rdparty/rang                          |   1 -
 CMakeLists.txt                         |   1 -
 LICENSE                                |  16 --
 docker/lint.sh                         |   3 -
 include/tvm/runtime/logging.h          |   9 +-
 python/tvm/relax/frontend/nn/extern.py |   4 +-
 src/ir/diagnostic.cc                   |  15 +-
 src/runtime/logging.cc                 | 270 ---------------------------------
 src/runtime/profiling.cc               |   3 +-
 tests/lint/cpplint.sh                  |   5 -
 tests/lint/jnilint.sh                  |   3 -
 tests/scripts/task_lint.sh             |   3 -
 15 files changed, 8 insertions(+), 334 deletions(-)

diff --git a/.gitmodules b/.gitmodules
index 0d87e21cf2..a7cbc9d019 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,9 +1,3 @@
-[submodule "dmlc-core"]
-       path = 3rdparty/dmlc-core
-       url = https://github.com/dmlc/dmlc-core.git
-[submodule "3rdparty/rang"]
-       path = 3rdparty/rang
-       url = https://github.com/agauniyal/rang.git
 [submodule "3rdparty/cutlass"]
        path = 3rdparty/cutlass
        url = https://github.com/NVIDIA/cutlass.git
diff --git a/3rdparty/cutlass_fpA_intB_gemm b/3rdparty/cutlass_fpA_intB_gemm
index 72b9883c98..9033091ecb 160000
--- a/3rdparty/cutlass_fpA_intB_gemm
+++ b/3rdparty/cutlass_fpA_intB_gemm
@@ -1 +1 @@
-Subproject commit 72b9883c986a2ff427ca61ac0b14ad59be1dc862
+Subproject commit 9033091ecb41e7387058147e11a7087d3b363c96
diff --git a/3rdparty/dmlc-core b/3rdparty/dmlc-core
deleted file mode 160000
index 3031e4a61a..0000000000
--- a/3rdparty/dmlc-core
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 3031e4a61a98f49f07a42cfdec6242340fb2fd8c
diff --git a/3rdparty/rang b/3rdparty/rang
deleted file mode 160000
index cabe04d6d6..0000000000
--- a/3rdparty/rang
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit cabe04d6d6b05356fa8f9741704924788f0dd762
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4143774c63..913baca1b5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -73,7 +73,6 @@ tvm_option(USE_ALTERNATIVE_LINKER "Use 'mold' or 'lld' if 
found when invoking co
 tvm_option(USE_CCACHE "Use ccache if found when invoking compiler" AUTO)
 
 # 3rdparty libraries
-tvm_option(RANG_PATH "Path to RANG" "3rdparty/rang/include")
 tvm_option(COMPILER_RT_PATH "Path to COMPILER-RT" "3rdparty/compiler-rt")
 # Contrib library options
 tvm_option(USE_BYODT_POSIT "Build with BYODT software emulated posit custom 
datatype" OFF)
diff --git a/LICENSE b/LICENSE
index df3fd20aaa..28d0627c1a 100644
--- a/LICENSE
+++ b/LICENSE
@@ -209,34 +209,18 @@ and 3rdparty/tvm-ffi/licenses/ for text of these licenses.
 Apache Software Foundation License 2.0
 --------------------------------------
 
-3rdparty/dmlc-core
 3rdparty/OpenCL-Headers
 3rdparty/nvbench (with LLVM exception)
 3rdparty/cutlass_fpA_intB_gemm
 3rdparty/tensorrt_llm
 3rdparty/tvm-ffi/3rdparty/dlpack
 
-BSD 2-clause License
---------------------
-
-3rdparty/dmlc-core/include/dmlc/concurrentqueue.h
-
-
-BSD 2-clause License + zlib License
------------------------------------
-
-3rdparty/dmlc-core/include/dmlc/blockingconcurrentqueue.h
-
 
 MIT License
 -----------
 
 3rdparty/compiler-rt/builtin_fp16.h
 
-The Unlicense
--------------
-
-3rdparty/rang
 
 BSD 3-Clause "New" or "Revised" License
 ---------------------------------------
diff --git a/docker/lint.sh b/docker/lint.sh
index 7225fa981f..8aea09b8cd 100755
--- a/docker/lint.sh
+++ b/docker/lint.sh
@@ -75,9 +75,6 @@ function run_lint_step() {
                 cmd=( tests/lint/git-black.sh -i --rev origin/main )
             fi
             ;;
-        jnilint)
-            cmd=( tests/lint/jnilint.sh )
-            ;;
         cppdocs)
             cmd=( tests/lint/cppdocs.sh )
             ;;
diff --git a/include/tvm/runtime/logging.h b/include/tvm/runtime/logging.h
index 6492a20fa3..b34b885c04 100644
--- a/include/tvm/runtime/logging.h
+++ b/include/tvm/runtime/logging.h
@@ -19,12 +19,7 @@
 
 /*!
  * \file tvm/runtime/logging.h
- * \brief logging utilities
- *
- * We define our own CHECK and LOG macros to replace those from dmlc-core.
- * These macros are then injected into dmlc-core via the
- * DMLC_USE_LOGGING_LIBRARY define. dmlc-core will #include this file wherever
- * it needs logging.
+ * \brief logging utilitiesß
  */
 #ifndef TVM_RUNTIME_LOGGING_H_
 #define TVM_RUNTIME_LOGGING_H_
@@ -364,7 +359,6 @@ class LogMessage {
 
 #endif
 
-// Below is from dmlc-core
 // This class is used to explicitly ignore values in the conditional
 // logging macros.  This avoids compiler warnings like "value computed
 // is not used" and "statement has no effect".
@@ -431,7 +425,6 @@ class TvmLogDebugSettings {
  * \endcode
  * or a valid setting as described by \p VerboseLoggingEnabled below.
  */
-// Also from dmlc-core
 inline bool DebugLoggingEnabled() {
   static int state = 0;
   if (state == 0) {
diff --git a/python/tvm/relax/frontend/nn/extern.py 
b/python/tvm/relax/frontend/nn/extern.py
index e38de97df3..8d22989323 100644
--- a/python/tvm/relax/frontend/nn/extern.py
+++ b/python/tvm/relax/frontend/nn/extern.py
@@ -292,7 +292,7 @@ class SourceModule(ExternModule):  # pylint: 
disable=too-few-public-methods
     @staticmethod
     def get_includes(tvm_pkg: Optional[List[str]] = None) -> List[Path]:
         """Returns the default include paths according to `tvm_home()`.
-        By default, it includes TVM, DLPack, and DMLC-Core. With `tvm_pkg` 
provided, it also
+        By default, it includes TVM, DLPack. With `tvm_pkg` provided, it also
         includes the specified package under `tvm_home/3rdparty`.
 
         Parameters
@@ -326,7 +326,7 @@ class SourceModule(ExternModule):  # pylint: 
disable=too-few-public-methods
         tvm_pkg: Optional[List[str]] = None,
     ) -> List[str]:
         """Returns the default compile options depending on `source_format`, 
including the default
-        inlcude paths w.r.t. `tvm_home()`, default flags to configure 
DMLC-Core, and by default,
+        inlcude paths w.r.t. `tvm_home()`, and by default,
         it uses "-O3" and "-std=c++17".
 
         Parameters
diff --git a/src/ir/diagnostic.cc b/src/ir/diagnostic.cc
index e20c6b8e17..583549cfa4 100644
--- a/src/ir/diagnostic.cc
+++ b/src/ir/diagnostic.cc
@@ -25,8 +25,6 @@
 #include <tvm/ir/diagnostic.h>
 #include <tvm/ir/source_map.h>
 
-#include <rang.hpp>
-
 namespace tvm {
 
 TVM_FFI_STATIC_INIT_BLOCK() {
@@ -220,41 +218,34 @@ TVM_FFI_STATIC_INIT_BLOCK() {
 
 std::ostream& EmitDiagnosticHeader(std::ostream& out, const Span& span, 
DiagnosticLevel level,
                                    std::string msg) {
-  rang::fg diagnostic_color = rang::fg::reset;
   std::string diagnostic_type;
 
   switch (level) {
     case DiagnosticLevel::kWarning: {
-      diagnostic_color = rang::fg::yellow;
       diagnostic_type = "warning";
       break;
     }
     case DiagnosticLevel::kError: {
-      diagnostic_color = rang::fg::red;
       diagnostic_type = "error";
       break;
     }
     case DiagnosticLevel::kBug: {
-      diagnostic_color = rang::fg::blue;
       diagnostic_type = "bug";
       break;
     }
     case DiagnosticLevel::kNote: {
-      diagnostic_color = rang::fg::reset;
       diagnostic_type = "note";
       break;
     }
     case DiagnosticLevel::kHelp: {
-      diagnostic_color = rang::fg::reset;
       diagnostic_type = "help";
       break;
     }
   }
 
-  out << rang::style::bold << diagnostic_color << diagnostic_type << ": " << 
rang::fg::reset << msg
-      << std::endl
-      << rang::fg::blue << " --> " << rang::fg::reset << rang::style::reset
-      << span->source_name->name << ":" << span->line << ":" << span->column 
<< std::endl;
+  out << diagnostic_type << ": " << msg << std::endl
+      << " --> " << span->source_name->name << ":" << span->line << ":" << 
span->column
+      << std::endl;
 
   return out;
 }
diff --git a/src/runtime/logging.cc b/src/runtime/logging.cc
index 372e5bc301..ef902f22fd 100644
--- a/src/runtime/logging.cc
+++ b/src/runtime/logging.cc
@@ -18,278 +18,8 @@
  */
 #include <tvm/runtime/logging.h>
 
-#include <cstdio>
-#include <cstring>
-#include <stdexcept>
 #include <string>
 
-#if TVM_LOG_STACK_TRACE
-#if TVM_USE_LIBBACKTRACE
-
-#include <backtrace.h>
-#include <cxxabi.h>
-
-#include <iomanip>
-#include <iostream>
-#include <sstream>
-#include <unordered_map>
-#include <vector>
-
-#if TVM_BACKTRACE_ON_SEGFAULT
-#include <signal.h>
-
-#include <csignal>
-#include <cstring>
-#endif
-
-namespace tvm {
-namespace runtime {
-namespace {
-
-struct BacktraceInfo {
-  std::vector<std::string> lines;
-  size_t max_size;
-  std::string error_message;
-};
-
-void BacktraceCreateErrorCallback(void* data, const char* msg, int errnum) {
-  std::cerr << "Could not initialize backtrace state: " << msg << std::endl;
-}
-
-backtrace_state* BacktraceCreate() {
-  return backtrace_create_state(nullptr, 1, BacktraceCreateErrorCallback, 
nullptr);
-}
-
-static backtrace_state* _bt_state = BacktraceCreate();
-
-std::string DemangleName(std::string name) {
-  int status = 0;
-  size_t length = name.size();
-  std::unique_ptr<char, void (*)(void* __ptr)> demangled_name = {
-      abi::__cxa_demangle(name.c_str(), nullptr, &length, &status), 
&std::free};
-  if (demangled_name && status == 0 && length > 0) {
-    return demangled_name.get();
-  } else {
-    return name;
-  }
-}
-
-void BacktraceErrorCallback(void* data, const char* msg, int errnum) {
-  // do nothing
-}
-
-void BacktraceSyminfoCallback(void* data, uintptr_t pc, const char* symname, 
uintptr_t symval,
-                              uintptr_t symsize) {
-  auto str = reinterpret_cast<std::string*>(data);
-
-  if (symname != nullptr) {
-    std::string tmp(symname, symsize);
-    *str = DemangleName(tmp.c_str());
-  } else {
-    std::ostringstream s;
-    s << "0x" << std::setfill('0') << std::setw(sizeof(uintptr_t) * 2) << 
std::hex << pc;
-    *str = s.str();
-  }
-}
-
-int BacktraceFullCallback(void* data, uintptr_t pc, const char* filename, int 
lineno,
-                          const char* symbol) {
-  auto stack_trace = reinterpret_cast<BacktraceInfo*>(data);
-
-  std::unique_ptr<std::string> symbol_str = 
std::make_unique<std::string>("<unknown>");
-  if (symbol) {
-    *symbol_str = DemangleName(symbol);
-  } else {
-    // see if syminfo gives anything
-    backtrace_syminfo(_bt_state, pc, BacktraceSyminfoCallback, 
BacktraceErrorCallback,
-                      symbol_str.get());
-  }
-  symbol = symbol_str->data();
-
-  // TVMFuncCall denotes the API boundary so we stop there. Exceptions
-  // should be caught there.  This is before any frame suppressions,
-  // as it would otherwise be suppressed.
-  bool should_stop_collecting =
-      (*symbol_str == "TVMFuncCall" || stack_trace->lines.size() >= 
stack_trace->max_size);
-  if (should_stop_collecting) {
-    return 1;
-  }
-
-  // Exclude frames that contain little useful information for most
-  // debugging purposes
-  bool should_exclude = [&]() -> bool {
-    if (filename) {
-      // Stack frames for TVM FFI
-      if (strstr(filename, "include/tvm/runtime/packed_func.h") ||
-          strstr(filename, "include/tvm/ffi/function.h") ||
-          strstr(filename, "src/runtime/c_runtime_api.cc")) {
-        return true;
-      }
-      // Stack frames for nested tree recursion.
-      // tir/ir/stmt_functor.cc and tir/ir/expr_functor.cc define
-      // Expr/Stmt Visitor/Mutator, which should be suppressed, but
-      // also Substitute which should not be suppressed.  Therefore,
-      // they are suppressed based on the symbol name.
-      if (strstr(filename, "include/tvm/node/functor.h") ||        //
-          strstr(filename, "include/tvm/relax/expr_functor.h") ||  //
-          strstr(filename, "include/tvm/tir/stmt_functor.h") ||    //
-          strstr(filename, "include/tvm/tir/expr_functor.h") ||    //
-          strstr(filename, "include/tvm/node/reflection.h") ||     //
-          strstr(filename, "src/node/structural_equal.cc") ||      //
-          strstr(filename, "src/ir/transform.cc") ||               //
-          strstr(filename, "src/relax/ir/expr_functor.cc") ||      //
-          strstr(filename, "src/relax/ir/py_expr_functor.cc")) {
-        return true;
-      }
-      // Python interpreter stack frames
-      if (strstr(filename, "/python-") || strstr(filename, "/Python/ceval.c") 
||
-          strstr(filename, "/Modules/_ctypes")) {
-        return true;
-      }
-      // C++ stdlib frames
-      if (strstr(filename, "include/c++/")) {
-        return true;
-      }
-    }
-    if (symbol) {
-      // C++ stdlib frames
-      if (strstr(symbol, "__libc_")) {
-        return true;
-      }
-      // Stack frames for nested tree visiting
-      if (strstr(symbol, "tvm::tir::StmtMutator::VisitStmt_") ||
-          strstr(symbol, "tvm::tir::ExprMutator::VisitExpr_") ||
-          strstr(symbol, "tvm::tir::IRTransformer::VisitExpr") ||
-          strstr(symbol, "tvm::tir::IRTransformer::VisitStmt") ||
-          strstr(symbol, "tvm::tir::IRTransformer::BaseVisitExpr") ||
-          strstr(symbol, "tvm::tir::IRTransformer::BaseVisitStmt")) {
-        return true;
-      }
-      // Python interpreter stack frames
-      if (strstr(symbol, "_Py") == symbol || strstr(symbol, "PyObject")) {
-        return true;
-      }
-    }
-
-    // libffi.so stack frames.  These may also show up as numeric
-    // addresses with no symbol name.  This could be improved in the
-    // future by using dladdr() to check whether an address is contained
-    // in libffi.so
-    if (filename == nullptr && strstr(symbol, "ffi_call_")) {
-      return true;
-    }
-
-    // Skip tvm::backtrace and tvm::LogFatal::~LogFatal at the beginning
-    // of the trace as they don't add anything useful to the backtrace.
-    if (stack_trace->lines.size() == 0 && (strstr(symbol, 
"tvm::runtime::Backtrace") ||
-                                           strstr(symbol, 
"tvm::runtime::detail::LogFatal"))) {
-      return true;
-    }
-
-    return false;
-  }();
-  if (should_exclude) {
-    return 0;
-  }
-
-  std::stringstream frame_str;
-  frame_str << *symbol_str;
-
-  if (filename) {
-    frame_str << std::endl << "        at " << filename;
-    if (lineno != 0) {
-      frame_str << ":" << lineno;
-    }
-  }
-  stack_trace->lines.push_back(frame_str.str());
-
-  return 0;
-}
-
-#if TVM_BACKTRACE_ON_SEGFAULT
-void backtrace_handler(int sig) {
-  // Technically we shouldn't do any allocation in a signal handler, but
-  // Backtrace may allocate. What's the worst it could do? We're already
-  // crashing.
-  std::cerr << "!!!!!!! TVM encountered a Segfault !!!!!!!\n" << Backtrace() 
<< std::endl;
-
-  // Re-raise signal with default handler
-  struct sigaction act;
-  std::memset(&act, 0, sizeof(struct sigaction));
-  act.sa_flags = SA_RESETHAND;
-  act.sa_handler = SIG_DFL;
-  sigaction(sig, &act, nullptr);
-  raise(sig);
-}
-
-__attribute__((constructor)) void install_signal_handler(void) {
-  // this may override already installed signal handlers
-  std::signal(SIGSEGV, backtrace_handler);
-}
-#endif
-}  // namespace
-
-std::string Backtrace() {
-  BacktraceInfo bt;
-
-  // Limit backtrace length based on TVM_BACKTRACE_LIMIT env variable
-  auto user_limit_s = getenv("TVM_BACKTRACE_LIMIT");
-  const auto default_limit = 500;
-
-  if (user_limit_s == nullptr) {
-    bt.max_size = default_limit;
-  } else {
-    // Parse out the user-set backtrace limit
-    try {
-      bt.max_size = std::stoi(user_limit_s);
-    } catch (const std::invalid_argument& e) {
-      bt.max_size = default_limit;
-    }
-  }
-
-  if (_bt_state == nullptr) {
-    return "";
-  }
-  // libbacktrace eats memory if run on multiple threads at the same time, so 
we guard against it
-  {
-    static std::mutex m;
-    std::lock_guard<std::mutex> lock(m);
-    backtrace_full(_bt_state, 0, BacktraceFullCallback, 
BacktraceErrorCallback, &bt);
-  }
-
-  std::ostringstream s;
-  s << "Stack trace:\n";
-  for (size_t i = 0; i < bt.lines.size(); i++) {
-    s << "  " << i << ": " << bt.lines[i] << "\n";
-  }
-
-  return s.str();
-}
-}  // namespace runtime
-}  // namespace tvm
-
-#else
-
-#include <tvm/runtime/logging.h>
-
-namespace tvm {
-namespace runtime {
-// Fallback when libbacktrace is not available.
-std::string Backtrace() { return ""; }
-}  // namespace runtime
-}  // namespace tvm
-
-#endif  // TVM_USE_LIBBACKTRACE
-#else
-
-namespace tvm {
-namespace runtime {
-// stacktrace logging is completely disabled
-std::string Backtrace() { return ""; }
-}  // namespace runtime
-}  // namespace tvm
-#endif  // TVM_LOG_STACK_TRACE
-
 #if (TVM_LOG_CUSTOMIZE == 0)
 namespace tvm {
 namespace runtime {
diff --git a/src/runtime/profiling.cc b/src/runtime/profiling.cc
index b9275398ca..5409989d3b 100644
--- a/src/runtime/profiling.cc
+++ b/src/runtime/profiling.cc
@@ -325,8 +325,7 @@ void metric_as_json(std::ostream& os, ffi::Any o) {
 
 ffi::String ReportNode::AsJSON() const {
   std::ostringstream s;
-  // DMLC's JSONWriter does not allow us to write a key value pair without
-  // implementing Write for the value. We want a specific write for the value,
+  // We want a specific write for the value,
   // so we would have to implement a custom data structure for each type of
   // value we want to print. Instead we construct the json by hand because it
   // is easier.
diff --git a/tests/lint/cpplint.sh b/tests/lint/cpplint.sh
index fbb3b153d6..658366955d 100755
--- a/tests/lint/cpplint.sh
+++ b/tests/lint/cpplint.sh
@@ -18,11 +18,6 @@
 
 set -e
 
-echo "Running cpplint..."
-# TODO: replace dmlc-core lint script with cpplint
-echo "cpplint skipped (dmlc-core removed)"
-
-
 if find src -name "*.cc" -exec grep -Hn '^#include <regex>$' {} +; then
     echo "The <regex> header file may not be used in TVM," 1>&2
     echo "because it causes ABI incompatibility with most pytorch 
installations." 1>&2
diff --git a/tests/lint/jnilint.sh b/tests/lint/jnilint.sh
index 6fa5dc3d6d..5d206a0286 100755
--- a/tests/lint/jnilint.sh
+++ b/tests/lint/jnilint.sh
@@ -17,6 +17,3 @@
 # under the License.
 
 set -e
-
-# TODO: replace dmlc-core lint script with cpplint
-echo "jnilint skipped (dmlc-core removed)"
diff --git a/tests/scripts/task_lint.sh b/tests/scripts/task_lint.sh
index 6a6a2171bd..6329573f88 100755
--- a/tests/scripts/task_lint.sh
+++ b/tests/scripts/task_lint.sh
@@ -48,9 +48,6 @@ function shard1 {
 
   echo "Checking for non-inclusive language with blocklint..."
   tests/lint/blocklint.sh
-
-  echo "Linting the JNI code..."
-  tests/lint/jnilint.sh
 }
 
 function shard2 {

Reply via email to