compilation_on_macos.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. name: compilation on macos-latest
  4. on:
  5. # will be triggered on PR events
  6. pull_request:
  7. types:
  8. - opened
  9. - synchronize
  10. paths:
  11. - ".github/**"
  12. - "build-scripts/**"
  13. - "core/**"
  14. - "!core/deps/**"
  15. - "product-mini/**"
  16. - "samples/**"
  17. - "!samples/workload/**"
  18. - "tests/wamr-test-suites/**"
  19. - "wamr-compiler/**"
  20. - "wamr-sdk/**"
  21. # will be triggered on push events
  22. push:
  23. branches:
  24. - main
  25. - "dev/**"
  26. paths:
  27. - ".github/**"
  28. - "build-scripts/**"
  29. - "core/**"
  30. - "!core/deps/**"
  31. - "product-mini/**"
  32. - "samples/**"
  33. - "!samples/workload/**"
  34. - "tests/wamr-test-suites/**"
  35. - "wamr-compiler/**"
  36. - "wamr-sdk/**"
  37. # allow to be triggered manually
  38. workflow_dispatch:
  39. # Cancel any in-flight jobs for the same PR/branch so there's only one active
  40. # at a time
  41. concurrency:
  42. group: ${{ github.workflow }}-${{ github.ref }}
  43. cancel-in-progress: true
  44. env:
  45. AOT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
  46. CLASSIC_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
  47. FAST_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
  48. LLVM_LAZY_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
  49. LLVM_EAGER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0"
  50. jobs:
  51. build_llvm_libraries:
  52. uses: ./.github/workflows/build_llvm_libraries.yml
  53. with:
  54. os: "macos-latest"
  55. arch: "X86"
  56. build_wamrc:
  57. needs: [build_llvm_libraries]
  58. runs-on: ${{ matrix.os }}
  59. strategy:
  60. matrix:
  61. include:
  62. - os: macos-latest
  63. llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }}
  64. steps:
  65. - name: checkout
  66. uses: actions/checkout@v3
  67. - name: Get LLVM libraries
  68. id: retrieve_llvm_libs
  69. uses: actions/cache@v3
  70. with:
  71. path: |
  72. ./core/deps/llvm/build/bin
  73. ./core/deps/llvm/build/include
  74. ./core/deps/llvm/build/lib
  75. ./core/deps/llvm/build/libexec
  76. ./core/deps/llvm/build/share
  77. key: ${{ matrix.llvm_cache_key }}
  78. - name: Quit if cache miss
  79. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
  80. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  81. - name: Build wamrc
  82. run: |
  83. mkdir build && cd build
  84. cmake ..
  85. cmake --build . --config Release --parallel 4
  86. working-directory: wamr-compiler
  87. build_iwasm:
  88. needs: [build_llvm_libraries]
  89. runs-on: ${{ matrix.os }}
  90. strategy:
  91. matrix:
  92. make_options_run_mode: [
  93. # Running mode
  94. $AOT_BUILD_OPTIONS,
  95. $CLASSIC_INTERP_BUILD_OPTIONS,
  96. $FAST_INTERP_BUILD_OPTIONS,
  97. $LLVM_LAZY_JIT_BUILD_OPTIONS,
  98. $LLVM_EAGER_JIT_BUILD_OPTIONS,
  99. ]
  100. make_options_feature: [
  101. # Features
  102. "-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
  103. # doesn't support
  104. #"-DWAMR_BUILD_DEBUG_AOT=1",
  105. "-DWAMR_BUILD_DEBUG_INTERP=1",
  106. "-DWAMR_BUILD_DUMP_CALL_STACK=1",
  107. "-DWAMR_BUILD_LIB_PTHREAD=1",
  108. "-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1",
  109. "-DWAMR_BUILD_MINI_LOADER=1",
  110. "-DWAMR_BUILD_MEMORY_PROFILING=1",
  111. "-DWAMR_BUILD_MULTI_MODULE=1",
  112. "-DWAMR_BUILD_PERF_PROFILING=1",
  113. "-DWAMR_BUILD_REF_TYPES=1",
  114. "-DWAMR_BUILD_SIMD=1",
  115. "-DWAMR_BUILD_TAIL_CALL=1",
  116. "-DWAMR_DISABLE_HW_BOUND_CHECK=1",
  117. ]
  118. os: [macos-latest]
  119. platform: [darwin]
  120. exclude:
  121. # uncompatiable feature and platform
  122. # uncompatiable mode and feature
  123. # MULTI_MODULE only on INTERP mode
  124. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  125. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  126. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  127. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  128. - make_options_run_mode: $AOT_BUILD_OPTIONS
  129. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  130. # SIMD only on JIT/AOT mode
  131. - make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
  132. make_options_feature: "-DWAMR_BUILD_SIMD=1"
  133. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  134. make_options_feature: "-DWAMR_BUILD_SIMD=1"
  135. # DEBUG_INTERP only on CLASSIC INTERP mode
  136. - make_options_run_mode: $AOT_BUILD_OPTIONS
  137. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  138. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  139. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  140. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  141. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  142. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  143. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  144. # DEBUG_AOT only on JIT/AOT mode
  145. - make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
  146. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  147. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  148. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  149. # TODO: DEBUG_AOT on JIT
  150. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  151. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  152. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  153. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  154. # MINI_LOADER only on INTERP mode
  155. - make_options_run_mode: $AOT_BUILD_OPTIONS
  156. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  157. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  158. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  159. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  160. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  161. include:
  162. - os: macos-latest
  163. llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }}
  164. steps:
  165. - name: checkout
  166. uses: actions/checkout@v3
  167. # only download llvm cache when needed
  168. - name: Get LLVM libraries
  169. id: retrieve_llvm_libs
  170. if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS')
  171. uses: actions/cache@v3
  172. with:
  173. path: |
  174. ./core/deps/llvm/build/bin
  175. ./core/deps/llvm/build/include
  176. ./core/deps/llvm/build/lib
  177. ./core/deps/llvm/build/libexec
  178. ./core/deps/llvm/build/share
  179. key: ${{ matrix.llvm_cache_key }}
  180. - name: Quit if cache miss
  181. if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS') && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
  182. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  183. - name: Build iwasm
  184. run: |
  185. mkdir build && cd build
  186. cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
  187. cmake --build . --config Release --parallel 4
  188. working-directory: product-mini/platforms/${{ matrix.platform }}
  189. build_samples_wasm_c_api:
  190. needs: [build_iwasm]
  191. runs-on: ${{ matrix.os }}
  192. strategy:
  193. matrix:
  194. make_options: [
  195. # Running modes supported
  196. $CLASSIC_INTERP_BUILD_OPTIONS,
  197. $FAST_INTERP_BUILD_OPTIONS,
  198. # Running modes unsupported
  199. #$LLVM_LAZY_JIT_BUILD_OPTIONS,
  200. #$LLVM_EAGER_JIT_BUILD_OPTIONS,
  201. #$AOT_BUILD_OPTIONS,
  202. ]
  203. os: [macos-latest]
  204. wasi_sdk_release:
  205. [
  206. "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-macos.tar.gz",
  207. ]
  208. wabt_release:
  209. [
  210. "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-macos-12.tar.gz",
  211. ]
  212. steps:
  213. - name: checkout
  214. uses: actions/checkout@v3
  215. - name: download and install wabt
  216. run: |
  217. cd /opt
  218. sudo wget ${{ matrix.wabt_release }}
  219. sudo tar -xzf wabt-1.0.31-*.tar.gz
  220. sudo mv wabt-1.0.31 wabt
  221. - name: Build Sample [wasm-c-api]
  222. run: |
  223. cmake -S . -B build ${{ matrix.make_options }}
  224. cmake --build build --config Release --parallel 4
  225. ctest --test-dir build
  226. working-directory: samples/wasm-c-api
  227. build_samples_others:
  228. needs: [build_iwasm]
  229. runs-on: ${{ matrix.os }}
  230. strategy:
  231. matrix:
  232. os: [macos-latest]
  233. wasi_sdk_release:
  234. [
  235. "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20%2Bthreads/wasi-sdk-20.0.threads-macos.tar.gz",
  236. ]
  237. wabt_release:
  238. [
  239. "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-macos-12.tar.gz",
  240. ]
  241. steps:
  242. - name: checkout
  243. uses: actions/checkout@v3
  244. - name: download and install wasi-sdk
  245. run: |
  246. cd /opt
  247. sudo wget ${{ matrix.wasi_sdk_release }}
  248. sudo tar -xzf wasi-sdk-*.tar.gz
  249. sudo mv wasi-sdk-20.0+threads wasi-sdk
  250. - name: download and install wabt
  251. run: |
  252. cd /opt
  253. sudo wget ${{ matrix.wabt_release }}
  254. sudo tar -xzf wabt-1.0.31-*.tar.gz
  255. sudo mv wabt-1.0.31 wabt
  256. - name: Build Sample [basic]
  257. run: |
  258. cd samples/basic
  259. ./build.sh
  260. ./run.sh
  261. - name: Build Sample [file]
  262. run: |
  263. cd samples/file
  264. mkdir build && cd build
  265. cmake ..
  266. cmake --build . --config Release --parallel 4
  267. ./src/iwasm -f wasm-app/file.wasm -d .
  268. - name: Build Sample [multi-thread]
  269. run: |
  270. cd samples/multi-thread
  271. mkdir build && cd build
  272. cmake ..
  273. cmake --build . --config Release --parallel 4
  274. ./iwasm wasm-apps/test.wasm
  275. - name: Build Sample [multi-module]
  276. run: |
  277. cd samples/multi-module
  278. mkdir build && cd build
  279. cmake ..
  280. cmake --build . --config Release --parallel 4
  281. ./multi_module
  282. - name: Build Sample [spawn-thread]
  283. run: |
  284. cd samples/spawn-thread
  285. mkdir build && cd build
  286. cmake ..
  287. cmake --build . --config Release --parallel 4
  288. ./spawn_thread
  289. - name: Build Sample [ref-types]
  290. run: |
  291. cd samples/ref-types
  292. mkdir build && cd build
  293. cmake ..
  294. cmake --build . --config Release --parallel 4
  295. ./hello
  296. - name: Build Sample [wasi-threads]
  297. run: |
  298. cd samples/wasi-threads
  299. mkdir build && cd build
  300. cmake ..
  301. cmake --build . --config Release --parallel 4
  302. ./iwasm wasm-apps/no_pthread.wasm