1515# specific language governing permissions and limitations
1616# under the License.
1717
18-
1918if (USE_MICRO)
2019
21- if (MSVC )
22-
23- # When building for Windows, use standard CMake for compatibility with
24- # Visual Studio build tools and not require Make to be on the system.
25-
26- # TODO: test building with this MSVC conditional code removed
27- # when USE_MICRO is enabled
20+ message (STATUS "Build microTVM RPC common" )
2821
29- set (CRT_CONFIG, "src/runtime/micro/crt_config.h" )
22+ # add microTVM RPC common files to TVM runtime build
23+ list (APPEND TVM_CRT_SOURCES
24+ 3rdparty/libcrc/src/crcccitt.c
25+ src/runtime/crt/microtvm_rpc_common/frame_buffer.cc
26+ src/runtime/crt/microtvm_rpc_common/framing.cc
27+ src/runtime/crt/microtvm_rpc_common/session.cc
28+ src/runtime/crt/microtvm_rpc_common/write_stream.cc)
3029
31- add_library (host_standalone_crt
32- STATIC
33- 3rdparty/libcrc/src/crcccitt.c
34- src/runtime/crt/microtvm_rpc_common/frame_buffer.cc
35- src/runtime/crt/microtvm_rpc_common/framing.cc
36- src/runtime/crt/microtvm_rpc_common/session.cc
37- src/runtime/crt/microtvm_rpc_common/write_stream.cc)
30+ list (APPEND RUNTIME_SRCS ${TVM_CRT_SOURCES} )
31+ include_directories (SYSTEM src/runtime/micro)
3832
39- target_include_directories (host_standalone_crt
40- PRIVATE
41- 3rdparty/libcrc/include
42- src/runtime/micro)
43-
44- else ()
4533
4634 function (create_crt_library CRT_LIBRARY)
4735
4836 set (CRT_LIBRARY_NAME host_standalone_crt_${CRT_LIBRARY} )
4937 set (CRT_LIBRARY_SOURCES "" )
5038
5139 foreach (FILE_NAME IN LISTS ARGN)
52- list (APPEND CRT_LIBRARY_SOURCES ${FILE_NAME} )
40+ list (APPEND CRT_LIBRARY_SOURCES ${FILE_NAME} )
5341 endforeach ()
5442
5543 add_library (${CRT_LIBRARY_NAME}
6048 set (CRT_LIBRARIES ${CRT_LIBRARIES} ${CRT_LIBRARY_NAME} PARENT_SCOPE)
6149
6250 target_include_directories (${CRT_LIBRARY_NAME}
63- PUBLIC
64- ${CMAKE_CURRENT_SOURCE_DIR} /src/runtime/micro/
65- ${STANDALONE_CRT_BASE} /include )
51+ PUBLIC
52+ ${CMAKE_CURRENT_SOURCE_DIR} /src/runtime/micro/
53+ ${STANDALONE_CRT_BASE} /include )
6654
6755 set_target_properties (${CRT_LIBRARY_NAME}
6856 PROPERTIES
7563
7664 endfunction ()
7765
78- message (STATUS "Build standalone CRT for microTVM " )
66+ message (STATUS "Build microTVM standalone CRT" )
7967
8068 # Build an isolated build directory, separate from the TVM tree.
8169 list (APPEND CRT_FILE_COPY_JOBS
@@ -147,32 +135,36 @@ else()
147135 ${RUNTIME_CRT_SOURCE_DIR} /aot_executor_module/aot_executor_module.c)
148136
149137 create_crt_library(graph_executor
150- ${RUNTIME_CRT_SOURCE_DIR} /graph_executor/graph_executor.c
151- ${RUNTIME_CRT_SOURCE_DIR} /graph_executor/load_json.c)
138+ ${RUNTIME_CRT_SOURCE_DIR} /graph_executor/graph_executor.c
139+ ${RUNTIME_CRT_SOURCE_DIR} /graph_executor/load_json.c)
152140
153141 create_crt_library(graph_executor_module
154- ${RUNTIME_CRT_SOURCE_DIR} /graph_executor_module/graph_executor_module.c)
142+ ${RUNTIME_CRT_SOURCE_DIR} /graph_executor_module/graph_executor_module.c)
155143
156144 create_crt_library(memory
157- ${RUNTIME_CRT_SOURCE_DIR} /memory/page_allocator.c
158- ${RUNTIME_CRT_SOURCE_DIR} /memory/stack_allocator.c)
145+ ${RUNTIME_CRT_SOURCE_DIR} /memory/page_allocator.c
146+ ${RUNTIME_CRT_SOURCE_DIR} /memory/stack_allocator.c)
159147
160148 create_crt_library(microtvm_rpc_common
161- ${RUNTIME_CRT_SOURCE_DIR} /microtvm_rpc_common/crcccitt.c
162- ${RUNTIME_CRT_SOURCE_DIR} /microtvm_rpc_common/frame_buffer.cc
163- ${RUNTIME_CRT_SOURCE_DIR} /microtvm_rpc_common/framing.cc
164- ${RUNTIME_CRT_SOURCE_DIR} /microtvm_rpc_common/session.cc
165- ${RUNTIME_CRT_SOURCE_DIR} /microtvm_rpc_common/write_stream.cc)
149+ ${RUNTIME_CRT_SOURCE_DIR} /microtvm_rpc_common/crcccitt.c
150+ ${RUNTIME_CRT_SOURCE_DIR} /microtvm_rpc_common/frame_buffer.cc
151+ ${RUNTIME_CRT_SOURCE_DIR} /microtvm_rpc_common/framing.cc
152+ ${RUNTIME_CRT_SOURCE_DIR} /microtvm_rpc_common/session.cc
153+ ${RUNTIME_CRT_SOURCE_DIR} /microtvm_rpc_common/write_stream.cc)
166154
167155 create_crt_library(microtvm_rpc_server
168- ${RUNTIME_CRT_SOURCE_DIR} /microtvm_rpc_server/rpc_server.cc)
169-
170- create_crt_library(common
171- ${RUNTIME_CRT_SOURCE_DIR} /common/crt_backend_api.c
172- ${RUNTIME_CRT_SOURCE_DIR} /common/crt_runtime_api.c
173- ${RUNTIME_CRT_SOURCE_DIR} /common/func_registry.c
174- ${RUNTIME_CRT_SOURCE_DIR} /common/ndarray.c
175- ${RUNTIME_CRT_SOURCE_DIR} /common/packed_func.c)
156+ ${RUNTIME_CRT_SOURCE_DIR} /microtvm_rpc_server/rpc_server.cc)
157+
158+ if (NOT MSVC )
159+ # TODO: if we want to eventually build standalone_crt for windows
160+ # these files would be needed, but for now don't build them
161+ create_crt_library(common
162+ ${RUNTIME_CRT_SOURCE_DIR} /common/crt_backend_api.c
163+ ${RUNTIME_CRT_SOURCE_DIR} /common/crt_runtime_api.c
164+ ${RUNTIME_CRT_SOURCE_DIR} /common/func_registry.c
165+ ${RUNTIME_CRT_SOURCE_DIR} /common/ndarray.c
166+ ${RUNTIME_CRT_SOURCE_DIR} /common/packed_func.c)
167+ endif ()
176168
177169 add_custom_target (host_standalone_crt DEPENDS ${CRT_LIBRARIES} standalone_crt)
178170
@@ -188,15 +180,4 @@ else()
188180 gtest_discover_tests(crttest)
189181 endif ()
190182
191- set (TVM_CRT_LINKER_LIB host_standalone_crt_microtvm_rpc_common)
192- if ("${CMAKE_CXX_COMPILER_ID} " STREQUAL "GNU" )
193- list (APPEND TVM_RUNTIME_LINKER_LIBS -Wl,--whole-archive ${TVM_CRT_LINKER_LIB} -Wl,--no -whole-archive)
194- elseif ("${CMAKE_CXX_COMPILER_ID} " MATCHES ".*Clang" )
195- list (APPEND TVM_RUNTIME_LINKER_LIBS -Wl,-force_load ${TVM_CRT_LINKER_LIB} )
196- else ()
197- list (APPEND TVM_RUNTIME_LINKER_LIBS ${TVM_CRT_LINKER_LIB} )
198- endif ()
199-
200- endif ()
201-
202183endif ()
0 commit comments