test / cmake /hexagon.toolchain
Androidonnxfork's picture
Upload folder using huggingface_hub
8b7c501
raw
history blame
5.9 kB
# Copyright 2022 Google LLC
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
SET(CMAKE_SYSTEM_NAME QURT)
SET(CMAKE_SYSTEM_PROCESSOR Hexagon)
SET(CMAKE_CROSSCOMPILING TRUE)
# For compatibility with with CMake toolchain from Hexagon SDK
SET(HEXAGON TRUE)
SET(HEXAGON_ARCH v66)
IF(NOT DEFINED ENV{HEXAGON_SDK_ROOT})
MESSAGE(FATAL_ERROR "HEXAGON_SDK_ROOT environment variable not defined")
ENDIF()
IF(NOT DEFINED ENV{HEXAGON_TOOLS_ROOT})
MESSAGE(FATAL_ERROR "HEXAGON_TOOLS_ROOT environment variable not defined")
ENDIF()
SET(CMAKE_C_COMPILER "$ENV{HEXAGON_TOOLS_ROOT}/bin/hexagon-clang")
SET(CMAKE_ASM_COMPILER "$ENV{HEXAGON_TOOLS_ROOT}/bin/hexagon-clang")
SET(CMAKE_CXX_COMPILER "$ENV{HEXAGON_TOOLS_ROOT}/bin/hexagon-clang++")
SET(HEXAGON_LINK "$ENV{HEXAGON_TOOLS_ROOT}/bin/hexagon-link")
SET(HEXAGON_SIM "$ENV{HEXAGON_TOOLS_ROOT}/bin/hexagon-sim")
SET(CMAKE_FIND_ROOT_PATH "$ENV{HEXAGON_TOOLS_ROOT}/target/hexagon")
SET(CMAKE_PREFIX_PATH "$ENV{HEXAGON_TOOLS_ROOT}/target/hexagon")
SET(CMAKE_INCLUDE_PATH "$ENV{HEXAGON_TOOLS_ROOT}/target/hexagon/include")
SET(CMAKE_LIBRARY_PATH "$ENV{HEXAGON_TOOLS_ROOT}/target/hexagon/lib/v66")
SET(CMAKE_PROGRAM_PATH "$ENV{HEXAGON_TOOLS_ROOT}/bin")
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
SET(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES
"$ENV{HEXAGON_SDK_ROOT}/incs"
"$ENV{HEXAGON_SDK_ROOT}/incs/stddef"
"$ENV{HEXAGON_SDK_ROOT}/libs/common/qurt/computev66/include"
"$ENV{HEXAGON_SDK_ROOT}/libs/common/qurt/computev66/include/qurt"
"$ENV{HEXAGON_SDK_ROOT}/libs/common/qurt/computev66/include/posix")
SET(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES
"$ENV{HEXAGON_SDK_ROOT}/incs"
"$ENV{HEXAGON_SDK_ROOT}/incs/stddef"
"$ENV{HEXAGON_SDK_ROOT}/libs/common/qurt/computev66/include"
"$ENV{HEXAGON_SDK_ROOT}/libs/common/qurt/computev66/include/qurt"
"$ENV{HEXAGON_SDK_ROOT}/libs/common/qurt/computev66/include/posix")
SET(HEXAGON_C_LINK_EXECUTABLE_LINK_OPTIONS "-mv66 -g -nostdlib --section-start .interp=0x23000000 --dynamic-linker= --force-dynamic -E -z muldefs --whole-archive -o <TARGET> --start-group $ENV{HEXAGON_TOOLS_ROOT}/target/hexagon/lib/v66/G0/init.o $ENV{HEXAGON_SDK_ROOT}/libs/common/qurt/computev66/lib/crt1.o $ENV{HEXAGON_SDK_ROOT}/libs/common/qurt/computev66/lib/libqurt.a $ENV{HEXAGON_TOOLS_ROOT}/target/hexagon/lib/v66/G0/libc.a $ENV{HEXAGON_TOOLS_ROOT}/target/hexagon/lib/v66/G0/libqcc.a $ENV{HEXAGON_TOOLS_ROOT}/target/hexagon/lib/v66/G0/libhexagon.a $ENV{HEXAGON_SDK_ROOT}/libs/common/qurt/computev66/lib/libqurtcfs.a $ENV{HEXAGON_SDK_ROOT}/libs/common/qurt/computev66/lib/libtimer.a $ENV{HEXAGON_SDK_ROOT}/libs/common/qurt/computev66/lib/libposix.a <OBJECTS> <LINK_LIBRARIES> $ENV{HEXAGON_TOOLS_ROOT}/target/hexagon/lib/v66/G0/fini.o --end-group")
SET(HEXAGON_CXX_LINK_EXECUTABLE_LINK_OPTIONS "-mv66 -g -nostdlib --section-start .interp=0x23000000 --dynamic-linker= --force-dynamic -E -z muldefs --whole-archive -o <TARGET> --start-group $ENV{HEXAGON_TOOLS_ROOT}/target/hexagon/lib/v66/G0/init.o $ENV{HEXAGON_SDK_ROOT}/libs/common/qurt/computev66/lib/crt1.o $ENV{HEXAGON_SDK_ROOT}/libs/common/qurt/computev66/lib/libqurt.a $ENV{HEXAGON_TOOLS_ROOT}/target/hexagon/lib/v66/G0/libc.a $ENV{HEXAGON_TOOLS_ROOT}/target/hexagon/lib/v66/G0/libqcc.a $ENV{HEXAGON_TOOLS_ROOT}/target/hexagon/lib/v66/G0/libhexagon.a $ENV{HEXAGON_SDK_ROOT}/libs/common/qurt/computev66/lib/libqurtcfs.a $ENV{HEXAGON_SDK_ROOT}/libs/common/qurt/computev66/lib/libtimer.a $ENV{HEXAGON_SDK_ROOT}/libs/common/qurt/computev66/lib/libposix.a $ENV{HEXAGON_TOOLS_ROOT}/target/hexagon/lib/v66/libc++.a $ENV{HEXAGON_TOOLS_ROOT}/target/hexagon/lib/v66/libc++abi.a $ENV{HEXAGON_TOOLS_ROOT}/target/hexagon/lib/v66/libc_eh.a <OBJECTS> <LINK_LIBRARIES> $ENV{HEXAGON_TOOLS_ROOT}/target/hexagon/lib/v66/G0/fini.o --end-group")
SET(CMAKE_C_LINK_EXECUTABLE "${HEXAGON_LINK} ${HEXAGON_C_LINK_EXECUTABLE_LINK_OPTIONS}")
SET(CMAKE_CXX_LINK_EXECUTABLE "${HEXAGON_LINK} ${HEXAGON_CXX_LINK_EXECUTABLE_LINK_OPTIONS}")
ADD_COMPILE_OPTIONS(-O2)
ADD_COMPILE_OPTIONS(-mv66)
SET(CMAKE_THREAD_LIBS_INIT "" CACHE STRING "")
SET(CMAKE_HAVE_THREADS_LIBRARY TRUE)
SET(CMAKE_USE_WIN32_THREADS_INIT FALSE)
SET(CMAKE_USE_PTHREADS_INIT TRUE)
SET(THREADS_PREFER_PTHREAD_FLAG FALSE)
SET(Threads_FOUND TRUE CACHE BOOL "")
# Setup Hexagon simulator
SET(HEXAGON_SIM_OSAM_CONTENT "$ENV{HEXAGON_SDK_ROOT}/libs/common/qurt/computev66/debugger/lnx64/qurt_model.so")
SET(HEXAGON_SIM_Q6SS_CONTENT
"$ENV{HEXAGON_TOOLS_ROOT}/lib/iss/qtimer.so --csr_base=0xFC900000 --irq_p=1 --freq=19200000 --cnttid=1
$ENV{HEXAGON_TOOLS_ROOT}/lib/iss/l2vic.so 32 0xFC910000")
SET(HEXAGON_SIMRUN_CONTENT
"#!/bin/sh
${HEXAGON_SIM} -mv66g_1024 --quiet --simulated_returnval --usefs ${CMAKE_CURRENT_BINARY_DIR} --pmu_statsfile ${CMAKE_CURRENT_BINARY_DIR}/pmu_stats.txt --cosim_file ${CMAKE_BINARY_DIR}/q6ss.cfg --l2tcm_base 0xd800 --rtos ${CMAKE_BINARY_DIR}/osam.cfg $ENV{HEXAGON_SDK_ROOT}/libs/common/qurt/computev66/sdksim_bin/runelf.pbn -- $@")
FILE(WRITE "${CMAKE_BINARY_DIR}/osam.cfg" "${HEXAGON_SIM_OSAM_CONTENT}")
FILE(WRITE "${CMAKE_BINARY_DIR}/q6ss.cfg" "${HEXAGON_SIM_Q6SS_CONTENT}")
FILE(TOUCH "${CMAKE_BINARY_DIR}/simrun")
FILE(CHMOD "${CMAKE_BINARY_DIR}/simrun" FILE_PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ WORLD_READ)
FILE(WRITE "${CMAKE_BINARY_DIR}/simrun" "${HEXAGON_SIMRUN_CONTENT}")
SET(CMAKE_CROSSCOMPILING_EMULATOR "${HEXAGON_SIM}" "-mv66g_1024" "--quiet" "--simulated_returnval" "--usefs" "${CMAKE_CURRENT_BINARY_DIR}" "--pmu_statsfile" "${CMAKE_CURRENT_BINARY_DIR}/pmu_stats.txt" "--cosim_file" "${CMAKE_BINARY_DIR}/q6ss.cfg" "--l2tcm_base" "0xd800" "--rtos" "${CMAKE_BINARY_DIR}/osam.cfg" "$ENV{HEXAGON_SDK_ROOT}/libs/common/qurt/computev66/sdksim_bin/runelf.pbn" "--")