Skip to content

Commit

Permalink
[FIX,CMAKE] Only compile runtime files once (apache#7417)
Browse files Browse the repository at this point in the history
* [FIX,CMAKE] Only compile runtime files once

* copy defines to tvm_runtime_objs
  • Loading branch information
tkonolige authored and trevor-m committed Mar 2, 2021
1 parent 6981dfd commit 8b86e32
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,10 @@ add_lib_info(${CMAKE_CURRENT_LIST_DIR}/src/support/libinfo.cc)

# TODO(trevmorr): Update tvm_runtime_static to match other targets
add_library(tvm_runtime_static STATIC ${RUNTIME_SRCS})
add_library(tvm_objs OBJECT ${COMPILER_SRCS} ${RUNTIME_SRCS})
add_library(tvm_objs OBJECT ${COMPILER_SRCS})
add_library(tvm_runtime_objs OBJECT ${RUNTIME_SRCS})

add_library(tvm SHARED $<TARGET_OBJECTS:tvm_objs>)
add_library(tvm SHARED $<TARGET_OBJECTS:tvm_objs> $<TARGET_OBJECTS:tvm_runtime_objs>)
set_property(TARGET tvm APPEND PROPERTY LINK_OPTIONS "${TVM_VISIBILITY_FLAG}")
add_library(tvm_runtime SHARED $<TARGET_OBJECTS:tvm_runtime_objs>)
set_property(TARGET tvm_runtime APPEND PROPERTY LINK_OPTIONS "${TVM_VISIBILITY_FLAG}")
Expand All @@ -412,16 +412,21 @@ if(USE_RELAY_DEBUG)
message(STATUS "Building Relay in debug mode...")
target_compile_definitions(tvm_objs PRIVATE "USE_RELAY_DEBUG")
target_compile_definitions(tvm_objs PRIVATE "DMLC_LOG_DEBUG")
target_compile_definitions(tvm_runtime_objs PRIVATE "USE_RELAY_DEBUG")
target_compile_definitions(tvm_runtime_objs PRIVATE "DMLC_LOG_DEBUG")
else()
target_compile_definitions(tvm_objs PRIVATE "NDEBUG")
target_compile_definitions(tvm_runtime_objs PRIVATE "NDEBUG")
endif(USE_RELAY_DEBUG)

if(USE_FALLBACK_STL_MAP)
message(STATUS "Building with STL Map...")
target_compile_definitions(tvm_objs PRIVATE "USE_FALLBACK_STL_MAP=1")
target_compile_definitions(tvm_runtime_objs PRIVATE "USE_FALLBACK_STL_MAP=1")
else()
message(STATUS "Building with TVM Map...")
target_compile_definitions(tvm_objs PRIVATE "USE_FALLBACK_STL_MAP=0")
target_compile_definitions(tvm_runtime_objs PRIVATE "USE_FALLBACK_STL_MAP=0")
endif(USE_FALLBACK_STL_MAP)

if(BUILD_FOR_HEXAGON)
Expand Down Expand Up @@ -465,7 +470,7 @@ target_include_directorieS(

set(TVM_TEST_LIBRARY_NAME tvm)
if (HIDE_PRIVATE_SYMBOLS AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_library(tvm_allvisible SHARED $<TARGET_OBJECTS:tvm_objs>)
add_library(tvm_allvisible SHARED $<TARGET_OBJECTS:tvm_objs> $<TARGET_OBJECTS:tvm_runtime_objs>)
target_include_directories(tvm_allvisible PUBLIC "$<TARGET_PROPERTY:tvm,INCLUDE_DIRECTORIES>")
target_link_libraries(tvm_allvisible PRIVATE "$<TARGET_PROPERTY:tvm,LINK_LIBRARIES>")
set(TVM_TEST_LIBRARY_NAME tvm_allvisible)
Expand Down

0 comments on commit 8b86e32

Please sign in to comment.