Cindy Liu | 48f6baf | 2021-07-28 20:42:34 -0700 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 3.13.4) |
| 2 | |
| 3 | #------------------------------------------------------------------------------- |
| 4 | # Project configuration |
| 5 | #------------------------------------------------------------------------------- |
| 6 | |
| 7 | project(iree-riscv32) |
| 8 | |
| 9 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 10 | |
Cindy Liu | ff71451 | 2021-08-26 16:22:12 -0700 | [diff] [blame] | 11 | list(APPEND CMAKE_MODULE_PATH |
| 12 | ${CMAKE_CURRENT_LIST_DIR}/cmake/ |
| 13 | ) |
| 14 | |
Cindy Liu | 48f6baf | 2021-07-28 20:42:34 -0700 | [diff] [blame] | 15 | set(BUILD_RV64_LINUX OFF CACHE BOOL "Build RISC-V 64-bit Linux target (default: OFF)") |
Cindy Liu | 151e5c2 | 2021-11-12 18:59:32 -0800 | [diff] [blame] | 16 | set(BUILD_INTERNAL_MODELS OFF CACHE BOOL "Build applications from internal models (default: OFF)") |
Cindy Liu | c250abf | 2021-11-11 19:23:54 -0800 | [diff] [blame] | 17 | set(IREE_SOURCE_DIR "$ENV{ROOTDIR}/toolchain/iree" CACHE PATH |
| 18 | "IREE source code path. (default: $ENV{ROOTDIR}/toolchain/iree)") |
Cindy Liu | 14c5390 | 2021-08-03 21:34:00 +0000 | [diff] [blame] | 19 | |
Cindy Liu | 71b163b | 2021-09-07 15:35:46 -0700 | [diff] [blame] | 20 | # Use nano spec header and libraries. |
| 21 | if(NOT ${BUILD_RV64_LINUX}) |
| 22 | include_directories(BEFORE SYSTEM "${RISCV_TOOLCHAIN_ROOT}/riscv32-unknown-elf/include/newlib-nano/") |
| 23 | link_directories(BEFORE "${RISCV_TOOLCHAIN_ROOT}/riscv32-unknown-elf/lib/newlib-nano/") |
| 24 | endif() |
| 25 | |
Cindy Liu | 14c5390 | 2021-08-03 21:34:00 +0000 | [diff] [blame] | 26 | #------------------------------------------------------------------------------- |
| 27 | # Springbok-specific settings |
| 28 | #------------------------------------------------------------------------------- |
Cindy Liu | 52b2fef | 2021-10-06 12:17:49 -0700 | [diff] [blame] | 29 | set(DTCM_LENGTH "16M" CACHE STRING "DTCM Length (default: 16M)") |
Lun Dong | e0f26a6 | 2021-09-18 02:59:42 +0000 | [diff] [blame] | 30 | add_link_options("LINKER:--defsym=__dtcm_length__=${DTCM_LENGTH}") |
Cindy Liu | 48f6baf | 2021-07-28 20:42:34 -0700 | [diff] [blame] | 31 | set(ITCM_LENGTH "256K" CACHE STRING "ITCM (I-mem) Length (default: 256K)") |
| 32 | add_link_options("LINKER:--defsym=__itcm_length__=${ITCM_LENGTH}") |
| 33 | set(STACK_SIZE "10K" CACHE STRING "Stack size (default: 10K)") |
| 34 | add_link_options("LINKER:--defsym=__stack_size__=${STACK_SIZE}") |
Cindy Liu | 14c5390 | 2021-08-03 21:34:00 +0000 | [diff] [blame] | 35 | set(SPRINGBOK_LINKER_SCRIPT "$ENV{ROOTDIR}/sw/vec/springbok/matcha.ld" CACHE PATH "Springbok linker script path (default: matcha.ld)") |
Cindy Liu | b503b1b | 2021-08-18 11:37:08 -0700 | [diff] [blame] | 36 | set(BUILD_WITH_SPRINGBOK ON CACHE BOOL "Build the target with springbok BSP (default: ON)") |
Cindy Liu | 48f6baf | 2021-07-28 20:42:34 -0700 | [diff] [blame] | 37 | |
| 38 | #------------------------------------------------------------------------------- |
| 39 | # IREE-specific settings |
| 40 | #------------------------------------------------------------------------------- |
| 41 | set(IREE_BUILD_COMPILER OFF) |
| 42 | set(IREE_ENABLE_MLIR OFF) |
Cindy Liu | 14b9032 | 2021-09-29 21:08:50 -0700 | [diff] [blame] | 43 | set(IREE_BUILD_SAMPLES OFF) |
Cindy Liu | 48f6baf | 2021-07-28 20:42:34 -0700 | [diff] [blame] | 44 | set(IREE_ENABLE_THREADING OFF) |
| 45 | set(IREE_BUILD_TESTS OFF) |
| 46 | set(IREE_BUILD_BINDINGS_TFLITE OFF) |
Cindy Liu | 0af5fb0 | 2021-12-24 11:14:01 -0800 | [diff] [blame] | 47 | set(IREE_HAL_DRIVER_DEFAULTS OFF CACHE BOOL "" FORCE) |
| 48 | set(IREE_HAL_DRIVER_VMVX_SYNC ON CACHE BOOL "" FORCE) |
| 49 | set(IREE_HAL_DRIVER_DYLIB_SYNC ON CACHE BOOL "" FORCE) |
Cindy Liu | 48f6baf | 2021-07-28 20:42:34 -0700 | [diff] [blame] | 50 | |
| 51 | #------------------------------------------------------------------------------- |
| 52 | # IREE-specific definitions |
| 53 | #------------------------------------------------------------------------------- |
| 54 | set(SPRINGBOK_CONFIG_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/springbok_config.h") |
| 55 | add_definitions(-DFLATCC_USE_GENERIC_ALIGNED_ALLOC) |
| 56 | if(NOT ${BUILD_RV64_LINUX}) |
| 57 | add_definitions(-DIREE_PLATFORM_GENERIC) |
| 58 | add_definitions(-DIREE_SYNCHRONIZATION_DISABLE_UNSAFE=1) |
| 59 | add_definitions(-DIREE_FILE_IO_ENABLE=0) |
| 60 | add_definitions(-DIREE_USER_CONFIG_H="${SPRINGBOK_CONFIG_HEADER}") |
| 61 | endif() |
| 62 | |
Cindy Liu | 151e5c2 | 2021-11-12 18:59:32 -0800 | [diff] [blame] | 63 | # The project does a cmake hack here -- at the executable linkage stage, we |
| 64 | # append the logging library (and springbok BSP). Any logging library update |
| 65 | # (libspringbok.a or libnative_log.a) only gets rebuilt during executable |
| 66 | # linkage, but not during library compilation. |
| 67 | # |
| 68 | # However, an explicit include path gets added here across all targets so the |
| 69 | # header files can be found during compilation. |
Cindy Liu | b503b1b | 2021-08-18 11:37:08 -0700 | [diff] [blame] | 70 | if(${BUILD_WITH_SPRINGBOK}) |
Cindy Liu | 151e5c2 | 2021-11-12 18:59:32 -0800 | [diff] [blame] | 71 | # Springbok BSP-related setting |
| 72 | add_subdirectory($ENV{ROOTDIR}/sw/vec/springbok springbok) |
Cindy Liu | ff71451 | 2021-08-26 16:22:12 -0700 | [diff] [blame] | 73 | include(riscv_springbok) |
Cindy Liu | b503b1b | 2021-08-18 11:37:08 -0700 | [diff] [blame] | 74 | include_directories($ENV{ROOTDIR}/sw/vec/springbok/include) |
Cindy Liu | 5c76581 | 2021-09-03 02:04:56 -0700 | [diff] [blame] | 75 | else() |
Cindy Liu | 151e5c2 | 2021-11-12 18:59:32 -0800 | [diff] [blame] | 76 | # Add the springbok printout support. |
| 77 | add_subdirectory(native_log) |
| 78 | include(riscv_native_log) |
| 79 | include_directories(native_log) |
Cindy Liu | b503b1b | 2021-08-18 11:37:08 -0700 | [diff] [blame] | 80 | endif() |
Cindy Liu | 14c5390 | 2021-08-03 21:34:00 +0000 | [diff] [blame] | 81 | |
Cindy Liu | c250abf | 2021-11-11 19:23:54 -0800 | [diff] [blame] | 82 | message(STATUS "Include IREE source at ${IREE_SOURCE_DIR}") |
Cindy Liu | 986ee24 | 2021-07-29 23:23:17 -0700 | [diff] [blame] | 83 | # Build IREE runtime libraries. |
Cindy Liu | c250abf | 2021-11-11 19:23:54 -0800 | [diff] [blame] | 84 | add_subdirectory(${IREE_SOURCE_DIR} iree) |
Cindy Liu | 986ee24 | 2021-07-29 23:23:17 -0700 | [diff] [blame] | 85 | |
| 86 | # Apply IREE's CMake variables and build options so we can use IREE build |
| 87 | # functions properly in this project. |
Cindy Liu | c250abf | 2021-11-11 19:23:54 -0800 | [diff] [blame] | 88 | include(${IREE_SOURCE_DIR}/build_tools/cmake/iree_copts.cmake) |
Cindy Liu | 986ee24 | 2021-07-29 23:23:17 -0700 | [diff] [blame] | 89 | |
Cindy Liu | ff71451 | 2021-08-26 16:22:12 -0700 | [diff] [blame] | 90 | include(springbok_bytecode_module) |
Lun Dong | 72890d0 | 2021-12-03 18:51:03 -0800 | [diff] [blame] | 91 | include(springbok_c_module) |
| 92 | include(springbok_modules) |
Lun Dong | db85fd7 | 2021-11-02 02:39:48 -0700 | [diff] [blame] | 93 | include(iree_model_input) |
Cindy Liu | 986ee24 | 2021-07-29 23:23:17 -0700 | [diff] [blame] | 94 | # Add the included directory here. |
| 95 | add_subdirectory(samples) |