iwasm_common.cmake 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. set (IWASM_COMMON_DIR ${CMAKE_CURRENT_LIST_DIR})
  4. include_directories (${IWASM_COMMON_DIR})
  5. add_definitions(-DBH_MALLOC=wasm_runtime_malloc)
  6. add_definitions(-DBH_FREE=wasm_runtime_free)
  7. file (GLOB c_source_all ${IWASM_COMMON_DIR}/*.c)
  8. if (WAMR_BUILD_TARGET STREQUAL "X86_64" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
  9. if (WAMR_BUILD_PLATFORM STREQUAL "windows")
  10. set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_em64.asm)
  11. else ()
  12. set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_em64.s)
  13. endif ()
  14. elseif (WAMR_BUILD_TARGET STREQUAL "X86_32")
  15. if (WAMR_BUILD_PLATFORM STREQUAL "windows")
  16. set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_ia32.asm)
  17. else ()
  18. set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_ia32.s)
  19. endif ()
  20. elseif (WAMR_BUILD_TARGET MATCHES "ARM.*")
  21. if (WAMR_BUILD_TARGET MATCHES "ARM.*_VFP")
  22. set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_arm_vfp.s)
  23. else ()
  24. set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_arm.s)
  25. endif ()
  26. elseif (WAMR_BUILD_TARGET MATCHES "THUMB.*")
  27. if (WAMR_BUILD_TARGET MATCHES "THUMB.*_VFP")
  28. set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_thumb_vfp.s)
  29. else ()
  30. set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_thumb.s)
  31. endif ()
  32. elseif (WAMR_BUILD_TARGET MATCHES "AARCH64.*")
  33. set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_aarch64.s)
  34. elseif (WAMR_BUILD_TARGET STREQUAL "MIPS")
  35. set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_mips.s)
  36. elseif (WAMR_BUILD_TARGET STREQUAL "XTENSA")
  37. set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_xtensa.s)
  38. elseif (WAMR_BUILD_TARGET STREQUAL "GENERAL")
  39. # Use invokeNative_general.c instead of assembly code,
  40. # but the maximum number of native arguments is limited to 20,
  41. # and there are possible issues when passing arguments to
  42. # native function for some cpus, e.g. int64 and double arguments
  43. # in arm and mips need to be 8-bytes aligned, and some arguments
  44. # of x86_64 are passed by registers but not stack
  45. set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_general.c)
  46. else ()
  47. message (FATAL_ERROR "Build target isn't set")
  48. endif ()
  49. set (IWASM_COMMON_SOURCE ${source_all})