You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/12/12 21:34:51 UTC
[GitHub] [tvm] alanmacd opened a new pull request, #13600: Build standalone_crt with cmake instead of makefile
alanmacd opened a new pull request, #13600:
URL: https://github.com/apache/tvm/pull/13600
Build standalone_crt with cmake instead of makefile
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] alanmacd commented on a diff in pull request #13600: [microTVM] Build standalone_crt with cmake instead of makefile
Posted by GitBox <gi...@apache.org>.
alanmacd commented on code in PR #13600:
URL: https://github.com/apache/tvm/pull/13600#discussion_r1048811731
##########
cmake/modules/StandaloneCrt.cmake:
##########
@@ -40,129 +40,154 @@ if(MSVC)
else()
- message(STATUS "Build standalone CRT for microTVM")
+ function(create_crt_library CRT_LIBRARY)
- function(tvm_crt_define_targets)
- # Build an isolated build directory, separate from the TVM tree.
- list(APPEND CRT_FILE_COPY_JOBS
- "3rdparty/libcrc/include *.h -> include"
- "3rdparty/libcrc/src crcccitt.c -> src/runtime/crt/microtvm_rpc_common"
- "3rdparty/libcrc/tab gentab_ccitt.inc -> src/runtime/crt/tab"
- "3rdparty/dlpack/include *.h -> include"
- "3rdparty/dmlc-core/include *.h -> include"
- "include/tvm/runtime c_*_api.h -> include/tvm/runtime"
- "include/tvm/runtime metadata_types.h -> include/tvm/runtime"
- "include/tvm/runtime/crt *.h -> include/tvm/runtime/crt"
- "src/runtime/crt Makefile -> ."
- "src/runtime/crt/include *.h -> include"
- "src/runtime/crt/aot_executor *.c -> src/runtime/crt/aot_executor"
- "src/runtime/crt/aot_executor_module *.c -> src/runtime/crt/aot_executor_module"
- "src/runtime/crt/common *.c -> src/runtime/crt/common"
- "src/runtime/crt/graph_executor *.c -> src/runtime/crt/graph_executor"
- "src/runtime/crt/graph_executor_module *.c -> src/runtime/crt/graph_executor_module"
- "src/runtime/crt/host *.cc -> template/host"
- "src/runtime/crt/host *.py -> template/host"
- "src/runtime/crt/host Makefile.template -> template/host"
- "src/runtime/crt/memory *.c -> src/runtime/crt/memory"
- "src/runtime/crt/microtvm_rpc_common *.cc -> src/runtime/crt/microtvm_rpc_common"
- "src/runtime/crt/microtvm_rpc_server *.cc -> src/runtime/crt/microtvm_rpc_server"
- "src/runtime/minrpc *.h -> src/runtime/minrpc"
- "src/support generic_arena.h -> src/support"
- "src/support ssize.h -> src/support"
- "src/runtime/crt crt_config-template.h -> template"
- )
-
- set(standalone_crt_base "${CMAKE_CURRENT_BINARY_DIR}/standalone_crt")
-
- foreach(job_spec IN LISTS CRT_FILE_COPY_JOBS)
- string(REPLACE " " ";" job_spec "${job_spec}")
- list(LENGTH job_spec job_spec_length)
- math(EXPR job_spec_length_mod "${job_spec_length} % 3")
- if(NOT "${job_spec_length_mod}" EQUAL 1)
- message(FATAL_ERROR "CRT copy job spec list length is ${job_spec_length}; parsed job spec is ${job_spec}")
- endif()
- math(EXPR job_spec_stop "${job_spec_length} - 3")
-
- list(GET job_spec 0 job_src_base)
- set(job_src_base "${CMAKE_CURRENT_SOURCE_DIR}/${job_src_base}")
- foreach(copy_pattern_index RANGE 1 "${job_spec_stop}" 3)
- list(GET job_spec ${copy_pattern_index} copy_pattern)
- math(EXPR copy_dest_index "${copy_pattern_index} + 2")
- list(GET job_spec ${copy_dest_index} copy_dest)
-
- tvm_file_glob(GLOB_RECURSE copy_files
- RELATIVE "${job_src_base}"
- "${job_src_base}/${copy_pattern}")
- list(LENGTH copy_files copy_files_length)
- if("${copy_files_length}" EQUAL 0)
- message(FATAL_ERROR "CRT copy job matched 0 files: ${job_src_base}/${copy_pattern} -> ${copy_dest}")
- endif()
- foreach(copy_src IN LISTS copy_files)
- get_filename_component(dest_path "${standalone_crt_base}/${copy_dest}/${copy_src}" ABSOLUTE)
- tvm_micro_add_copy_file(host_isolated_build_deps ${job_src_base}/${copy_src} ${dest_path})
- endforeach()
- endforeach()
- endforeach()
+ set(CRT_LIBRARY_NAME host_standalone_crt_${CRT_LIBRARY})
+ set(CRT_LIBRARY_SOURCES "")
- add_custom_target(standalone_crt DEPENDS ${host_isolated_build_deps})
+ foreach(FILE_NAME IN LISTS ARGN)
+ list(APPEND CRT_LIBRARY_SOURCES ${FILE_NAME})
+ endforeach()
- get_filename_component(host_build_dir_abspath "${CMAKE_CURRENT_BINARY_DIR}/host_standalone_crt" ABSOLUTE)
+ add_library(${CRT_LIBRARY_NAME}
+ STATIC
+ ${CRT_LIBRARY_SOURCES})
- if(${VERBOSE})
- set(make_quiet QUIET=)
- else(${VERBOSE})
- set(make_quiet )
- endif(${VERBOSE})
+ # add this library to the list of CRT libraries
+ set(CRT_LIBRARIES ${CRT_LIBRARIES} ${CRT_LIBRARY_NAME} PARENT_SCOPE)
- list(APPEND crt_libraries memory graph_executor microtvm_rpc_server microtvm_rpc_common common) # NOTE: listed in link order.
- foreach(crt_lib_name IN LISTS crt_libraries)
- list(APPEND crt_library_paths "host_standalone_crt/lib${crt_lib_name}.a")
- endforeach()
+ target_include_directories(${CRT_LIBRARY_NAME}
+ PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/micro/
+ ${STANDALONE_CRT_BASE}/include)
- set(make_common_args
- "CRT_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/micro/crt_config.h"
- "BUILD_DIR=${host_build_dir_abspath}"
- "EXTRA_CFLAGS=-fPIC"
- "EXTRA_CXXFLAGS=-fPIC"
- "EXTRA_LDFLAGS=-fPIC"
- "${make_quiet}")
-
- add_custom_command(
- OUTPUT ${crt_library_paths}
- COMMAND make ARGS ${make_common_args} clean
- COMMAND make ARGS ${make_common_args} all
- WORKING_DIRECTORY "${standalone_crt_base}"
- DEPENDS standalone_crt ${host_isolated_build_deps})
-
- add_custom_target(host_standalone_crt DEPENDS ${crt_library_paths})
-
- foreach(crt_lib IN LISTS crt_libraries)
- set(cmake_crt_lib_name host_standalone_crt_${crt_lib})
- list(APPEND cmake_crt_libraries ${cmake_crt_lib_name})
- add_library(${cmake_crt_lib_name} STATIC IMPORTED GLOBAL)
- set(cmake_crt_lib_path "${CMAKE_CURRENT_BINARY_DIR}/host_standalone_crt/lib${crt_lib}.a")
- add_dependencies(${cmake_crt_lib_name} host_standalone_crt "${cmake_crt_lib_path}")
- set_target_properties(${cmake_crt_lib_name} PROPERTIES
- IMPORTED_LOCATION "${cmake_crt_lib_path}"
- IMPORTED_OBJECTS "${cmake_crt_lib_path}"
- PUBLIC_HEADER "${crt_headers}")
- endforeach()
+ set_target_properties(${CRT_LIBRARY_NAME}
+ PROPERTIES
+ ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/host_standalone_crt
+ POSITION_INDEPENDENT_CODE ON)
Review Comment:
will do this in subsequent PR that also replaced the standalone_crt/Makefile with cmake version
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] alanmacd commented on a diff in pull request #13600: [microTVM] Build standalone_crt with cmake instead of makefile
Posted by GitBox <gi...@apache.org>.
alanmacd commented on code in PR #13600:
URL: https://github.com/apache/tvm/pull/13600#discussion_r1048819357
##########
cmake/modules/StandaloneCrt.cmake:
##########
@@ -40,129 +40,147 @@ if(MSVC)
else()
Review Comment:
will follow-up in another PR with this
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] alanmacd commented on a diff in pull request #13600: [microTVM] Build standalone_crt with cmake instead of makefile
Posted by GitBox <gi...@apache.org>.
alanmacd commented on code in PR #13600:
URL: https://github.com/apache/tvm/pull/13600#discussion_r1046415428
##########
cmake/modules/StandaloneCrt.cmake:
##########
@@ -40,129 +40,143 @@ if(MSVC)
else()
Review Comment:
NOTE: change diff settings to hide whitespace (if not set) for this diff to make more sense since I needed to change indentation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] mehrdadh commented on pull request #13600: [microTVM] Build standalone_crt with cmake instead of makefile
Posted by GitBox <gi...@apache.org>.
mehrdadh commented on PR #13600:
URL: https://github.com/apache/tvm/pull/13600#issuecomment-1372614310
Given the time that this PR was open I will merge it.
@leandron @areusch thanks for the reviews!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] alanmacd commented on a diff in pull request #13600: [microTVM] Build standalone_crt with cmake instead of makefile
Posted by GitBox <gi...@apache.org>.
alanmacd commented on code in PR #13600:
URL: https://github.com/apache/tvm/pull/13600#discussion_r1046576417
##########
cmake/modules/StandaloneCrt.cmake:
##########
@@ -40,129 +40,147 @@ if(MSVC)
else()
- message(STATUS "Build standalone CRT for microTVM")
+ function(create_crt_library CRT_LIBRARY)
- function(tvm_crt_define_targets)
- # Build an isolated build directory, separate from the TVM tree.
- list(APPEND CRT_FILE_COPY_JOBS
- "3rdparty/libcrc/include *.h -> include"
- "3rdparty/libcrc/src crcccitt.c -> src/runtime/crt/microtvm_rpc_common"
- "3rdparty/libcrc/tab gentab_ccitt.inc -> src/runtime/crt/tab"
- "3rdparty/dlpack/include *.h -> include"
- "3rdparty/dmlc-core/include *.h -> include"
- "include/tvm/runtime c_*_api.h -> include/tvm/runtime"
- "include/tvm/runtime metadata_types.h -> include/tvm/runtime"
- "include/tvm/runtime/crt *.h -> include/tvm/runtime/crt"
- "src/runtime/crt Makefile -> ."
- "src/runtime/crt/include *.h -> include"
- "src/runtime/crt/aot_executor *.c -> src/runtime/crt/aot_executor"
- "src/runtime/crt/aot_executor_module *.c -> src/runtime/crt/aot_executor_module"
- "src/runtime/crt/common *.c -> src/runtime/crt/common"
- "src/runtime/crt/graph_executor *.c -> src/runtime/crt/graph_executor"
- "src/runtime/crt/graph_executor_module *.c -> src/runtime/crt/graph_executor_module"
- "src/runtime/crt/host *.cc -> template/host"
- "src/runtime/crt/host *.py -> template/host"
- "src/runtime/crt/host Makefile.template -> template/host"
- "src/runtime/crt/memory *.c -> src/runtime/crt/memory"
- "src/runtime/crt/microtvm_rpc_common *.cc -> src/runtime/crt/microtvm_rpc_common"
- "src/runtime/crt/microtvm_rpc_server *.cc -> src/runtime/crt/microtvm_rpc_server"
- "src/runtime/minrpc *.h -> src/runtime/minrpc"
- "src/support generic_arena.h -> src/support"
- "src/support ssize.h -> src/support"
- "src/runtime/crt crt_config-template.h -> template"
- )
-
- set(standalone_crt_base "${CMAKE_CURRENT_BINARY_DIR}/standalone_crt")
-
- foreach(job_spec IN LISTS CRT_FILE_COPY_JOBS)
- string(REPLACE " " ";" job_spec "${job_spec}")
- list(LENGTH job_spec job_spec_length)
- math(EXPR job_spec_length_mod "${job_spec_length} % 3")
- if(NOT "${job_spec_length_mod}" EQUAL 1)
- message(FATAL_ERROR "CRT copy job spec list length is ${job_spec_length}; parsed job spec is ${job_spec}")
- endif()
- math(EXPR job_spec_stop "${job_spec_length} - 3")
-
- list(GET job_spec 0 job_src_base)
- set(job_src_base "${CMAKE_CURRENT_SOURCE_DIR}/${job_src_base}")
- foreach(copy_pattern_index RANGE 1 "${job_spec_stop}" 3)
- list(GET job_spec ${copy_pattern_index} copy_pattern)
- math(EXPR copy_dest_index "${copy_pattern_index} + 2")
- list(GET job_spec ${copy_dest_index} copy_dest)
-
- tvm_file_glob(GLOB_RECURSE copy_files
- RELATIVE "${job_src_base}"
- "${job_src_base}/${copy_pattern}")
- list(LENGTH copy_files copy_files_length)
- if("${copy_files_length}" EQUAL 0)
- message(FATAL_ERROR "CRT copy job matched 0 files: ${job_src_base}/${copy_pattern} -> ${copy_dest}")
- endif()
- foreach(copy_src IN LISTS copy_files)
- get_filename_component(dest_path "${standalone_crt_base}/${copy_dest}/${copy_src}" ABSOLUTE)
- tvm_micro_add_copy_file(host_isolated_build_deps ${job_src_base}/${copy_src} ${dest_path})
- endforeach()
- endforeach()
- endforeach()
+ set(CRT_LIBRARY_NAME host_standalone_crt_${CRT_LIBRARY})
+ set(CRT_LIBRARY_SOURCES "")
- add_custom_target(standalone_crt DEPENDS ${host_isolated_build_deps})
+ foreach(FILE_NAME IN LISTS ARGN)
+ list(APPEND CRT_LIBRARY_SOURCES ${FILE_NAME})
+ endforeach()
- get_filename_component(host_build_dir_abspath "${CMAKE_CURRENT_BINARY_DIR}/host_standalone_crt" ABSOLUTE)
+ add_library(${CRT_LIBRARY_NAME}
+ STATIC
+ ${CRT_LIBRARY_SOURCES})
- if(${VERBOSE})
- set(make_quiet QUIET=)
- else(${VERBOSE})
- set(make_quiet )
- endif(${VERBOSE})
+ # add this library to the list of CRT libraries
+ set(CRT_LIBRARIES ${CRT_LIBRARIES} ${CRT_LIBRARY_NAME} PARENT_SCOPE)
- list(APPEND crt_libraries memory graph_executor microtvm_rpc_server microtvm_rpc_common common) # NOTE: listed in link order.
- foreach(crt_lib_name IN LISTS crt_libraries)
- list(APPEND crt_library_paths "host_standalone_crt/lib${crt_lib_name}.a")
- endforeach()
+ target_include_directories(${CRT_LIBRARY_NAME}
+ PUBLIC
+ "${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/micro/"
+ "${STANDALONE_CRT_BASE}/include")
- set(make_common_args
- "CRT_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/micro/crt_config.h"
- "BUILD_DIR=${host_build_dir_abspath}"
- "EXTRA_CFLAGS=-fPIC"
- "EXTRA_CXXFLAGS=-fPIC"
- "EXTRA_LDFLAGS=-fPIC"
- "${make_quiet}")
-
- add_custom_command(
- OUTPUT ${crt_library_paths}
- COMMAND make ARGS ${make_common_args} clean
- COMMAND make ARGS ${make_common_args} all
- WORKING_DIRECTORY "${standalone_crt_base}"
- DEPENDS standalone_crt ${host_isolated_build_deps})
-
- add_custom_target(host_standalone_crt DEPENDS ${crt_library_paths})
-
- foreach(crt_lib IN LISTS crt_libraries)
- set(cmake_crt_lib_name host_standalone_crt_${crt_lib})
- list(APPEND cmake_crt_libraries ${cmake_crt_lib_name})
- add_library(${cmake_crt_lib_name} STATIC IMPORTED GLOBAL)
- set(cmake_crt_lib_path "${CMAKE_CURRENT_BINARY_DIR}/host_standalone_crt/lib${crt_lib}.a")
- add_dependencies(${cmake_crt_lib_name} host_standalone_crt "${cmake_crt_lib_path}")
- set_target_properties(${cmake_crt_lib_name} PROPERTIES
- IMPORTED_LOCATION "${cmake_crt_lib_path}"
- IMPORTED_OBJECTS "${cmake_crt_lib_path}"
- PUBLIC_HEADER "${crt_headers}")
- endforeach()
+ set_target_properties(${CRT_LIBRARY_NAME}
+ PROPERTIES
+ ARCHIVE_OUTPUT_DIRECTORY ${STANDALONE_CRT_BASE}/build
+ POSITION_INDEPENDENT_CODE ON)
- # Create the `crttest` target if we can find GTest. If not, we create dummy
- # targets that give the user an informative error message.
- if(GTEST_FOUND)
- tvm_file_glob(GLOB TEST_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/tests/crt/*.cc)
- add_executable(crttest ${TEST_SRCS})
- target_include_directories(crttest SYSTEM PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/standalone_crt/include ${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/micro)
- target_link_libraries(crttest PRIVATE ${cmake_crt_libraries} GTest::GTest GTest::Main pthread dl)
- set_target_properties(crttest PROPERTIES EXCLUDE_FROM_ALL 1)
- set_target_properties(crttest PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
- gtest_discover_tests(crttest)
- endif()
+ # make these libraries dependent on standalone_crt which depends on host_isolated_build_deps to avoid
+ # race with the file copy jobs
+ add_dependencies(${CRT_LIBRARY_NAME} standalone_crt)
endfunction()
- tvm_crt_define_targets()
+ message(STATUS "Build standalone CRT for microTVM")
+
+ # Build an isolated build directory, separate from the TVM tree.
+ list(APPEND CRT_FILE_COPY_JOBS
+ "3rdparty/libcrc/include *.h -> include"
+ "3rdparty/libcrc/src crcccitt.c -> src/runtime/crt/microtvm_rpc_common"
+ "3rdparty/libcrc/tab gentab_ccitt.inc -> src/runtime/crt/tab"
+ "3rdparty/dlpack/include *.h -> include"
+ "3rdparty/dmlc-core/include *.h -> include"
+ "include/tvm/runtime c_*_api.h -> include/tvm/runtime"
+ "include/tvm/runtime metadata_types.h -> include/tvm/runtime"
+ "include/tvm/runtime/crt *.h -> include/tvm/runtime/crt"
+ "src/runtime/crt Makefile -> ."
+ "src/runtime/crt/include *.h -> include"
+ "src/runtime/crt/aot_executor *.c -> src/runtime/crt/aot_executor"
+ "src/runtime/crt/aot_executor_module *.c -> src/runtime/crt/aot_executor_module"
+ "src/runtime/crt/common *.c -> src/runtime/crt/common"
+ "src/runtime/crt/graph_executor *.c -> src/runtime/crt/graph_executor"
+ "src/runtime/crt/graph_executor_module *.c -> src/runtime/crt/graph_executor_module"
+ "src/runtime/crt/host *.cc -> template/host"
+ "src/runtime/crt/host *.py -> template/host"
+ "src/runtime/crt/host Makefile.template -> template/host"
+ "src/runtime/crt/memory *.c -> src/runtime/crt/memory"
+ "src/runtime/crt/microtvm_rpc_common *.cc -> src/runtime/crt/microtvm_rpc_common"
+ "src/runtime/crt/microtvm_rpc_server *.cc -> src/runtime/crt/microtvm_rpc_server"
+ "src/runtime/minrpc *.h -> src/runtime/minrpc"
+ "src/support generic_arena.h -> src/support"
+ "src/support ssize.h -> src/support"
+ "src/runtime/crt crt_config-template.h -> template"
+ )
+
+ set(STANDALONE_CRT_BASE "${CMAKE_CURRENT_BINARY_DIR}/standalone_crt")
+
+ foreach(job_spec IN LISTS CRT_FILE_COPY_JOBS)
+ string(REPLACE " " ";" job_spec "${job_spec}")
+ list(LENGTH job_spec job_spec_length)
+ math(EXPR job_spec_length_mod "${job_spec_length} % 3")
+ if(NOT "${job_spec_length_mod}" EQUAL 1)
+ message(FATAL_ERROR "CRT copy job spec list length is ${job_spec_length}; parsed job spec is ${job_spec}")
+ endif()
+ math(EXPR job_spec_stop "${job_spec_length} - 3")
+
+ list(GET job_spec 0 job_src_base)
+ set(job_src_base "${CMAKE_CURRENT_SOURCE_DIR}/${job_src_base}")
+ foreach(copy_pattern_index RANGE 1 "${job_spec_stop}" 3)
+ list(GET job_spec ${copy_pattern_index} copy_pattern)
+ math(EXPR copy_dest_index "${copy_pattern_index} + 2")
+ list(GET job_spec ${copy_dest_index} copy_dest)
+
+ tvm_file_glob(GLOB_RECURSE copy_files
+ RELATIVE "${job_src_base}"
+ "${job_src_base}/${copy_pattern}")
+ list(LENGTH copy_files copy_files_length)
+ if("${copy_files_length}" EQUAL 0)
+ message(FATAL_ERROR "CRT copy job matched 0 files: ${job_src_base}/${copy_pattern} -> ${copy_dest}")
+ endif()
+ foreach(copy_src IN LISTS copy_files)
+ get_filename_component(dest_path "${STANDALONE_CRT_BASE}/${copy_dest}/${copy_src}" ABSOLUTE)
+ tvm_micro_add_copy_file(host_isolated_build_deps ${job_src_base}/${copy_src} ${dest_path})
+ endforeach()
+ endforeach()
+ endforeach()
+
+ add_custom_target(standalone_crt DEPENDS ${host_isolated_build_deps})
+
+ get_filename_component(host_build_dir_abspath "${CMAKE_CURRENT_BINARY_DIR}/host_standalone_crt" ABSOLUTE)
Review Comment:
remove, unused
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] leandron commented on pull request #13600: [microTVM] Build standalone_crt with cmake instead of makefile
Posted by GitBox <gi...@apache.org>.
leandron commented on PR #13600:
URL: https://github.com/apache/tvm/pull/13600#issuecomment-1351731456
> @leandron ok, it looks like it's only copying the standalone_crt directory into the wheel, I've updated my PR to not put the library binaries in the standalone_crt directory (matching the current TVM main), all the other files should be the same as I didn't change the standalone_crt file copy code.
thanks @alanmacd
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] areusch commented on pull request #13600: [microTVM] Build standalone_crt with cmake instead of makefile
Posted by GitBox <gi...@apache.org>.
areusch commented on PR #13600:
URL: https://github.com/apache/tvm/pull/13600#issuecomment-1370323637
@leandron can you explicit approve if you're good w/ this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] alanmacd commented on a diff in pull request #13600: [microTVM] Build standalone_crt with cmake instead of makefile
Posted by GitBox <gi...@apache.org>.
alanmacd commented on code in PR #13600:
URL: https://github.com/apache/tvm/pull/13600#discussion_r1061038650
##########
cmake/modules/StandaloneCrt.cmake:
##########
@@ -40,129 +40,147 @@ if(MSVC)
else()
Review Comment:
done, thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] alanmacd commented on a diff in pull request #13600: [microTVM] Build standalone_crt with cmake instead of makefile
Posted by GitBox <gi...@apache.org>.
alanmacd commented on code in PR #13600:
URL: https://github.com/apache/tvm/pull/13600#discussion_r1047825499
##########
cmake/modules/StandaloneCrt.cmake:
##########
@@ -40,129 +40,154 @@ if(MSVC)
else()
- message(STATUS "Build standalone CRT for microTVM")
+ function(create_crt_library CRT_LIBRARY)
- function(tvm_crt_define_targets)
- # Build an isolated build directory, separate from the TVM tree.
- list(APPEND CRT_FILE_COPY_JOBS
- "3rdparty/libcrc/include *.h -> include"
- "3rdparty/libcrc/src crcccitt.c -> src/runtime/crt/microtvm_rpc_common"
- "3rdparty/libcrc/tab gentab_ccitt.inc -> src/runtime/crt/tab"
- "3rdparty/dlpack/include *.h -> include"
- "3rdparty/dmlc-core/include *.h -> include"
- "include/tvm/runtime c_*_api.h -> include/tvm/runtime"
- "include/tvm/runtime metadata_types.h -> include/tvm/runtime"
- "include/tvm/runtime/crt *.h -> include/tvm/runtime/crt"
- "src/runtime/crt Makefile -> ."
- "src/runtime/crt/include *.h -> include"
- "src/runtime/crt/aot_executor *.c -> src/runtime/crt/aot_executor"
- "src/runtime/crt/aot_executor_module *.c -> src/runtime/crt/aot_executor_module"
- "src/runtime/crt/common *.c -> src/runtime/crt/common"
- "src/runtime/crt/graph_executor *.c -> src/runtime/crt/graph_executor"
- "src/runtime/crt/graph_executor_module *.c -> src/runtime/crt/graph_executor_module"
- "src/runtime/crt/host *.cc -> template/host"
- "src/runtime/crt/host *.py -> template/host"
- "src/runtime/crt/host Makefile.template -> template/host"
- "src/runtime/crt/memory *.c -> src/runtime/crt/memory"
- "src/runtime/crt/microtvm_rpc_common *.cc -> src/runtime/crt/microtvm_rpc_common"
- "src/runtime/crt/microtvm_rpc_server *.cc -> src/runtime/crt/microtvm_rpc_server"
- "src/runtime/minrpc *.h -> src/runtime/minrpc"
- "src/support generic_arena.h -> src/support"
- "src/support ssize.h -> src/support"
- "src/runtime/crt crt_config-template.h -> template"
- )
-
- set(standalone_crt_base "${CMAKE_CURRENT_BINARY_DIR}/standalone_crt")
-
- foreach(job_spec IN LISTS CRT_FILE_COPY_JOBS)
- string(REPLACE " " ";" job_spec "${job_spec}")
- list(LENGTH job_spec job_spec_length)
- math(EXPR job_spec_length_mod "${job_spec_length} % 3")
- if(NOT "${job_spec_length_mod}" EQUAL 1)
- message(FATAL_ERROR "CRT copy job spec list length is ${job_spec_length}; parsed job spec is ${job_spec}")
- endif()
- math(EXPR job_spec_stop "${job_spec_length} - 3")
-
- list(GET job_spec 0 job_src_base)
- set(job_src_base "${CMAKE_CURRENT_SOURCE_DIR}/${job_src_base}")
- foreach(copy_pattern_index RANGE 1 "${job_spec_stop}" 3)
- list(GET job_spec ${copy_pattern_index} copy_pattern)
- math(EXPR copy_dest_index "${copy_pattern_index} + 2")
- list(GET job_spec ${copy_dest_index} copy_dest)
-
- tvm_file_glob(GLOB_RECURSE copy_files
- RELATIVE "${job_src_base}"
- "${job_src_base}/${copy_pattern}")
- list(LENGTH copy_files copy_files_length)
- if("${copy_files_length}" EQUAL 0)
- message(FATAL_ERROR "CRT copy job matched 0 files: ${job_src_base}/${copy_pattern} -> ${copy_dest}")
- endif()
- foreach(copy_src IN LISTS copy_files)
- get_filename_component(dest_path "${standalone_crt_base}/${copy_dest}/${copy_src}" ABSOLUTE)
- tvm_micro_add_copy_file(host_isolated_build_deps ${job_src_base}/${copy_src} ${dest_path})
- endforeach()
- endforeach()
- endforeach()
+ set(CRT_LIBRARY_NAME host_standalone_crt_${CRT_LIBRARY})
+ set(CRT_LIBRARY_SOURCES "")
- add_custom_target(standalone_crt DEPENDS ${host_isolated_build_deps})
+ foreach(FILE_NAME IN LISTS ARGN)
+ list(APPEND CRT_LIBRARY_SOURCES ${FILE_NAME})
+ endforeach()
- get_filename_component(host_build_dir_abspath "${CMAKE_CURRENT_BINARY_DIR}/host_standalone_crt" ABSOLUTE)
+ add_library(${CRT_LIBRARY_NAME}
+ STATIC
+ ${CRT_LIBRARY_SOURCES})
- if(${VERBOSE})
- set(make_quiet QUIET=)
- else(${VERBOSE})
- set(make_quiet )
- endif(${VERBOSE})
+ # add this library to the list of CRT libraries
+ set(CRT_LIBRARIES ${CRT_LIBRARIES} ${CRT_LIBRARY_NAME} PARENT_SCOPE)
- list(APPEND crt_libraries memory graph_executor microtvm_rpc_server microtvm_rpc_common common) # NOTE: listed in link order.
- foreach(crt_lib_name IN LISTS crt_libraries)
- list(APPEND crt_library_paths "host_standalone_crt/lib${crt_lib_name}.a")
- endforeach()
+ target_include_directories(${CRT_LIBRARY_NAME}
+ PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/micro/
Review Comment:
update to use standalone_crt dir
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] alanmacd commented on a diff in pull request #13600: [microTVM] Build standalone_crt with cmake instead of makefile
Posted by GitBox <gi...@apache.org>.
alanmacd commented on code in PR #13600:
URL: https://github.com/apache/tvm/pull/13600#discussion_r1048838361
##########
cmake/modules/StandaloneCrt.cmake:
##########
@@ -40,129 +40,154 @@ if(MSVC)
else()
- message(STATUS "Build standalone CRT for microTVM")
+ function(create_crt_library CRT_LIBRARY)
- function(tvm_crt_define_targets)
- # Build an isolated build directory, separate from the TVM tree.
- list(APPEND CRT_FILE_COPY_JOBS
- "3rdparty/libcrc/include *.h -> include"
- "3rdparty/libcrc/src crcccitt.c -> src/runtime/crt/microtvm_rpc_common"
- "3rdparty/libcrc/tab gentab_ccitt.inc -> src/runtime/crt/tab"
- "3rdparty/dlpack/include *.h -> include"
- "3rdparty/dmlc-core/include *.h -> include"
- "include/tvm/runtime c_*_api.h -> include/tvm/runtime"
- "include/tvm/runtime metadata_types.h -> include/tvm/runtime"
- "include/tvm/runtime/crt *.h -> include/tvm/runtime/crt"
- "src/runtime/crt Makefile -> ."
- "src/runtime/crt/include *.h -> include"
- "src/runtime/crt/aot_executor *.c -> src/runtime/crt/aot_executor"
- "src/runtime/crt/aot_executor_module *.c -> src/runtime/crt/aot_executor_module"
- "src/runtime/crt/common *.c -> src/runtime/crt/common"
- "src/runtime/crt/graph_executor *.c -> src/runtime/crt/graph_executor"
- "src/runtime/crt/graph_executor_module *.c -> src/runtime/crt/graph_executor_module"
- "src/runtime/crt/host *.cc -> template/host"
- "src/runtime/crt/host *.py -> template/host"
- "src/runtime/crt/host Makefile.template -> template/host"
- "src/runtime/crt/memory *.c -> src/runtime/crt/memory"
- "src/runtime/crt/microtvm_rpc_common *.cc -> src/runtime/crt/microtvm_rpc_common"
- "src/runtime/crt/microtvm_rpc_server *.cc -> src/runtime/crt/microtvm_rpc_server"
- "src/runtime/minrpc *.h -> src/runtime/minrpc"
- "src/support generic_arena.h -> src/support"
- "src/support ssize.h -> src/support"
- "src/runtime/crt crt_config-template.h -> template"
- )
-
- set(standalone_crt_base "${CMAKE_CURRENT_BINARY_DIR}/standalone_crt")
-
- foreach(job_spec IN LISTS CRT_FILE_COPY_JOBS)
- string(REPLACE " " ";" job_spec "${job_spec}")
- list(LENGTH job_spec job_spec_length)
- math(EXPR job_spec_length_mod "${job_spec_length} % 3")
- if(NOT "${job_spec_length_mod}" EQUAL 1)
- message(FATAL_ERROR "CRT copy job spec list length is ${job_spec_length}; parsed job spec is ${job_spec}")
- endif()
- math(EXPR job_spec_stop "${job_spec_length} - 3")
-
- list(GET job_spec 0 job_src_base)
- set(job_src_base "${CMAKE_CURRENT_SOURCE_DIR}/${job_src_base}")
- foreach(copy_pattern_index RANGE 1 "${job_spec_stop}" 3)
- list(GET job_spec ${copy_pattern_index} copy_pattern)
- math(EXPR copy_dest_index "${copy_pattern_index} + 2")
- list(GET job_spec ${copy_dest_index} copy_dest)
-
- tvm_file_glob(GLOB_RECURSE copy_files
- RELATIVE "${job_src_base}"
- "${job_src_base}/${copy_pattern}")
- list(LENGTH copy_files copy_files_length)
- if("${copy_files_length}" EQUAL 0)
- message(FATAL_ERROR "CRT copy job matched 0 files: ${job_src_base}/${copy_pattern} -> ${copy_dest}")
- endif()
- foreach(copy_src IN LISTS copy_files)
- get_filename_component(dest_path "${standalone_crt_base}/${copy_dest}/${copy_src}" ABSOLUTE)
- tvm_micro_add_copy_file(host_isolated_build_deps ${job_src_base}/${copy_src} ${dest_path})
- endforeach()
- endforeach()
- endforeach()
+ set(CRT_LIBRARY_NAME host_standalone_crt_${CRT_LIBRARY})
+ set(CRT_LIBRARY_SOURCES "")
- add_custom_target(standalone_crt DEPENDS ${host_isolated_build_deps})
+ foreach(FILE_NAME IN LISTS ARGN)
+ list(APPEND CRT_LIBRARY_SOURCES ${FILE_NAME})
+ endforeach()
- get_filename_component(host_build_dir_abspath "${CMAKE_CURRENT_BINARY_DIR}/host_standalone_crt" ABSOLUTE)
+ add_library(${CRT_LIBRARY_NAME}
+ STATIC
+ ${CRT_LIBRARY_SOURCES})
- if(${VERBOSE})
- set(make_quiet QUIET=)
- else(${VERBOSE})
- set(make_quiet )
- endif(${VERBOSE})
+ # add this library to the list of CRT libraries
+ set(CRT_LIBRARIES ${CRT_LIBRARIES} ${CRT_LIBRARY_NAME} PARENT_SCOPE)
- list(APPEND crt_libraries memory graph_executor microtvm_rpc_server microtvm_rpc_common common) # NOTE: listed in link order.
- foreach(crt_lib_name IN LISTS crt_libraries)
- list(APPEND crt_library_paths "host_standalone_crt/lib${crt_lib_name}.a")
- endforeach()
+ target_include_directories(${CRT_LIBRARY_NAME}
+ PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/micro/
Review Comment:
actually, this is only for crt_config.h so it's the same as what the previous Makefile did
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] alanmacd commented on a diff in pull request #13600: [microTVM] Build standalone_crt with cmake instead of makefile
Posted by GitBox <gi...@apache.org>.
alanmacd commented on code in PR #13600:
URL: https://github.com/apache/tvm/pull/13600#discussion_r1046433141
##########
cmake/modules/StandaloneCrt.cmake:
##########
@@ -40,129 +40,143 @@ if(MSVC)
else()
- message(STATUS "Build standalone CRT for microTVM")
-
- function(tvm_crt_define_targets)
- # Build an isolated build directory, separate from the TVM tree.
- list(APPEND CRT_FILE_COPY_JOBS
- "3rdparty/libcrc/include *.h -> include"
- "3rdparty/libcrc/src crcccitt.c -> src/runtime/crt/microtvm_rpc_common"
- "3rdparty/libcrc/tab gentab_ccitt.inc -> src/runtime/crt/tab"
- "3rdparty/dlpack/include *.h -> include"
- "3rdparty/dmlc-core/include *.h -> include"
- "include/tvm/runtime c_*_api.h -> include/tvm/runtime"
- "include/tvm/runtime metadata_types.h -> include/tvm/runtime"
- "include/tvm/runtime/crt *.h -> include/tvm/runtime/crt"
- "src/runtime/crt Makefile -> ."
- "src/runtime/crt/include *.h -> include"
- "src/runtime/crt/aot_executor *.c -> src/runtime/crt/aot_executor"
- "src/runtime/crt/aot_executor_module *.c -> src/runtime/crt/aot_executor_module"
- "src/runtime/crt/common *.c -> src/runtime/crt/common"
- "src/runtime/crt/graph_executor *.c -> src/runtime/crt/graph_executor"
- "src/runtime/crt/graph_executor_module *.c -> src/runtime/crt/graph_executor_module"
- "src/runtime/crt/host *.cc -> template/host"
- "src/runtime/crt/host *.py -> template/host"
- "src/runtime/crt/host Makefile.template -> template/host"
- "src/runtime/crt/memory *.c -> src/runtime/crt/memory"
- "src/runtime/crt/microtvm_rpc_common *.cc -> src/runtime/crt/microtvm_rpc_common"
- "src/runtime/crt/microtvm_rpc_server *.cc -> src/runtime/crt/microtvm_rpc_server"
- "src/runtime/minrpc *.h -> src/runtime/minrpc"
- "src/support generic_arena.h -> src/support"
- "src/support ssize.h -> src/support"
- "src/runtime/crt crt_config-template.h -> template"
- )
-
- set(standalone_crt_base "${CMAKE_CURRENT_BINARY_DIR}/standalone_crt")
-
- foreach(job_spec IN LISTS CRT_FILE_COPY_JOBS)
- string(REPLACE " " ";" job_spec "${job_spec}")
- list(LENGTH job_spec job_spec_length)
- math(EXPR job_spec_length_mod "${job_spec_length} % 3")
- if(NOT "${job_spec_length_mod}" EQUAL 1)
- message(FATAL_ERROR "CRT copy job spec list length is ${job_spec_length}; parsed job spec is ${job_spec}")
- endif()
- math(EXPR job_spec_stop "${job_spec_length} - 3")
-
- list(GET job_spec 0 job_src_base)
- set(job_src_base "${CMAKE_CURRENT_SOURCE_DIR}/${job_src_base}")
- foreach(copy_pattern_index RANGE 1 "${job_spec_stop}" 3)
- list(GET job_spec ${copy_pattern_index} copy_pattern)
- math(EXPR copy_dest_index "${copy_pattern_index} + 2")
- list(GET job_spec ${copy_dest_index} copy_dest)
-
- tvm_file_glob(GLOB_RECURSE copy_files
- RELATIVE "${job_src_base}"
- "${job_src_base}/${copy_pattern}")
- list(LENGTH copy_files copy_files_length)
- if("${copy_files_length}" EQUAL 0)
- message(FATAL_ERROR "CRT copy job matched 0 files: ${job_src_base}/${copy_pattern} -> ${copy_dest}")
- endif()
- foreach(copy_src IN LISTS copy_files)
- get_filename_component(dest_path "${standalone_crt_base}/${copy_dest}/${copy_src}" ABSOLUTE)
- tvm_micro_add_copy_file(host_isolated_build_deps ${job_src_base}/${copy_src} ${dest_path})
- endforeach()
- endforeach()
+ function(create_crt_library CRT_LIBRARY_NAME)
+ set(cmake_crt_lib_name host_standalone_crt_${CRT_LIBRARY_NAME})
+
+ set(CRT_LIBRARY_SOURCES "")
+ foreach(FILE_NAME IN LISTS ARGN)
+ list(APPEND CRT_LIBRARY_SOURCES ${FILE_NAME})
endforeach()
- add_custom_target(standalone_crt DEPENDS ${host_isolated_build_deps})
+ add_library(${cmake_crt_lib_name}
+ STATIC
+ ${CRT_LIBRARY_SOURCES})
- get_filename_component(host_build_dir_abspath "${CMAKE_CURRENT_BINARY_DIR}/host_standalone_crt" ABSOLUTE)
+ set(CMAKE_CRT_LIBRARIES ${CMAKE_CRT_LIBRARIES} ${cmake_crt_lib_name} PARENT_SCOPE)
Review Comment:
add comment about what this does, remove some of the newlines
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] alanmacd commented on pull request #13600: [microTVM] Build standalone_crt with cmake instead of makefile
Posted by GitBox <gi...@apache.org>.
alanmacd commented on PR #13600:
URL: https://github.com/apache/tvm/pull/13600#issuecomment-1349273860
> The static files are needed so that users can integrate embedded projects only with the TVM installed from the package, rather than requiring the package+cloning `apache/tvm` repo.
>
> https://github.com/apache/tvm/blob/b7015bb388a1d8f84b89e57709831e74c032d941/python/setup.py#L59-L64
Thanks @leandron I will verify that files are placed in the same locations as previous done with the makefile version (I may have stashed the library files in slightly different locations)
Is there a specific way you typically invoke setup.py to exercise this feature or an example command that I should use to test?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] alanmacd commented on a diff in pull request #13600: [microTVM] Build standalone_crt with cmake instead of makefile
Posted by GitBox <gi...@apache.org>.
alanmacd commented on code in PR #13600:
URL: https://github.com/apache/tvm/pull/13600#discussion_r1046610268
##########
cmake/modules/StandaloneCrt.cmake:
##########
@@ -40,129 +40,147 @@ if(MSVC)
else()
- message(STATUS "Build standalone CRT for microTVM")
+ function(create_crt_library CRT_LIBRARY)
- function(tvm_crt_define_targets)
- # Build an isolated build directory, separate from the TVM tree.
- list(APPEND CRT_FILE_COPY_JOBS
- "3rdparty/libcrc/include *.h -> include"
- "3rdparty/libcrc/src crcccitt.c -> src/runtime/crt/microtvm_rpc_common"
- "3rdparty/libcrc/tab gentab_ccitt.inc -> src/runtime/crt/tab"
- "3rdparty/dlpack/include *.h -> include"
- "3rdparty/dmlc-core/include *.h -> include"
- "include/tvm/runtime c_*_api.h -> include/tvm/runtime"
- "include/tvm/runtime metadata_types.h -> include/tvm/runtime"
- "include/tvm/runtime/crt *.h -> include/tvm/runtime/crt"
- "src/runtime/crt Makefile -> ."
- "src/runtime/crt/include *.h -> include"
- "src/runtime/crt/aot_executor *.c -> src/runtime/crt/aot_executor"
- "src/runtime/crt/aot_executor_module *.c -> src/runtime/crt/aot_executor_module"
- "src/runtime/crt/common *.c -> src/runtime/crt/common"
- "src/runtime/crt/graph_executor *.c -> src/runtime/crt/graph_executor"
- "src/runtime/crt/graph_executor_module *.c -> src/runtime/crt/graph_executor_module"
- "src/runtime/crt/host *.cc -> template/host"
- "src/runtime/crt/host *.py -> template/host"
- "src/runtime/crt/host Makefile.template -> template/host"
- "src/runtime/crt/memory *.c -> src/runtime/crt/memory"
- "src/runtime/crt/microtvm_rpc_common *.cc -> src/runtime/crt/microtvm_rpc_common"
- "src/runtime/crt/microtvm_rpc_server *.cc -> src/runtime/crt/microtvm_rpc_server"
- "src/runtime/minrpc *.h -> src/runtime/minrpc"
- "src/support generic_arena.h -> src/support"
- "src/support ssize.h -> src/support"
- "src/runtime/crt crt_config-template.h -> template"
- )
-
- set(standalone_crt_base "${CMAKE_CURRENT_BINARY_DIR}/standalone_crt")
-
- foreach(job_spec IN LISTS CRT_FILE_COPY_JOBS)
- string(REPLACE " " ";" job_spec "${job_spec}")
- list(LENGTH job_spec job_spec_length)
- math(EXPR job_spec_length_mod "${job_spec_length} % 3")
- if(NOT "${job_spec_length_mod}" EQUAL 1)
- message(FATAL_ERROR "CRT copy job spec list length is ${job_spec_length}; parsed job spec is ${job_spec}")
- endif()
- math(EXPR job_spec_stop "${job_spec_length} - 3")
-
- list(GET job_spec 0 job_src_base)
- set(job_src_base "${CMAKE_CURRENT_SOURCE_DIR}/${job_src_base}")
- foreach(copy_pattern_index RANGE 1 "${job_spec_stop}" 3)
- list(GET job_spec ${copy_pattern_index} copy_pattern)
- math(EXPR copy_dest_index "${copy_pattern_index} + 2")
- list(GET job_spec ${copy_dest_index} copy_dest)
-
- tvm_file_glob(GLOB_RECURSE copy_files
- RELATIVE "${job_src_base}"
- "${job_src_base}/${copy_pattern}")
- list(LENGTH copy_files copy_files_length)
- if("${copy_files_length}" EQUAL 0)
- message(FATAL_ERROR "CRT copy job matched 0 files: ${job_src_base}/${copy_pattern} -> ${copy_dest}")
- endif()
- foreach(copy_src IN LISTS copy_files)
- get_filename_component(dest_path "${standalone_crt_base}/${copy_dest}/${copy_src}" ABSOLUTE)
- tvm_micro_add_copy_file(host_isolated_build_deps ${job_src_base}/${copy_src} ${dest_path})
- endforeach()
- endforeach()
- endforeach()
+ set(CRT_LIBRARY_NAME host_standalone_crt_${CRT_LIBRARY})
+ set(CRT_LIBRARY_SOURCES "")
- add_custom_target(standalone_crt DEPENDS ${host_isolated_build_deps})
+ foreach(FILE_NAME IN LISTS ARGN)
+ list(APPEND CRT_LIBRARY_SOURCES ${FILE_NAME})
+ endforeach()
- get_filename_component(host_build_dir_abspath "${CMAKE_CURRENT_BINARY_DIR}/host_standalone_crt" ABSOLUTE)
+ add_library(${CRT_LIBRARY_NAME}
+ STATIC
+ ${CRT_LIBRARY_SOURCES})
- if(${VERBOSE})
- set(make_quiet QUIET=)
- else(${VERBOSE})
- set(make_quiet )
- endif(${VERBOSE})
+ # add this library to the list of CRT libraries
+ set(CRT_LIBRARIES ${CRT_LIBRARIES} ${CRT_LIBRARY_NAME} PARENT_SCOPE)
- list(APPEND crt_libraries memory graph_executor microtvm_rpc_server microtvm_rpc_common common) # NOTE: listed in link order.
- foreach(crt_lib_name IN LISTS crt_libraries)
- list(APPEND crt_library_paths "host_standalone_crt/lib${crt_lib_name}.a")
- endforeach()
+ target_include_directories(${CRT_LIBRARY_NAME}
+ PUBLIC
+ "${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/micro/"
+ "${STANDALONE_CRT_BASE}/include")
- set(make_common_args
- "CRT_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/micro/crt_config.h"
- "BUILD_DIR=${host_build_dir_abspath}"
- "EXTRA_CFLAGS=-fPIC"
- "EXTRA_CXXFLAGS=-fPIC"
- "EXTRA_LDFLAGS=-fPIC"
- "${make_quiet}")
-
- add_custom_command(
- OUTPUT ${crt_library_paths}
- COMMAND make ARGS ${make_common_args} clean
- COMMAND make ARGS ${make_common_args} all
- WORKING_DIRECTORY "${standalone_crt_base}"
- DEPENDS standalone_crt ${host_isolated_build_deps})
-
- add_custom_target(host_standalone_crt DEPENDS ${crt_library_paths})
-
- foreach(crt_lib IN LISTS crt_libraries)
- set(cmake_crt_lib_name host_standalone_crt_${crt_lib})
- list(APPEND cmake_crt_libraries ${cmake_crt_lib_name})
- add_library(${cmake_crt_lib_name} STATIC IMPORTED GLOBAL)
- set(cmake_crt_lib_path "${CMAKE_CURRENT_BINARY_DIR}/host_standalone_crt/lib${crt_lib}.a")
- add_dependencies(${cmake_crt_lib_name} host_standalone_crt "${cmake_crt_lib_path}")
- set_target_properties(${cmake_crt_lib_name} PROPERTIES
- IMPORTED_LOCATION "${cmake_crt_lib_path}"
- IMPORTED_OBJECTS "${cmake_crt_lib_path}"
- PUBLIC_HEADER "${crt_headers}")
- endforeach()
+ set_target_properties(${CRT_LIBRARY_NAME}
+ PROPERTIES
+ ARCHIVE_OUTPUT_DIRECTORY ${STANDALONE_CRT_BASE}/build
+ POSITION_INDEPENDENT_CODE ON)
- # Create the `crttest` target if we can find GTest. If not, we create dummy
- # targets that give the user an informative error message.
- if(GTEST_FOUND)
- tvm_file_glob(GLOB TEST_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/tests/crt/*.cc)
- add_executable(crttest ${TEST_SRCS})
- target_include_directories(crttest SYSTEM PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/standalone_crt/include ${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/micro)
- target_link_libraries(crttest PRIVATE ${cmake_crt_libraries} GTest::GTest GTest::Main pthread dl)
- set_target_properties(crttest PROPERTIES EXCLUDE_FROM_ALL 1)
- set_target_properties(crttest PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
- gtest_discover_tests(crttest)
- endif()
+ # make these libraries dependent on standalone_crt which depends on host_isolated_build_deps to avoid
+ # race with the file copy jobs
+ add_dependencies(${CRT_LIBRARY_NAME} standalone_crt)
endfunction()
- tvm_crt_define_targets()
+ message(STATUS "Build standalone CRT for microTVM")
+
+ # Build an isolated build directory, separate from the TVM tree.
+ list(APPEND CRT_FILE_COPY_JOBS
+ "3rdparty/libcrc/include *.h -> include"
+ "3rdparty/libcrc/src crcccitt.c -> src/runtime/crt/microtvm_rpc_common"
+ "3rdparty/libcrc/tab gentab_ccitt.inc -> src/runtime/crt/tab"
+ "3rdparty/dlpack/include *.h -> include"
+ "3rdparty/dmlc-core/include *.h -> include"
+ "include/tvm/runtime c_*_api.h -> include/tvm/runtime"
+ "include/tvm/runtime metadata_types.h -> include/tvm/runtime"
+ "include/tvm/runtime/crt *.h -> include/tvm/runtime/crt"
+ "src/runtime/crt Makefile -> ."
+ "src/runtime/crt/include *.h -> include"
+ "src/runtime/crt/aot_executor *.c -> src/runtime/crt/aot_executor"
+ "src/runtime/crt/aot_executor_module *.c -> src/runtime/crt/aot_executor_module"
+ "src/runtime/crt/common *.c -> src/runtime/crt/common"
+ "src/runtime/crt/graph_executor *.c -> src/runtime/crt/graph_executor"
+ "src/runtime/crt/graph_executor_module *.c -> src/runtime/crt/graph_executor_module"
+ "src/runtime/crt/host *.cc -> template/host"
+ "src/runtime/crt/host *.py -> template/host"
+ "src/runtime/crt/host Makefile.template -> template/host"
+ "src/runtime/crt/memory *.c -> src/runtime/crt/memory"
+ "src/runtime/crt/microtvm_rpc_common *.cc -> src/runtime/crt/microtvm_rpc_common"
+ "src/runtime/crt/microtvm_rpc_server *.cc -> src/runtime/crt/microtvm_rpc_server"
+ "src/runtime/minrpc *.h -> src/runtime/minrpc"
+ "src/support generic_arena.h -> src/support"
+ "src/support ssize.h -> src/support"
+ "src/runtime/crt crt_config-template.h -> template"
+ )
+
+ set(STANDALONE_CRT_BASE "${CMAKE_CURRENT_BINARY_DIR}/standalone_crt")
+
+ foreach(job_spec IN LISTS CRT_FILE_COPY_JOBS)
+ string(REPLACE " " ";" job_spec "${job_spec}")
+ list(LENGTH job_spec job_spec_length)
+ math(EXPR job_spec_length_mod "${job_spec_length} % 3")
+ if(NOT "${job_spec_length_mod}" EQUAL 1)
+ message(FATAL_ERROR "CRT copy job spec list length is ${job_spec_length}; parsed job spec is ${job_spec}")
+ endif()
+ math(EXPR job_spec_stop "${job_spec_length} - 3")
+
+ list(GET job_spec 0 job_src_base)
+ set(job_src_base "${CMAKE_CURRENT_SOURCE_DIR}/${job_src_base}")
+ foreach(copy_pattern_index RANGE 1 "${job_spec_stop}" 3)
+ list(GET job_spec ${copy_pattern_index} copy_pattern)
+ math(EXPR copy_dest_index "${copy_pattern_index} + 2")
+ list(GET job_spec ${copy_dest_index} copy_dest)
+
+ tvm_file_glob(GLOB_RECURSE copy_files
+ RELATIVE "${job_src_base}"
+ "${job_src_base}/${copy_pattern}")
+ list(LENGTH copy_files copy_files_length)
+ if("${copy_files_length}" EQUAL 0)
+ message(FATAL_ERROR "CRT copy job matched 0 files: ${job_src_base}/${copy_pattern} -> ${copy_dest}")
+ endif()
+ foreach(copy_src IN LISTS copy_files)
+ get_filename_component(dest_path "${STANDALONE_CRT_BASE}/${copy_dest}/${copy_src}" ABSOLUTE)
+ tvm_micro_add_copy_file(host_isolated_build_deps ${job_src_base}/${copy_src} ${dest_path})
+ endforeach()
+ endforeach()
+ endforeach()
+
+ add_custom_target(standalone_crt DEPENDS ${host_isolated_build_deps})
+
+ get_filename_component(host_build_dir_abspath "${CMAKE_CURRENT_BINARY_DIR}/host_standalone_crt" ABSOLUTE)
+
+ set(CRT_LIBRARIES "")
+ set(RUNTIME_CRT_SOURCE_DIR ${STANDALONE_CRT_BASE}/src/runtime/crt)
+
+ # these create_crt_library() targets are in link order and the common library needs to be last
+ create_crt_library(graph_executor
+ ${RUNTIME_CRT_SOURCE_DIR}/graph_executor/graph_executor.c
+ ${RUNTIME_CRT_SOURCE_DIR}/graph_executor/load_json.c)
+
+ create_crt_library(memory
+ ${RUNTIME_CRT_SOURCE_DIR}/memory/page_allocator.c
+ ${RUNTIME_CRT_SOURCE_DIR}/memory/stack_allocator.c)
+
+ create_crt_library(microtvm_rpc_common
+ ${RUNTIME_CRT_SOURCE_DIR}/microtvm_rpc_common/crcccitt.c
+ ${RUNTIME_CRT_SOURCE_DIR}/microtvm_rpc_common/frame_buffer.cc
+ ${RUNTIME_CRT_SOURCE_DIR}/microtvm_rpc_common/framing.cc
+ ${RUNTIME_CRT_SOURCE_DIR}/microtvm_rpc_common/session.cc
+ ${RUNTIME_CRT_SOURCE_DIR}/microtvm_rpc_common/write_stream.cc)
+
+ create_crt_library(microtvm_rpc_server
+ ${RUNTIME_CRT_SOURCE_DIR}/microtvm_rpc_server/rpc_server.cc)
+
+ create_crt_library(common
+ ${RUNTIME_CRT_SOURCE_DIR}/common/crt_backend_api.c
+ ${RUNTIME_CRT_SOURCE_DIR}/common/crt_runtime_api.c
+ ${RUNTIME_CRT_SOURCE_DIR}/common/func_registry.c
+ ${RUNTIME_CRT_SOURCE_DIR}/common/ndarray.c
+ ${RUNTIME_CRT_SOURCE_DIR}/common/packed_func.c)
+
Review Comment:
add additional libraries that are part of standalone_crt
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] areusch commented on a diff in pull request #13600: [microTVM] Build standalone_crt with cmake instead of makefile
Posted by GitBox <gi...@apache.org>.
areusch commented on code in PR #13600:
URL: https://github.com/apache/tvm/pull/13600#discussion_r1060967419
##########
cmake/modules/StandaloneCrt.cmake:
##########
@@ -40,129 +40,147 @@ if(MSVC)
else()
Review Comment:
want to add a TODO then?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] alanmacd commented on a diff in pull request #13600: [microTVM] Build standalone_crt with cmake instead of makefile
Posted by GitBox <gi...@apache.org>.
alanmacd commented on code in PR #13600:
URL: https://github.com/apache/tvm/pull/13600#discussion_r1046610486
##########
cmake/modules/StandaloneCrt.cmake:
##########
@@ -40,129 +40,147 @@ if(MSVC)
else()
Review Comment:
try removing MSVC conditional code
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] alanmacd commented on a diff in pull request #13600: [microTVM] Build standalone_crt with cmake instead of makefile
Posted by GitBox <gi...@apache.org>.
alanmacd commented on code in PR #13600:
URL: https://github.com/apache/tvm/pull/13600#discussion_r1046432873
##########
cmake/modules/StandaloneCrt.cmake:
##########
@@ -40,129 +40,143 @@ if(MSVC)
else()
- message(STATUS "Build standalone CRT for microTVM")
-
- function(tvm_crt_define_targets)
- # Build an isolated build directory, separate from the TVM tree.
- list(APPEND CRT_FILE_COPY_JOBS
- "3rdparty/libcrc/include *.h -> include"
- "3rdparty/libcrc/src crcccitt.c -> src/runtime/crt/microtvm_rpc_common"
- "3rdparty/libcrc/tab gentab_ccitt.inc -> src/runtime/crt/tab"
- "3rdparty/dlpack/include *.h -> include"
- "3rdparty/dmlc-core/include *.h -> include"
- "include/tvm/runtime c_*_api.h -> include/tvm/runtime"
- "include/tvm/runtime metadata_types.h -> include/tvm/runtime"
- "include/tvm/runtime/crt *.h -> include/tvm/runtime/crt"
- "src/runtime/crt Makefile -> ."
- "src/runtime/crt/include *.h -> include"
- "src/runtime/crt/aot_executor *.c -> src/runtime/crt/aot_executor"
- "src/runtime/crt/aot_executor_module *.c -> src/runtime/crt/aot_executor_module"
- "src/runtime/crt/common *.c -> src/runtime/crt/common"
- "src/runtime/crt/graph_executor *.c -> src/runtime/crt/graph_executor"
- "src/runtime/crt/graph_executor_module *.c -> src/runtime/crt/graph_executor_module"
- "src/runtime/crt/host *.cc -> template/host"
- "src/runtime/crt/host *.py -> template/host"
- "src/runtime/crt/host Makefile.template -> template/host"
- "src/runtime/crt/memory *.c -> src/runtime/crt/memory"
- "src/runtime/crt/microtvm_rpc_common *.cc -> src/runtime/crt/microtvm_rpc_common"
- "src/runtime/crt/microtvm_rpc_server *.cc -> src/runtime/crt/microtvm_rpc_server"
- "src/runtime/minrpc *.h -> src/runtime/minrpc"
- "src/support generic_arena.h -> src/support"
- "src/support ssize.h -> src/support"
- "src/runtime/crt crt_config-template.h -> template"
- )
-
- set(standalone_crt_base "${CMAKE_CURRENT_BINARY_DIR}/standalone_crt")
-
- foreach(job_spec IN LISTS CRT_FILE_COPY_JOBS)
- string(REPLACE " " ";" job_spec "${job_spec}")
- list(LENGTH job_spec job_spec_length)
- math(EXPR job_spec_length_mod "${job_spec_length} % 3")
- if(NOT "${job_spec_length_mod}" EQUAL 1)
- message(FATAL_ERROR "CRT copy job spec list length is ${job_spec_length}; parsed job spec is ${job_spec}")
- endif()
- math(EXPR job_spec_stop "${job_spec_length} - 3")
-
- list(GET job_spec 0 job_src_base)
- set(job_src_base "${CMAKE_CURRENT_SOURCE_DIR}/${job_src_base}")
- foreach(copy_pattern_index RANGE 1 "${job_spec_stop}" 3)
- list(GET job_spec ${copy_pattern_index} copy_pattern)
- math(EXPR copy_dest_index "${copy_pattern_index} + 2")
- list(GET job_spec ${copy_dest_index} copy_dest)
-
- tvm_file_glob(GLOB_RECURSE copy_files
- RELATIVE "${job_src_base}"
- "${job_src_base}/${copy_pattern}")
- list(LENGTH copy_files copy_files_length)
- if("${copy_files_length}" EQUAL 0)
- message(FATAL_ERROR "CRT copy job matched 0 files: ${job_src_base}/${copy_pattern} -> ${copy_dest}")
- endif()
- foreach(copy_src IN LISTS copy_files)
- get_filename_component(dest_path "${standalone_crt_base}/${copy_dest}/${copy_src}" ABSOLUTE)
- tvm_micro_add_copy_file(host_isolated_build_deps ${job_src_base}/${copy_src} ${dest_path})
- endforeach()
- endforeach()
+ function(create_crt_library CRT_LIBRARY_NAME)
+ set(cmake_crt_lib_name host_standalone_crt_${CRT_LIBRARY_NAME})
Review Comment:
uppercase
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] leandron commented on pull request #13600: [microTVM] Build standalone_crt with cmake instead of makefile
Posted by GitBox <gi...@apache.org>.
leandron commented on PR #13600:
URL: https://github.com/apache/tvm/pull/13600#issuecomment-1349510028
> Is there a specific way you typically invoke setup.py to exercise this feature or an example command that I should use to test?
Build TVM with `USE_MICRO ON`, then `cd python; python setup.py bdist_wheel`.
Also, if that helps with context, the real use case would be following tlcpack steps https://github.com/tlc-pack/tlcpack
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] mehrdadh merged pull request #13600: [microTVM] Build standalone_crt with cmake instead of makefile
Posted by GitBox <gi...@apache.org>.
mehrdadh merged PR #13600:
URL: https://github.com/apache/tvm/pull/13600
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] tvm-bot commented on pull request #13600: Build standalone_crt with cmake instead of makefile
Posted by GitBox <gi...@apache.org>.
tvm-bot commented on PR #13600:
URL: https://github.com/apache/tvm/pull/13600#issuecomment-1347367331
<!---bot-comment-->
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @-ing them in a comment.
<sub>Generated by [tvm-bot](https://github.com/apache/tvm/blob/main/ci/README.md#github-actions)</sub>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] alanmacd commented on pull request #13600: [microTVM] Build standalone_crt with cmake instead of makefile
Posted by GitBox <gi...@apache.org>.
alanmacd commented on PR #13600:
URL: https://github.com/apache/tvm/pull/13600#issuecomment-1349884405
> python setup.py bdist_wheel
@leandron ok, it looks like it's only copying the standalone_crt directory into the wheel, I've updated my PR to not put the library binaries in the standalone_crt directory (matching the current TVM main), all the other files should be the same as I didn't change the standalone_crt file copy code.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] alanmacd commented on a diff in pull request #13600: [microTVM] Build standalone_crt with cmake instead of makefile
Posted by GitBox <gi...@apache.org>.
alanmacd commented on code in PR #13600:
URL: https://github.com/apache/tvm/pull/13600#discussion_r1047829464
##########
cmake/modules/StandaloneCrt.cmake:
##########
@@ -40,129 +40,154 @@ if(MSVC)
else()
- message(STATUS "Build standalone CRT for microTVM")
+ function(create_crt_library CRT_LIBRARY)
- function(tvm_crt_define_targets)
- # Build an isolated build directory, separate from the TVM tree.
- list(APPEND CRT_FILE_COPY_JOBS
- "3rdparty/libcrc/include *.h -> include"
- "3rdparty/libcrc/src crcccitt.c -> src/runtime/crt/microtvm_rpc_common"
- "3rdparty/libcrc/tab gentab_ccitt.inc -> src/runtime/crt/tab"
- "3rdparty/dlpack/include *.h -> include"
- "3rdparty/dmlc-core/include *.h -> include"
- "include/tvm/runtime c_*_api.h -> include/tvm/runtime"
- "include/tvm/runtime metadata_types.h -> include/tvm/runtime"
- "include/tvm/runtime/crt *.h -> include/tvm/runtime/crt"
- "src/runtime/crt Makefile -> ."
- "src/runtime/crt/include *.h -> include"
- "src/runtime/crt/aot_executor *.c -> src/runtime/crt/aot_executor"
- "src/runtime/crt/aot_executor_module *.c -> src/runtime/crt/aot_executor_module"
- "src/runtime/crt/common *.c -> src/runtime/crt/common"
- "src/runtime/crt/graph_executor *.c -> src/runtime/crt/graph_executor"
- "src/runtime/crt/graph_executor_module *.c -> src/runtime/crt/graph_executor_module"
- "src/runtime/crt/host *.cc -> template/host"
- "src/runtime/crt/host *.py -> template/host"
- "src/runtime/crt/host Makefile.template -> template/host"
- "src/runtime/crt/memory *.c -> src/runtime/crt/memory"
- "src/runtime/crt/microtvm_rpc_common *.cc -> src/runtime/crt/microtvm_rpc_common"
- "src/runtime/crt/microtvm_rpc_server *.cc -> src/runtime/crt/microtvm_rpc_server"
- "src/runtime/minrpc *.h -> src/runtime/minrpc"
- "src/support generic_arena.h -> src/support"
- "src/support ssize.h -> src/support"
- "src/runtime/crt crt_config-template.h -> template"
- )
-
- set(standalone_crt_base "${CMAKE_CURRENT_BINARY_DIR}/standalone_crt")
-
- foreach(job_spec IN LISTS CRT_FILE_COPY_JOBS)
- string(REPLACE " " ";" job_spec "${job_spec}")
- list(LENGTH job_spec job_spec_length)
- math(EXPR job_spec_length_mod "${job_spec_length} % 3")
- if(NOT "${job_spec_length_mod}" EQUAL 1)
- message(FATAL_ERROR "CRT copy job spec list length is ${job_spec_length}; parsed job spec is ${job_spec}")
- endif()
- math(EXPR job_spec_stop "${job_spec_length} - 3")
-
- list(GET job_spec 0 job_src_base)
- set(job_src_base "${CMAKE_CURRENT_SOURCE_DIR}/${job_src_base}")
- foreach(copy_pattern_index RANGE 1 "${job_spec_stop}" 3)
- list(GET job_spec ${copy_pattern_index} copy_pattern)
- math(EXPR copy_dest_index "${copy_pattern_index} + 2")
- list(GET job_spec ${copy_dest_index} copy_dest)
-
- tvm_file_glob(GLOB_RECURSE copy_files
- RELATIVE "${job_src_base}"
- "${job_src_base}/${copy_pattern}")
- list(LENGTH copy_files copy_files_length)
- if("${copy_files_length}" EQUAL 0)
- message(FATAL_ERROR "CRT copy job matched 0 files: ${job_src_base}/${copy_pattern} -> ${copy_dest}")
- endif()
- foreach(copy_src IN LISTS copy_files)
- get_filename_component(dest_path "${standalone_crt_base}/${copy_dest}/${copy_src}" ABSOLUTE)
- tvm_micro_add_copy_file(host_isolated_build_deps ${job_src_base}/${copy_src} ${dest_path})
- endforeach()
- endforeach()
- endforeach()
+ set(CRT_LIBRARY_NAME host_standalone_crt_${CRT_LIBRARY})
+ set(CRT_LIBRARY_SOURCES "")
- add_custom_target(standalone_crt DEPENDS ${host_isolated_build_deps})
+ foreach(FILE_NAME IN LISTS ARGN)
+ list(APPEND CRT_LIBRARY_SOURCES ${FILE_NAME})
+ endforeach()
- get_filename_component(host_build_dir_abspath "${CMAKE_CURRENT_BINARY_DIR}/host_standalone_crt" ABSOLUTE)
+ add_library(${CRT_LIBRARY_NAME}
+ STATIC
+ ${CRT_LIBRARY_SOURCES})
- if(${VERBOSE})
- set(make_quiet QUIET=)
- else(${VERBOSE})
- set(make_quiet )
- endif(${VERBOSE})
+ # add this library to the list of CRT libraries
+ set(CRT_LIBRARIES ${CRT_LIBRARIES} ${CRT_LIBRARY_NAME} PARENT_SCOPE)
- list(APPEND crt_libraries memory graph_executor microtvm_rpc_server microtvm_rpc_common common) # NOTE: listed in link order.
- foreach(crt_lib_name IN LISTS crt_libraries)
- list(APPEND crt_library_paths "host_standalone_crt/lib${crt_lib_name}.a")
- endforeach()
+ target_include_directories(${CRT_LIBRARY_NAME}
+ PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/micro/
+ ${STANDALONE_CRT_BASE}/include)
- set(make_common_args
- "CRT_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/micro/crt_config.h"
- "BUILD_DIR=${host_build_dir_abspath}"
- "EXTRA_CFLAGS=-fPIC"
- "EXTRA_CXXFLAGS=-fPIC"
- "EXTRA_LDFLAGS=-fPIC"
- "${make_quiet}")
-
- add_custom_command(
- OUTPUT ${crt_library_paths}
- COMMAND make ARGS ${make_common_args} clean
- COMMAND make ARGS ${make_common_args} all
- WORKING_DIRECTORY "${standalone_crt_base}"
- DEPENDS standalone_crt ${host_isolated_build_deps})
-
- add_custom_target(host_standalone_crt DEPENDS ${crt_library_paths})
-
- foreach(crt_lib IN LISTS crt_libraries)
- set(cmake_crt_lib_name host_standalone_crt_${crt_lib})
- list(APPEND cmake_crt_libraries ${cmake_crt_lib_name})
- add_library(${cmake_crt_lib_name} STATIC IMPORTED GLOBAL)
- set(cmake_crt_lib_path "${CMAKE_CURRENT_BINARY_DIR}/host_standalone_crt/lib${crt_lib}.a")
- add_dependencies(${cmake_crt_lib_name} host_standalone_crt "${cmake_crt_lib_path}")
- set_target_properties(${cmake_crt_lib_name} PROPERTIES
- IMPORTED_LOCATION "${cmake_crt_lib_path}"
- IMPORTED_OBJECTS "${cmake_crt_lib_path}"
- PUBLIC_HEADER "${crt_headers}")
- endforeach()
+ set_target_properties(${CRT_LIBRARY_NAME}
+ PROPERTIES
+ ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/host_standalone_crt
+ POSITION_INDEPENDENT_CODE ON)
Review Comment:
add option to disable PIC if using a standalone CMake build
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] alanmacd commented on a diff in pull request #13600: [microTVM] Build standalone_crt with cmake instead of makefile
Posted by GitBox <gi...@apache.org>.
alanmacd commented on code in PR #13600:
URL: https://github.com/apache/tvm/pull/13600#discussion_r1046447592
##########
cmake/modules/StandaloneCrt.cmake:
##########
@@ -40,129 +40,143 @@ if(MSVC)
else()
- message(STATUS "Build standalone CRT for microTVM")
-
- function(tvm_crt_define_targets)
- # Build an isolated build directory, separate from the TVM tree.
- list(APPEND CRT_FILE_COPY_JOBS
- "3rdparty/libcrc/include *.h -> include"
- "3rdparty/libcrc/src crcccitt.c -> src/runtime/crt/microtvm_rpc_common"
- "3rdparty/libcrc/tab gentab_ccitt.inc -> src/runtime/crt/tab"
- "3rdparty/dlpack/include *.h -> include"
- "3rdparty/dmlc-core/include *.h -> include"
- "include/tvm/runtime c_*_api.h -> include/tvm/runtime"
- "include/tvm/runtime metadata_types.h -> include/tvm/runtime"
- "include/tvm/runtime/crt *.h -> include/tvm/runtime/crt"
- "src/runtime/crt Makefile -> ."
- "src/runtime/crt/include *.h -> include"
- "src/runtime/crt/aot_executor *.c -> src/runtime/crt/aot_executor"
- "src/runtime/crt/aot_executor_module *.c -> src/runtime/crt/aot_executor_module"
- "src/runtime/crt/common *.c -> src/runtime/crt/common"
- "src/runtime/crt/graph_executor *.c -> src/runtime/crt/graph_executor"
- "src/runtime/crt/graph_executor_module *.c -> src/runtime/crt/graph_executor_module"
- "src/runtime/crt/host *.cc -> template/host"
- "src/runtime/crt/host *.py -> template/host"
- "src/runtime/crt/host Makefile.template -> template/host"
- "src/runtime/crt/memory *.c -> src/runtime/crt/memory"
- "src/runtime/crt/microtvm_rpc_common *.cc -> src/runtime/crt/microtvm_rpc_common"
- "src/runtime/crt/microtvm_rpc_server *.cc -> src/runtime/crt/microtvm_rpc_server"
- "src/runtime/minrpc *.h -> src/runtime/minrpc"
- "src/support generic_arena.h -> src/support"
- "src/support ssize.h -> src/support"
- "src/runtime/crt crt_config-template.h -> template"
- )
-
- set(standalone_crt_base "${CMAKE_CURRENT_BINARY_DIR}/standalone_crt")
-
- foreach(job_spec IN LISTS CRT_FILE_COPY_JOBS)
- string(REPLACE " " ";" job_spec "${job_spec}")
- list(LENGTH job_spec job_spec_length)
- math(EXPR job_spec_length_mod "${job_spec_length} % 3")
- if(NOT "${job_spec_length_mod}" EQUAL 1)
- message(FATAL_ERROR "CRT copy job spec list length is ${job_spec_length}; parsed job spec is ${job_spec}")
- endif()
- math(EXPR job_spec_stop "${job_spec_length} - 3")
-
- list(GET job_spec 0 job_src_base)
- set(job_src_base "${CMAKE_CURRENT_SOURCE_DIR}/${job_src_base}")
- foreach(copy_pattern_index RANGE 1 "${job_spec_stop}" 3)
- list(GET job_spec ${copy_pattern_index} copy_pattern)
- math(EXPR copy_dest_index "${copy_pattern_index} + 2")
- list(GET job_spec ${copy_dest_index} copy_dest)
-
- tvm_file_glob(GLOB_RECURSE copy_files
- RELATIVE "${job_src_base}"
- "${job_src_base}/${copy_pattern}")
- list(LENGTH copy_files copy_files_length)
- if("${copy_files_length}" EQUAL 0)
- message(FATAL_ERROR "CRT copy job matched 0 files: ${job_src_base}/${copy_pattern} -> ${copy_dest}")
- endif()
- foreach(copy_src IN LISTS copy_files)
- get_filename_component(dest_path "${standalone_crt_base}/${copy_dest}/${copy_src}" ABSOLUTE)
- tvm_micro_add_copy_file(host_isolated_build_deps ${job_src_base}/${copy_src} ${dest_path})
- endforeach()
- endforeach()
+ function(create_crt_library CRT_LIBRARY_NAME)
+ set(cmake_crt_lib_name host_standalone_crt_${CRT_LIBRARY_NAME})
+
+ set(CRT_LIBRARY_SOURCES "")
+ foreach(FILE_NAME IN LISTS ARGN)
+ list(APPEND CRT_LIBRARY_SOURCES ${FILE_NAME})
endforeach()
- add_custom_target(standalone_crt DEPENDS ${host_isolated_build_deps})
+ add_library(${cmake_crt_lib_name}
+ STATIC
+ ${CRT_LIBRARY_SOURCES})
- get_filename_component(host_build_dir_abspath "${CMAKE_CURRENT_BINARY_DIR}/host_standalone_crt" ABSOLUTE)
+ set(CMAKE_CRT_LIBRARIES ${CMAKE_CRT_LIBRARIES} ${cmake_crt_lib_name} PARENT_SCOPE)
- if(${VERBOSE})
- set(make_quiet QUIET=)
- else(${VERBOSE})
- set(make_quiet )
- endif(${VERBOSE})
+ set_property(TARGET ${cmake_crt_lib_name} PROPERTY POSITION_INDEPENDENT_CODE ON)
- list(APPEND crt_libraries memory graph_executor microtvm_rpc_server microtvm_rpc_common common) # NOTE: listed in link order.
- foreach(crt_lib_name IN LISTS crt_libraries)
- list(APPEND crt_library_paths "host_standalone_crt/lib${crt_lib_name}.a")
- endforeach()
+ target_include_directories(${cmake_crt_lib_name} PUBLIC ${STANDALONE_CRT_INCLUDE_PATH} ${CRT_CONFIG_INCLUDE_PATH})
- set(make_common_args
- "CRT_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/micro/crt_config.h"
- "BUILD_DIR=${host_build_dir_abspath}"
- "EXTRA_CFLAGS=-fPIC"
- "EXTRA_CXXFLAGS=-fPIC"
- "EXTRA_LDFLAGS=-fPIC"
- "${make_quiet}")
-
- add_custom_command(
- OUTPUT ${crt_library_paths}
- COMMAND make ARGS ${make_common_args} clean
- COMMAND make ARGS ${make_common_args} all
- WORKING_DIRECTORY "${standalone_crt_base}"
- DEPENDS standalone_crt ${host_isolated_build_deps})
-
- add_custom_target(host_standalone_crt DEPENDS ${crt_library_paths})
-
- foreach(crt_lib IN LISTS crt_libraries)
- set(cmake_crt_lib_name host_standalone_crt_${crt_lib})
- list(APPEND cmake_crt_libraries ${cmake_crt_lib_name})
- add_library(${cmake_crt_lib_name} STATIC IMPORTED GLOBAL)
- set(cmake_crt_lib_path "${CMAKE_CURRENT_BINARY_DIR}/host_standalone_crt/lib${crt_lib}.a")
- add_dependencies(${cmake_crt_lib_name} host_standalone_crt "${cmake_crt_lib_path}")
- set_target_properties(${cmake_crt_lib_name} PROPERTIES
- IMPORTED_LOCATION "${cmake_crt_lib_path}"
- IMPORTED_OBJECTS "${cmake_crt_lib_path}"
- PUBLIC_HEADER "${crt_headers}")
- endforeach()
+ set_target_properties(${cmake_crt_lib_name} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${standalone_crt_base}/build)
- # Create the `crttest` target if we can find GTest. If not, we create dummy
- # targets that give the user an informative error message.
- if(GTEST_FOUND)
- tvm_file_glob(GLOB TEST_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/tests/crt/*.cc)
- add_executable(crttest ${TEST_SRCS})
- target_include_directories(crttest SYSTEM PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/standalone_crt/include ${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/micro)
- target_link_libraries(crttest PRIVATE ${cmake_crt_libraries} GTest::GTest GTest::Main pthread dl)
- set_target_properties(crttest PROPERTIES EXCLUDE_FROM_ALL 1)
- set_target_properties(crttest PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
- gtest_discover_tests(crttest)
- endif()
+ # make these libraries dependent on standalone_crt which depends on host_isolated_build_deps to avoid
+ # race with the file copy jobs
+ add_dependencies(${cmake_crt_lib_name} standalone_crt)
endfunction()
- tvm_crt_define_targets()
+ message(STATUS "Build standalone CRT for microTVM")
+
+ # Build an isolated build directory, separate from the TVM tree.
+ list(APPEND CRT_FILE_COPY_JOBS
+ "3rdparty/libcrc/include *.h -> include"
+ "3rdparty/libcrc/src crcccitt.c -> src/runtime/crt/microtvm_rpc_common"
+ "3rdparty/libcrc/tab gentab_ccitt.inc -> src/runtime/crt/tab"
+ "3rdparty/dlpack/include *.h -> include"
+ "3rdparty/dmlc-core/include *.h -> include"
+ "include/tvm/runtime c_*_api.h -> include/tvm/runtime"
+ "include/tvm/runtime metadata_types.h -> include/tvm/runtime"
+ "include/tvm/runtime/crt *.h -> include/tvm/runtime/crt"
+ "src/runtime/crt Makefile -> ."
+ "src/runtime/crt/include *.h -> include"
+ "src/runtime/crt/aot_executor *.c -> src/runtime/crt/aot_executor"
+ "src/runtime/crt/aot_executor_module *.c -> src/runtime/crt/aot_executor_module"
+ "src/runtime/crt/common *.c -> src/runtime/crt/common"
+ "src/runtime/crt/graph_executor *.c -> src/runtime/crt/graph_executor"
+ "src/runtime/crt/graph_executor_module *.c -> src/runtime/crt/graph_executor_module"
+ "src/runtime/crt/host *.cc -> template/host"
+ "src/runtime/crt/host *.py -> template/host"
+ "src/runtime/crt/host Makefile.template -> template/host"
+ "src/runtime/crt/memory *.c -> src/runtime/crt/memory"
+ "src/runtime/crt/microtvm_rpc_common *.cc -> src/runtime/crt/microtvm_rpc_common"
+ "src/runtime/crt/microtvm_rpc_server *.cc -> src/runtime/crt/microtvm_rpc_server"
+ "src/runtime/minrpc *.h -> src/runtime/minrpc"
+ "src/support generic_arena.h -> src/support"
+ "src/support ssize.h -> src/support"
+ "src/runtime/crt crt_config-template.h -> template"
+ )
+
+ set(standalone_crt_base "${CMAKE_CURRENT_BINARY_DIR}/standalone_crt")
+
+ foreach(job_spec IN LISTS CRT_FILE_COPY_JOBS)
+ string(REPLACE " " ";" job_spec "${job_spec}")
+ list(LENGTH job_spec job_spec_length)
+ math(EXPR job_spec_length_mod "${job_spec_length} % 3")
+ if(NOT "${job_spec_length_mod}" EQUAL 1)
+ message(FATAL_ERROR "CRT copy job spec list length is ${job_spec_length}; parsed job spec is ${job_spec}")
+ endif()
+ math(EXPR job_spec_stop "${job_spec_length} - 3")
+
+ list(GET job_spec 0 job_src_base)
+ set(job_src_base "${CMAKE_CURRENT_SOURCE_DIR}/${job_src_base}")
+ foreach(copy_pattern_index RANGE 1 "${job_spec_stop}" 3)
+ list(GET job_spec ${copy_pattern_index} copy_pattern)
+ math(EXPR copy_dest_index "${copy_pattern_index} + 2")
+ list(GET job_spec ${copy_dest_index} copy_dest)
+
+ tvm_file_glob(GLOB_RECURSE copy_files
+ RELATIVE "${job_src_base}"
+ "${job_src_base}/${copy_pattern}")
+ list(LENGTH copy_files copy_files_length)
+ if("${copy_files_length}" EQUAL 0)
+ message(FATAL_ERROR "CRT copy job matched 0 files: ${job_src_base}/${copy_pattern} -> ${copy_dest}")
+ endif()
+ foreach(copy_src IN LISTS copy_files)
+ get_filename_component(dest_path "${standalone_crt_base}/${copy_dest}/${copy_src}" ABSOLUTE)
+ tvm_micro_add_copy_file(host_isolated_build_deps ${job_src_base}/${copy_src} ${dest_path})
+ endforeach()
+ endforeach()
+ endforeach()
+
+ add_custom_target(standalone_crt DEPENDS ${host_isolated_build_deps})
+
+ get_filename_component(host_build_dir_abspath "${CMAKE_CURRENT_BINARY_DIR}/host_standalone_crt" ABSOLUTE)
+
+ set(CRT_CONFIG_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/micro/")
+ set(STANDALONE_CRT_INCLUDE_PATH "${standalone_crt_base}/include")
+ set(CMAKE_CRT_LIBRARIES "")
+
+ # NOTE: these create_crt_library() targets are in link order and common needs to be last
+
+ create_crt_library(graph_executor
+ ${standalone_crt_base}/src/runtime/crt/graph_executor/graph_executor.c
+ ${standalone_crt_base}/src/runtime/crt/graph_executor/load_json.c)
+
+ create_crt_library(memory
+ ${standalone_crt_base}/src/runtime/crt/memory/page_allocator.c
+ ${standalone_crt_base}/src/runtime/crt/memory/stack_allocator.c)
+
+ create_crt_library(microtvm_rpc_common
+ ${standalone_crt_base}/src/runtime/crt/microtvm_rpc_common/crcccitt.c
+ ${standalone_crt_base}/src/runtime/crt/microtvm_rpc_common/frame_buffer.cc
+ ${standalone_crt_base}/src/runtime/crt/microtvm_rpc_common/framing.cc
+ ${standalone_crt_base}/src/runtime/crt/microtvm_rpc_common/session.cc
+ ${standalone_crt_base}/src/runtime/crt/microtvm_rpc_common/write_stream.cc)
+
+ create_crt_library(microtvm_rpc_server
+ ${standalone_crt_base}/src/runtime/crt/microtvm_rpc_server/rpc_server.cc)
+
+ create_crt_library(common
+ ${standalone_crt_base}/src/runtime/crt/common/crt_backend_api.c
+ ${standalone_crt_base}/src/runtime/crt/common/crt_runtime_api.c
+ ${standalone_crt_base}/src/runtime/crt/common/func_registry.c
+ ${standalone_crt_base}/src/runtime/crt/common/ndarray.c
+ ${standalone_crt_base}/src/runtime/crt/common/packed_func.c)
+
+ add_custom_target(host_standalone_crt DEPENDS ${CMAKE_CRT_LIBRARIES} standalone_crt)
+
+ # Create the `crttest` target if we can find GTest. If not, we create dummy
+ # targets that give the user an informative error message.
+ if(GTEST_FOUND)
+ tvm_file_glob(GLOB TEST_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/tests/crt/*.cc)
+ add_executable(crttest ${TEST_SRCS})
+ target_include_directories(crttest SYSTEM PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/standalone_crt/include ${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/micro)
+ target_link_libraries(crttest PRIVATE ${CMAKE_CRT_LIBRARIES} GTest::GTest GTest::Main pthread dl)
Review Comment:
rename to STANDALONE_CRT_LIBRARIES (CMAKE prefix is confusing)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org