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

tqchen pushed a commit to branch refactor-s3
in repository https://gitbox.apache.org/repos/asf/tvm.git

commit 0c7211ec1e75bae7d4a79b286f72bcde778ae402
Author: tqchen <[email protected]>
AuthorDate: Sun May 4 21:20:06 2025 -0400

    [WIN] Cleanup for win
---
 cmake/utils/FindLLVM.cmake   | 5 ++++-
 ffi/CMakeLists.txt           | 7 +++++++
 ffi/src/ffi/traceback_win.cc | 3 +--
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/cmake/utils/FindLLVM.cmake b/cmake/utils/FindLLVM.cmake
index 182a2c6693..2a243b06c8 100644
--- a/cmake/utils/FindLLVM.cmake
+++ b/cmake/utils/FindLLVM.cmake
@@ -199,7 +199,7 @@ macro(find_llvm use_llvm)
         message(STATUS "LLVM links against zlib")
         find_package(ZLIB REQUIRED)
         list(APPEND LLVM_LIBS "ZLIB::ZLIB")
-      elseif("${__flag}" STREQUAL "-lzstd" OR ("${__flag}" STREQUAL 
"zstd.dll.lib"))
+      elseif("${__flag}" STREQUAL "-lzstd")
         list(APPEND CMAKE_MODULE_PATH "${__llvm_cmakedir}")
         find_package(zstd REQUIRED)
         if (TARGET "zstd::libzstd_static")
@@ -212,6 +212,9 @@ macro(find_llvm use_llvm)
       elseif("${__flag}" STREQUAL "-lxml2")
         message(STATUS "LLVM links against xml2")
         list(APPEND LLVM_LIBS "-lxml2")
+      elseif("${__flag}" STREQUAL "zstd.dll.lib")
+        message(STATUS "LLVM linker flag under LLVM libdir: 
${__llvm_libdir}/zstd.lib")
+        list(APPEND LLVM_LIBS "${__llvm_libdir}/zstd.lib")
       elseif((__flag MATCHES ".lib$") AND (EXISTS 
"${__llvm_libdir}/${__flag}"))
         # If the library file ends in .lib try to also search the llvm_libdir
         message(STATUS "LLVM linker flag under LLVM libdir: 
${__llvm_libdir}/${__flag}")
diff --git a/ffi/CMakeLists.txt b/ffi/CMakeLists.txt
index 209913d60f..ab9a3fabc3 100644
--- a/ffi/CMakeLists.txt
+++ b/ffi/CMakeLists.txt
@@ -104,6 +104,13 @@ if (TARGET libbacktrace)
   target_link_libraries(tvm_ffi_shared PRIVATE libbacktrace)
   target_link_libraries(tvm_ffi_static PRIVATE libbacktrace)
 endif ()
+
+if (MSVC)
+  target_link_libraries(tvm_ffi_objs PRIVATE DbgHelp.lib)
+  target_link_libraries(tvm_ffi_shared PRIVATE DbgHelp.lib)
+  target_link_libraries(tvm_ffi_static PRIVATE DbgHelp.lib)
+endif ()
+
 target_link_libraries(tvm_ffi_objs PUBLIC tvm_ffi_header)
 target_link_libraries(tvm_ffi_shared PUBLIC tvm_ffi_header)
 target_link_libraries(tvm_ffi_static PUBLIC tvm_ffi_header)
diff --git a/ffi/src/ffi/traceback_win.cc b/ffi/src/ffi/traceback_win.cc
index 166b7eb242..4c89c4f239 100644
--- a/ffi/src/ffi/traceback_win.cc
+++ b/ffi/src/ffi/traceback_win.cc
@@ -23,9 +23,8 @@
  */
 #ifdef _MSC_VER
 
-#include <dbghelp.h>
 #include <windows.h>
-#pragma comment(lib, "DbgHelp.lib")
+#include <dbghelp.h>  // NOLINT(*)
 
 #include <tvm/ffi/c_api.h>
 #include <tvm/ffi/error.h>

Reply via email to