compilation_on_macos.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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 and AOT 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. # SIMD only on JIT/AOT mode
  132. - make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
  133. make_options_feature: "-DWAMR_BUILD_SIMD=1"
  134. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  135. make_options_feature: "-DWAMR_BUILD_SIMD=1"
  136. # DEBUG_INTERP only on CLASSIC INTERP mode
  137. - make_options_run_mode: $AOT_BUILD_OPTIONS
  138. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  139. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  140. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  141. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  142. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  143. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  144. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  145. # DEBUG_AOT only on JIT/AOT mode
  146. - make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
  147. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  148. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  149. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  150. # TODO: DEBUG_AOT on JIT
  151. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  152. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  153. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  154. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  155. # MINI_LOADER only on INTERP mode
  156. - make_options_run_mode: $AOT_BUILD_OPTIONS
  157. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  158. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  159. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  160. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  161. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  162. include:
  163. - os: macos-latest
  164. llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }}
  165. steps:
  166. - name: checkout
  167. uses: actions/checkout@v3
  168. # only download llvm cache when needed
  169. - name: Get LLVM libraries
  170. id: retrieve_llvm_libs
  171. if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS')
  172. uses: actions/cache@v3
  173. with:
  174. path: |
  175. ./core/deps/llvm/build/bin
  176. ./core/deps/llvm/build/include
  177. ./core/deps/llvm/build/lib
  178. ./core/deps/llvm/build/libexec
  179. ./core/deps/llvm/build/share
  180. key: ${{ matrix.llvm_cache_key }}
  181. - name: Quit if cache miss
  182. if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS') && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
  183. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  184. - name: Build iwasm
  185. run: |
  186. mkdir build && cd build
  187. cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
  188. cmake --build . --config Release --parallel 4
  189. working-directory: product-mini/platforms/${{ matrix.platform }}
  190. build_samples_wasm_c_api:
  191. needs: [build_iwasm]
  192. runs-on: ${{ matrix.os }}
  193. strategy:
  194. matrix:
  195. make_options: [
  196. # Running modes supported
  197. $CLASSIC_INTERP_BUILD_OPTIONS,
  198. $FAST_INTERP_BUILD_OPTIONS,
  199. # Running modes unsupported
  200. #$LLVM_LAZY_JIT_BUILD_OPTIONS,
  201. #$LLVM_EAGER_JIT_BUILD_OPTIONS,
  202. #$AOT_BUILD_OPTIONS,
  203. ]
  204. os: [macos-latest]
  205. wasi_sdk_release:
  206. [
  207. "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-macos.tar.gz",
  208. ]
  209. wabt_release:
  210. [
  211. "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-macos-12.tar.gz",
  212. ]
  213. steps:
  214. - name: checkout
  215. uses: actions/checkout@v3
  216. - name: download and install wabt
  217. run: |
  218. cd /opt
  219. sudo wget ${{ matrix.wabt_release }}
  220. sudo tar -xzf wabt-1.0.31-*.tar.gz
  221. sudo mv wabt-1.0.31 wabt
  222. - name: Build Sample [wasm-c-api]
  223. run: |
  224. cmake -S . -B build ${{ matrix.make_options }}
  225. cmake --build build --config Release --parallel 4
  226. ctest --test-dir build
  227. working-directory: samples/wasm-c-api
  228. build_samples_others:
  229. needs: [build_iwasm, build_wamrc]
  230. runs-on: ${{ matrix.os }}
  231. strategy:
  232. matrix:
  233. os: [macos-latest]
  234. wasi_sdk_release:
  235. [
  236. "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-macos.tar.gz",
  237. ]
  238. wabt_release:
  239. [
  240. "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-macos-12.tar.gz",
  241. ]
  242. steps:
  243. - name: checkout
  244. uses: actions/checkout@v3
  245. - name: download and install wasi-sdk
  246. run: |
  247. cd /opt
  248. sudo wget ${{ matrix.wasi_sdk_release }}
  249. sudo tar -xzf wasi-sdk-*.tar.gz
  250. sudo mv wasi-sdk-20.0 wasi-sdk
  251. - name: download and install wabt
  252. run: |
  253. cd /opt
  254. sudo wget ${{ matrix.wabt_release }}
  255. sudo tar -xzf wabt-1.0.31-*.tar.gz
  256. sudo mv wabt-1.0.31 wabt
  257. - name: Build Sample [basic]
  258. run: |
  259. cd samples/basic
  260. ./build.sh
  261. ./run.sh
  262. - name: Build Sample [file]
  263. run: |
  264. cd samples/file
  265. mkdir build && cd build
  266. cmake ..
  267. cmake --build . --config Debug --parallel 4
  268. ./src/iwasm -f wasm-app/file.wasm -d .
  269. - name: Build Sample [multi-thread]
  270. run: |
  271. cd samples/multi-thread
  272. mkdir build && cd build
  273. cmake ..
  274. cmake --build . --config Debug --parallel 4
  275. ./iwasm wasm-apps/test.wasm
  276. - name: Build Sample [multi-module]
  277. run: |
  278. cd samples/multi-module
  279. mkdir build && cd build
  280. cmake ..
  281. cmake --build . --config Debug --parallel 4
  282. ./multi_module mC.wasm
  283. - name: Build Sample [spawn-thread]
  284. run: |
  285. cd samples/spawn-thread
  286. mkdir build && cd build
  287. cmake ..
  288. cmake --build . --config Debug --parallel 4
  289. ./spawn_thread
  290. - name: Build Sample [ref-types]
  291. run: |
  292. cd samples/ref-types
  293. mkdir build && cd build
  294. cmake ..
  295. cmake --build . --config Debug --parallel 4
  296. ./hello
  297. - name: Build Sample [wasi-threads]
  298. run: |
  299. cd samples/wasi-threads
  300. mkdir build && cd build
  301. cmake ..
  302. cmake --build . --config Debug --parallel 4
  303. ./iwasm wasm-apps/no_pthread.wasm
  304. - name: Build Sample [shared-module]
  305. run: |
  306. cd samples/shared-module
  307. ./build.sh
  308. ./run.sh