-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Hexagon] -Build Hexagon runtime components using the Hexagon SDK (Cl…
…one of #7671) (#7741) * Add CMakeLists.txt to build the hexagon_remote runtime. * Print an error message if libhalide_hexagon_host.so is not found. * Fix case mismatch in hexagon_remote/CMakeLists.txt * Remove some code that had been commented out in hexagon_remote/CMakeLists.txt * Remove unused argument in macro in hexagon_remote/CMakeLists.txt * add find module for Hexagon * move more variables to find module * Build binary modules with ExternalProject * group platform-speicifc sources into subdirectories * Pass HEXAGON_TOOLS_ROOT, too * Use the desired layout for the build-tree artifacts * Use SYSTEM for Hexagon SDK include dirs * trigger buildbots * Ignore code in src/runtime/hexagon_remote/bin/src for clang-tidy * Just skip hexagon_remote entirely for Halide_CLANG_TIDY_BUILD * Add an option to enable the building of the hexagon remote runtime --------- Co-authored-by: Alex Reinking <quic_areinkin@quicinc.com> Co-authored-by: Steven Johnson <srj@google.com>
- Loading branch information
1 parent
708d41b
commit fcc1c3b
Showing
19 changed files
with
261 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
include(FindPackageHandleStandardArgs) | ||
|
||
## | ||
# Find the Hexagon SDK root | ||
|
||
# We use the presense of the hexagon toolchain file to determine the SDK | ||
# root. Other files have names that are too generic (like readme.txt) or | ||
# are platform-specific (like setup_sdk_env.source) to and so can't be | ||
# used to autodetect the path. Plus, we need to find this file anyway. | ||
|
||
find_path( | ||
HEXAGON_SDK_ROOT build/cmake/hexagon_toolchain.cmake | ||
HINTS ENV HEXAGON_SDK_ROOT | ||
) | ||
|
||
## | ||
# Detect the installed Hexagon tools version | ||
|
||
if (NOT DEFINED HEXAGON_TOOLS_VER AND DEFINED ENV{HEXAGON_TOOLS_VER}) | ||
set(HEXAGON_TOOLS_VER "$ENV{HEXAGON_TOOLS_VER}") | ||
endif () | ||
|
||
if (NOT DEFINED HEXAGON_TOOLS_VER) | ||
# No other way to list a directory; no need for CONFIGURE_DEPENDS here | ||
# since this is just used to initialize a cache variable. | ||
file( | ||
GLOB tools_versions | ||
RELATIVE "${HEXAGON_SDK_ROOT}/tools/HEXAGON_Tools" | ||
"${HEXAGON_SDK_ROOT}/tools/HEXAGON_Tools/*" | ||
) | ||
if (NOT tools_versions STREQUAL "") | ||
list(GET tools_versions 0 HEXAGON_TOOLS_VER) | ||
endif () | ||
endif () | ||
|
||
set(HEXAGON_TOOLS_VER "${HEXAGON_TOOLS_VER}" | ||
CACHE STRING "Version of the Hexagon tools to use") | ||
|
||
set(HEXAGON_TOOLS_ROOT "${HEXAGON_SDK_ROOT}/tools/HEXAGON_Tools/${HEXAGON_TOOLS_VER}") | ||
|
||
## | ||
# Set known paths | ||
|
||
set(HEXAGON_TOOLCHAIN ${HEXAGON_SDK_ROOT}/build/cmake/hexagon_toolchain.cmake) | ||
set(HEXAGON_QAIC ${HEXAGON_SDK_ROOT}/ipc/fastrpc/qaic/Ubuntu16/qaic) | ||
|
||
set(ANDROID_NDK_ROOT ${HEXAGON_SDK_ROOT}/tools/android-ndk-r19c) | ||
set(ANDROID_NDK_TOOLCHAIN ${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake) | ||
|
||
## | ||
# Find ISS wrapper library and headers | ||
|
||
find_library( | ||
HEXAGON_ISS_WRAPPER_LIBRARY | ||
NAMES wrapper | ||
HINTS "${HEXAGON_TOOLS_ROOT}" | ||
PATH_SUFFIXES Tools/lib/iss lib/iss iss | ||
) | ||
|
||
find_path( | ||
HEXAGON_ISS_WRAPPER_INCLUDE_DIRECTORY | ||
NAMES HexagonWrapper.h | ||
HINTS "${HEXAGON_TOOLS_ROOT}" | ||
PATH_SUFFIXES Tools/include/iss include/iss iss | ||
) | ||
|
||
## | ||
# Validate we found everything correctly | ||
|
||
find_package_handle_standard_args( | ||
HexagonSDK | ||
REQUIRED_VARS | ||
HEXAGON_SDK_ROOT | ||
HEXAGON_TOOLS_ROOT | ||
HEXAGON_TOOLCHAIN | ||
HEXAGON_ISS_WRAPPER_LIBRARY | ||
HEXAGON_ISS_WRAPPER_INCLUDE_DIRECTORY | ||
HANDLE_COMPONENTS | ||
) | ||
|
||
## | ||
# Create imported targets | ||
|
||
if (HexagonSDK_FOUND AND NOT TARGET HexagonSDK::wrapper) | ||
add_library(HexagonSDK::wrapper UNKNOWN IMPORTED) | ||
set_target_properties( | ||
HexagonSDK::wrapper | ||
PROPERTIES | ||
IMPORTED_LOCATION "${HEXAGON_ISS_WRAPPER_LIBRARY}" | ||
INTERFACE_INCLUDE_DIRECTORIES "${HEXAGON_ISS_WRAPPER_INCLUDE_DIRECTORY}" | ||
) | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
include(ExternalProject) | ||
|
||
find_package(HexagonSDK REQUIRED) | ||
|
||
add_custom_command( | ||
OUTPUT | ||
halide_hexagon_remote.h | ||
halide_hexagon_remote_skel.c | ||
halide_hexagon_remote_stub.c | ||
COMMAND ${HEXAGON_QAIC} -I ${HEXAGON_SDK_ROOT}/incs/stddef ${CMAKE_CURRENT_SOURCE_DIR}/halide_hexagon_remote.idl | ||
DEPENDS halide_hexagon_remote.idl | ||
VERBATIM | ||
) | ||
|
||
add_custom_target( | ||
halide_hexagon_remote_idl | ||
DEPENDS | ||
${CMAKE_CURRENT_BINARY_DIR}/halide_hexagon_remote.h | ||
${CMAKE_CURRENT_BINARY_DIR}/halide_hexagon_remote_skel.c | ||
${CMAKE_CURRENT_BINARY_DIR}/halide_hexagon_remote_stub.c | ||
) | ||
|
||
set(common_cache_args | ||
"-DHALIDE_HEXAGON_REMOTE_IDL:PATH=${CMAKE_CURRENT_BINARY_DIR}" | ||
"-DHEXAGON_SDK_ROOT:PATH=${HEXAGON_SDK_ROOT}" | ||
"-DHEXAGON_TOOLS_ROOT:PATH=${HEXAGON_TOOLS_ROOT}" | ||
"-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>" | ||
) | ||
|
||
if (CMAKE_BUILD_TYPE) | ||
list(APPEND common_cache_args "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}") | ||
endif () | ||
|
||
ExternalProject_Add( | ||
hexagon_remote-qurt | ||
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/qurt" | ||
CMAKE_CACHE_ARGS | ||
"-DCMAKE_TOOLCHAIN_FILE:FILEPATH=${HEXAGON_TOOLCHAIN}" | ||
${common_cache_args} | ||
PREFIX hexagon | ||
DEPENDS halide_hexagon_remote_idl | ||
CONFIGURE_HANDLED_BY_BUILD ON | ||
) | ||
|
||
set(arm_abis armeabi-v7a arm64-v8a) | ||
set(arm_bits 32 64) | ||
foreach (abi bits IN ZIP_LISTS arm_abis arm_bits) | ||
ExternalProject_Add( | ||
halide_hexagon_host-${abi} | ||
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android" | ||
CMAKE_CACHE_ARGS | ||
"-DCMAKE_TOOLCHAIN_FILE:FILEPATH=${ANDROID_NDK_TOOLCHAIN}" | ||
"-DANDROID_ABI:STRING=${abi}" | ||
"-DANDROID_PLATFORM:STRING=21" | ||
${common_cache_args} | ||
PREFIX arm-${bits}-android | ||
DEPENDS halide_hexagon_remote_idl | ||
CONFIGURE_HANDLED_BY_BUILD ON | ||
) | ||
endforeach () | ||
|
||
add_library(halide_hexagon_host SHARED sim_host.cpp sim_protocol.h) | ||
target_compile_features(halide_hexagon_host PRIVATE cxx_std_17) | ||
target_include_directories(halide_hexagon_host PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) | ||
target_link_libraries(halide_hexagon_host PRIVATE HexagonSDK::wrapper) | ||
|
||
add_custom_target(hexagon_remote) | ||
add_dependencies( | ||
hexagon_remote | ||
hexagon_remote-qurt | ||
halide_hexagon_host | ||
halide_hexagon_host-armeabi-v7a | ||
halide_hexagon_host-arm64-v8a | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
cmake_minimum_required(VERSION 3.22) | ||
project(halide-hexagon_remote-android) | ||
|
||
set(_aarch64 "") | ||
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") | ||
set(_aarch64 "_aarch64") | ||
endif () | ||
|
||
add_library(fastrpc::cdsprpc SHARED IMPORTED) | ||
set_target_properties( | ||
fastrpc::cdsprpc | ||
PROPERTIES | ||
IMPORTED_LOCATION "${HEXAGON_SDK_ROOT}/ipc/fastrpc/remote/ship/android${_aarch64}/libcdsprpc.so" | ||
) | ||
|
||
add_library( | ||
halide_hexagon_host | ||
MODULE | ||
${HALIDE_HEXAGON_REMOTE_IDL}/halide_hexagon_remote_stub.c | ||
host_malloc.cpp | ||
host_shim.cpp | ||
libadsprpc_shim.cpp | ||
) | ||
target_include_directories( | ||
halide_hexagon_host | ||
PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR}/../.. | ||
) | ||
target_include_directories( | ||
halide_hexagon_host | ||
SYSTEM PRIVATE | ||
${HALIDE_HEXAGON_REMOTE_IDL} | ||
${HEXAGON_SDK_ROOT}/incs | ||
${HEXAGON_SDK_ROOT}/incs/stddef | ||
) | ||
target_link_libraries(halide_hexagon_host PRIVATE fastrpc::cdsprpc log) | ||
|
||
install( | ||
TARGETS halide_hexagon_host | ||
DESTINATION bin | ||
) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
cmake_minimum_required(VERSION 3.22) | ||
|
||
# The Hexagon toolchain is broken | ||
set(ENV{HEXAGON_SDK_ROOT} "${HEXAGON_SDK_ROOT}") | ||
set(ENV{HEXAGON_TOOLS_ROOT} "${HEXAGON_TOOLS_ROOT}") | ||
|
||
project(halide-hexagon_remote-qurt) | ||
|
||
add_library(sim_qurt STATIC sim_qurt.cpp sim_qurt_vtcm.cpp) | ||
target_include_directories(sim_qurt SYSTEM PRIVATE ${HALIDE_HEXAGON_REMOTE_IDL}) | ||
|
||
add_executable( | ||
hexagon_sim_remote | ||
known_symbols.cpp | ||
sim_remote.cpp | ||
$<TARGET_OBJECTS:sim_qurt> | ||
) | ||
target_include_directories( | ||
hexagon_sim_remote | ||
PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR}/.. | ||
${CMAKE_CURRENT_SOURCE_DIR}/../.. | ||
) | ||
target_include_directories(hexagon_sim_remote SYSTEM PRIVATE ${HALIDE_HEXAGON_REMOTE_IDL}) | ||
target_link_libraries(hexagon_sim_remote PRIVATE ${CMAKE_DL_LIBS}) | ||
|
||
add_library( | ||
halide_hexagon_remote_skel | ||
MODULE | ||
c11_stubs.cpp | ||
halide_remote.cpp | ||
known_symbols.cpp | ||
log.cpp | ||
nearbyint.cpp | ||
${HALIDE_HEXAGON_REMOTE_IDL}/halide_hexagon_remote_skel.c | ||
) | ||
target_include_directories(halide_hexagon_remote_skel PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../..) | ||
target_include_directories(halide_hexagon_remote_skel SYSTEM PRIVATE ${HALIDE_HEXAGON_REMOTE_IDL}) | ||
|
||
install( | ||
TARGETS sim_qurt hexagon_sim_remote halide_hexagon_remote_skel | ||
DESTINATION bin | ||
) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.