This is an automated email from the ASF dual-hosted git repository.
junrushao 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 1608ca82ce [CMAKE] Introduce dummy build as an option (#15000)
1608ca82ce is described below
commit 1608ca82ce0d5f581d46f2e2b71e9c26e40f0279
Author: Tianqi Chen <[email protected]>
AuthorDate: Thu Jun 1 11:07:20 2023 -0400
[CMAKE] Introduce dummy build as an option (#15000)
Previously the dummy build sets a separate target
which can cause issues in some windows build.
This PR updates the build to use an explicit option.
---
CMakeLists.txt | 27 ++++++++++++++-------------
cmake/modules/LibInfo.cmake | 1 +
src/support/libinfo.cc | 1 +
3 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4cc59789f7..145d013b9a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -71,6 +71,7 @@ tvm_option(INDEX_DEFAULT_I64 "Defaults the index datatype to
int64" ON)
tvm_option(USE_LIBBACKTRACE "Use libbacktrace to supply linenumbers on stack
traces" AUTO)
tvm_option(BACKTRACE_ON_SEGFAULT "Install a signal handler to print a
backtrace on segfault" OFF)
tvm_option(BUILD_STATIC_RUNTIME "Build static version of libtvm_runtime" OFF)
+tvm_option(BUILD_DUMMY_LIBTVM "Build a dummy version of libtvm" OFF)
tvm_option(USE_PAPI "Use Performance Application Programming Interface (PAPI)
to read performance counters" OFF)
tvm_option(USE_GTEST "Use GoogleTest for C++ sanity tests" AUTO)
tvm_option(USE_CUSTOM_LOGGING "Use user-defined custom logging,
tvm::runtime::detail::LogFatalImpl and tvm::runtime::detail::LogMessageImpl
must be implemented" OFF)
@@ -544,7 +545,14 @@ add_library(tvm_objs OBJECT ${COMPILER_SRCS})
add_library(tvm_runtime_objs OBJECT ${RUNTIME_SRCS})
add_library(tvm_libinfo_objs OBJECT ${LIBINFO_FILE})
-add_library(tvm SHARED $<TARGET_OBJECTS:tvm_objs>
$<TARGET_OBJECTS:tvm_runtime_objs> $<TARGET_OBJECTS:tvm_libinfo_objs>)
+if(NOT BUILD_DUMMY_LIBTVM)
+ add_library(tvm SHARED $<TARGET_OBJECTS:tvm_objs>
$<TARGET_OBJECTS:tvm_runtime_objs> $<TARGET_OBJECTS:tvm_libinfo_objs>)
+else()
+ # dummy version of libtvm that can be used by downstream to specify
dependencies
+ # the real runner still need a full version of libtvm
+ add_library(tvm SHARED $<TARGET_OBJECTS:tvm_runtime_objs>
$<TARGET_OBJECTS:tvm_libinfo_objs>)
+endif()
+
target_include_directories(tvm PUBLIC
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
set_property(TARGET tvm APPEND PROPERTY LINK_OPTIONS
"${TVM_NO_UNDEFINED_SYMBOLS}")
set_property(TARGET tvm APPEND PROPERTY LINK_OPTIONS "${TVM_VISIBILITY_FLAG}")
@@ -561,24 +569,15 @@ else()
set_property(TARGET tvm_runtime APPEND PROPERTY LINK_OPTIONS
"${TVM_NO_UNDEFINED_SYMBOLS}")
endif()
-# dummy target is not compiled by default
-# it can be used by downstream project to create a "link" to libtvm without
compiling libtvm
-# This is useful in platforms such as windows
-# The created dll still need the real libtvm to be available in runtime.
-add_library(tvm_dummy SHARED EXCLUDE_FROM_ALL
$<TARGET_OBJECTS:tvm_runtime_objs> $<TARGET_OBJECTS:tvm_libinfo_objs>)
-set_target_properties(tvm_dummy PROPERTIES OUTPUT_NAME "tvm")
-set_target_properties(tvm_dummy PROPERTIES LIBRARY_OUTPUT_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/dummy/)
target_include_directories(tvm_runtime PUBLIC
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
set_property(TARGET tvm_runtime APPEND PROPERTY LINK_OPTIONS
"${TVM_VISIBILITY_FLAG}")
-set_property(TARGET tvm_dummy APPEND PROPERTY LINK_OPTIONS
"${TVM_VISIBILITY_FLAG}")
target_compile_definitions(tvm_objs PUBLIC
DMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>)
target_compile_definitions(tvm_runtime_objs PUBLIC
DMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>)
target_compile_definitions(tvm_libinfo_objs PUBLIC
DMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>)
target_compile_definitions(tvm PUBLIC
DMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>)
target_compile_definitions(tvm_runtime PUBLIC
DMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>)
-target_compile_definitions(tvm_dummy PUBLIC
DMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>)
# logging option for libbacktrace
include(cmake/modules/Logging.cmake)
@@ -641,9 +640,12 @@ if(USE_THREADS AND NOT BUILD_FOR_HEXAGON)
target_link_libraries(tvm_runtime PUBLIC Threads::Threads)
endif()
-target_link_libraries(tvm PRIVATE ${TVM_LINKER_LIBS}
${TVM_RUNTIME_LINKER_LIBS})
+if(NOT BUILD_DUMMY_LIBTVM)
+ target_link_libraries(tvm PRIVATE ${TVM_LINKER_LIBS})
+endif()
+
+target_link_libraries(tvm PRIVATE ${TVM_RUNTIME_LINKER_LIBS})
target_link_libraries(tvm_runtime PRIVATE ${TVM_RUNTIME_LINKER_LIBS})
-target_link_libraries(tvm_dummy PRIVATE ${TVM_RUNTIME_LINKER_LIBS})
if(BUILD_FOR_HEXAGON AND DEFINED USE_HEXAGON_GTEST AND EXISTS
${USE_HEXAGON_GTEST})
include(FetchContent)
@@ -680,7 +682,6 @@ if (HIDE_PRIVATE_SYMBOLS AND NOT ${CMAKE_SYSTEM_NAME}
MATCHES "Darwin")
# once minimum CMake version is bumped up to 3.13 or above.
target_link_libraries(tvm PRIVATE ${HIDE_SYMBOLS_LINKER_FLAGS})
target_link_libraries(tvm_runtime PRIVATE ${HIDE_SYMBOLS_LINKER_FLAGS})
- target_link_libraries(tvm_dummy PRIVATE ${HIDE_SYMBOLS_LINKER_FLAGS})
target_compile_definitions(tvm_allvisible PUBLIC
$<TARGET_PROPERTY:tvm,INTERFACE_COMPILE_DEFINITONS>)
target_compile_definitions(tvm_allvisible PRIVATE
$<TARGET_PROPERTY:tvm,COMPILE_DEFINITONS>)
endif()
diff --git a/cmake/modules/LibInfo.cmake b/cmake/modules/LibInfo.cmake
index 35e246cd8f..2c23d24b36 100644
--- a/cmake/modules/LibInfo.cmake
+++ b/cmake/modules/LibInfo.cmake
@@ -36,6 +36,7 @@ function(add_lib_info src_file)
PROPERTY COMPILE_DEFINITIONS
TVM_CXX_COMPILER_PATH="${CMAKE_CXX_COMPILER}"
TVM_INFO_BUILD_STATIC_RUNTIME="${BUILD_STATIC_RUNTIME}"
+ TVM_INFO_BUILD_DUMMY_LIBTVM="${BUILD_DUMMY_LIBTVM}"
TVM_INFO_COMPILER_RT_PATH="${COMPILER_RT_PATH}"
TVM_INFO_CUDA_VERSION="${TVM_INFO_CUDA_VERSION}"
TVM_INFO_DLPACK_PATH="${DLPACK_PATH}"
diff --git a/src/support/libinfo.cc b/src/support/libinfo.cc
index 96e8279b67..bb609cb872 100644
--- a/src/support/libinfo.cc
+++ b/src/support/libinfo.cc
@@ -252,6 +252,7 @@ namespace tvm {
TVM_DLL Map<String, String> GetLibInfo() {
Map<String, String> result = {
{"BUILD_STATIC_RUNTIME", TVM_INFO_BUILD_STATIC_RUNTIME},
+ {"BUILD_DUMMY_LIBTVM", TVM_INFO_BUILD_DUMMY_LIBTVM},
{"COMPILER_RT_PATH", TVM_INFO_COMPILER_RT_PATH},
{"CUDA_VERSION", TVM_INFO_CUDA_VERSION},
{"DLPACK_PATH", TVM_INFO_DLPACK_PATH},