iwasm_fast_jit.cmake 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. # Yes. To solve the compatibility issue with CMAKE (>= 4.0), we need to update
  4. # our `cmake_minimum_required()` to 3.5. However, there are CMakeLists.txt
  5. # from 3rd parties that we should not alter. Therefore, in addition to
  6. # changing the `cmake_minimum_required()`, we should also add a configuration
  7. # here that is compatible with earlier versions.
  8. set(CMAKE_POLICY_VERSION_MINIMUM 3.5 FORCE)
  9. set (IWASM_FAST_JIT_DIR ${CMAKE_CURRENT_LIST_DIR})
  10. add_definitions(-DWASM_ENABLE_FAST_JIT=1)
  11. if (WAMR_BUILD_FAST_JIT_DUMP EQUAL 1)
  12. add_definitions(-DWASM_ENABLE_FAST_JIT_DUMP=1)
  13. endif ()
  14. include_directories (${IWASM_FAST_JIT_DIR})
  15. enable_language(CXX)
  16. if (WAMR_BUILD_TARGET STREQUAL "X86_64" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
  17. include(FetchContent)
  18. if (NOT WAMR_BUILD_PLATFORM STREQUAL "linux-sgx")
  19. FetchContent_Declare(
  20. asmjit
  21. GIT_REPOSITORY https://github.com/asmjit/asmjit.git
  22. GIT_TAG c1019f1642a588107148f64ba54584b0ae3ec8d1
  23. )
  24. else ()
  25. FetchContent_Declare(
  26. asmjit
  27. GIT_REPOSITORY https://github.com/asmjit/asmjit.git
  28. GIT_TAG c1019f1642a588107148f64ba54584b0ae3ec8d1
  29. PATCH_COMMAND git apply ${IWASM_FAST_JIT_DIR}/asmjit_sgx_patch.diff
  30. )
  31. endif ()
  32. FetchContent_GetProperties(asmjit)
  33. if (NOT asmjit_POPULATED)
  34. message ("-- Fetching asmjit ..")
  35. FetchContent_Populate(asmjit)
  36. add_definitions(-DASMJIT_STATIC)
  37. add_definitions(-DASMJIT_NO_DEPRECATED)
  38. add_definitions(-DASMJIT_NO_BUILDER)
  39. add_definitions(-DASMJIT_NO_COMPILER)
  40. add_definitions(-DASMJIT_NO_JIT)
  41. add_definitions(-DASMJIT_NO_LOGGING)
  42. add_definitions(-DASMJIT_NO_TEXT)
  43. add_definitions(-DASMJIT_NO_VALIDATION)
  44. add_definitions(-DASMJIT_NO_INTROSPECTION)
  45. add_definitions(-DASMJIT_NO_INTRINSICS)
  46. add_definitions(-DASMJIT_NO_AARCH64)
  47. add_definitions(-DASMJIT_NO_AARCH32)
  48. include_directories("${asmjit_SOURCE_DIR}/src")
  49. add_subdirectory(${asmjit_SOURCE_DIR} ${asmjit_BINARY_DIR} EXCLUDE_FROM_ALL)
  50. file (GLOB_RECURSE cpp_source_asmjit
  51. ${asmjit_SOURCE_DIR}/src/asmjit/core/*.cpp
  52. ${asmjit_SOURCE_DIR}/src/asmjit/x86/*.cpp
  53. )
  54. endif ()
  55. if (WAMR_BUILD_FAST_JIT_DUMP EQUAL 1)
  56. FetchContent_Declare(
  57. zycore
  58. GIT_REPOSITORY https://github.com/zyantific/zycore-c.git
  59. )
  60. FetchContent_GetProperties(zycore)
  61. if (NOT zycore_POPULATED)
  62. message ("-- Fetching zycore ..")
  63. FetchContent_Populate(zycore)
  64. option(ZYDIS_BUILD_TOOLS "" OFF)
  65. option(ZYDIS_BUILD_EXAMPLES "" OFF)
  66. include_directories("${zycore_SOURCE_DIR}/include")
  67. include_directories("${zycore_BINARY_DIR}")
  68. add_subdirectory(${zycore_SOURCE_DIR} ${zycore_BINARY_DIR} EXCLUDE_FROM_ALL)
  69. file (GLOB_RECURSE c_source_zycore ${zycore_SOURCE_DIR}/src/*.c)
  70. endif ()
  71. FetchContent_Declare(
  72. zydis
  73. GIT_REPOSITORY https://github.com/zyantific/zydis.git
  74. GIT_TAG e14a07895136182a5b53e181eec3b1c6e0b434de
  75. )
  76. FetchContent_GetProperties(zydis)
  77. if (NOT zydis_POPULATED)
  78. message ("-- Fetching zydis ..")
  79. FetchContent_Populate(zydis)
  80. option(ZYDIS_BUILD_TOOLS "" OFF)
  81. option(ZYDIS_BUILD_EXAMPLES "" OFF)
  82. include_directories("${zydis_BINARY_DIR}")
  83. include_directories("${zydis_SOURCE_DIR}/include")
  84. include_directories("${zydis_SOURCE_DIR}/src")
  85. add_subdirectory(${zydis_SOURCE_DIR} ${zydis_BINARY_DIR} EXCLUDE_FROM_ALL)
  86. file (GLOB_RECURSE c_source_zydis ${zydis_SOURCE_DIR}/src/*.c)
  87. endif ()
  88. endif ()
  89. endif ()
  90. file (GLOB c_source_jit ${IWASM_FAST_JIT_DIR}/*.c ${IWASM_FAST_JIT_DIR}/fe/*.c)
  91. if (WAMR_BUILD_TARGET STREQUAL "X86_64" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
  92. file (GLOB_RECURSE cpp_source_jit_cg ${IWASM_FAST_JIT_DIR}/cg/x86-64/*.cpp)
  93. else ()
  94. message (FATAL_ERROR "Fast JIT codegen for target ${WAMR_BUILD_TARGET} isn't implemented")
  95. endif ()
  96. set (IWASM_FAST_JIT_SOURCE ${c_source_jit} ${cpp_source_jit_cg}
  97. ${cpp_source_asmjit} ${c_source_zycore} ${c_source_zydis})