compilation_on_macos.yml 11 KB

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