compilation_on_macos.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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. LLVM_CACHE_SUFFIX: "build-llvm_libraries_ex"
  51. jobs:
  52. build_llvm_libraries:
  53. uses: ./.github/workflows/build_llvm_libraries.yml
  54. with:
  55. runs-on: "['macos-latest']"
  56. build_wamrc:
  57. needs: [build_llvm_libraries]
  58. runs-on: ${{ matrix.os }}
  59. strategy:
  60. matrix:
  61. os: [macos-latest]
  62. steps:
  63. - name: checkout
  64. uses: actions/checkout@v3
  65. - name: Get LLVM libraries
  66. id: cache_llvm
  67. uses: actions/cache@v3
  68. with:
  69. path: |
  70. ./core/deps/llvm/build/bin
  71. ./core/deps/llvm/build/include
  72. ./core/deps/llvm/build/lib
  73. ./core/deps/llvm/build/libexec
  74. ./core/deps/llvm/build/share
  75. key: ${{ matrix.os }}-${{ env.LLVM_CACHE_SUFFIX }}
  76. - name: Quit if cache miss
  77. if: steps.cache_llvm.outputs.cache-hit != 'true'
  78. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  79. - name: Build wamrc
  80. run: |
  81. mkdir build && cd build
  82. cmake ..
  83. cmake --build . --config Release --parallel 4
  84. working-directory: wamr-compiler
  85. build_iwasm:
  86. needs: [build_llvm_libraries]
  87. runs-on: ${{ matrix.os }}
  88. strategy:
  89. matrix:
  90. make_options_run_mode: [
  91. # Running mode
  92. $AOT_BUILD_OPTIONS,
  93. $CLASSIC_INTERP_BUILD_OPTIONS,
  94. $FAST_INTERP_BUILD_OPTIONS,
  95. $LLVM_LAZY_JIT_BUILD_OPTIONS,
  96. $LLVM_EAGER_JIT_BUILD_OPTIONS,
  97. ]
  98. make_options_feature: [
  99. # Features
  100. "-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
  101. # doesn't support
  102. #"-DWAMR_BUILD_DEBUG_AOT=1",
  103. "-DWAMR_BUILD_DEBUG_INTERP=1",
  104. "-DWAMR_BUILD_DUMP_CALL_STACK=1",
  105. "-DWAMR_BUILD_LIB_PTHREAD=1",
  106. "-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1",
  107. "-DWAMR_BUILD_MINI_LOADER=1",
  108. "-DWAMR_BUILD_MEMORY_PROFILING=1",
  109. "-DWAMR_BUILD_MULTI_MODULE=1",
  110. "-DWAMR_BUILD_PERF_PROFILING=1",
  111. "-DWAMR_BUILD_REF_TYPES=1",
  112. "-DWAMR_BUILD_SIMD=1",
  113. "-DWAMR_BUILD_TAIL_CALL=1",
  114. "-DWAMR_DISABLE_HW_BOUND_CHECK=1",
  115. ]
  116. os: [macos-latest]
  117. platform: [darwin]
  118. exclude:
  119. # uncompatiable feature and platform
  120. # uncompatiable mode and feature
  121. # MULTI_MODULE only on INTERP mode
  122. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  123. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  124. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  125. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  126. - make_options_run_mode: $AOT_BUILD_OPTIONS
  127. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  128. # SIMD only on JIT/AOT mode
  129. - make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
  130. make_options_feature: "-DWAMR_BUILD_SIMD=1"
  131. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  132. make_options_feature: "-DWAMR_BUILD_SIMD=1"
  133. # DEBUG_INTERP only on CLASSIC INTERP mode
  134. - make_options_run_mode: $AOT_BUILD_OPTIONS
  135. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  136. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  137. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  138. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  139. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  140. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  141. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  142. # DEBUG_AOT only on JIT/AOT mode
  143. - make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
  144. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  145. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  146. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  147. # TODO: DEBUG_AOT on JIT
  148. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  149. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  150. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  151. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  152. # MINI_LOADER only on INTERP mode
  153. - make_options_run_mode: $AOT_BUILD_OPTIONS
  154. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  155. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  156. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  157. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  158. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  159. steps:
  160. - name: checkout
  161. uses: actions/checkout@v3
  162. # only download llvm cache when needed
  163. - name: Get LLVM libraries
  164. id: cache_llvm
  165. if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS')
  166. uses: actions/cache@v3
  167. with:
  168. path: |
  169. ./core/deps/llvm/build/bin
  170. ./core/deps/llvm/build/include
  171. ./core/deps/llvm/build/lib
  172. ./core/deps/llvm/build/libexec
  173. ./core/deps/llvm/build/share
  174. key: ${{ matrix.os }}-${{ env.LLVM_CACHE_SUFFIX }}
  175. - name: Quit if cache miss
  176. if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS') && (steps.cache_llvm.outputs.cache-hit != 'true')
  177. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  178. - name: Build iwasm
  179. run: |
  180. mkdir build && cd build
  181. cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
  182. cmake --build . --config Release --parallel 4
  183. working-directory: product-mini/platforms/${{ matrix.platform }}
  184. build_samples_wasm_c_api:
  185. needs: [build_iwasm]
  186. runs-on: ${{ matrix.os }}
  187. strategy:
  188. matrix:
  189. make_options: [
  190. # Running modes supported
  191. $CLASSIC_INTERP_BUILD_OPTIONS,
  192. $FAST_INTERP_BUILD_OPTIONS,
  193. # Running modes unsupported
  194. #$LLVM_LAZY_JIT_BUILD_OPTIONS,
  195. #$LLVM_EAGER_JIT_BUILD_OPTIONS,
  196. #$AOT_BUILD_OPTIONS,
  197. ]
  198. os: [macos-latest]
  199. wasi_sdk_release: ["https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-macos.tar.gz"]
  200. wabt_release: ["https://github.com/WebAssembly/wabt/releases/download/1.0.24/wabt-1.0.24-macos.tar.gz"]
  201. steps:
  202. - name: checkout
  203. uses: actions/checkout@v3
  204. - name: download and install wabt
  205. run: |
  206. cd /opt
  207. sudo wget ${{ matrix.wabt_release }}
  208. sudo tar -xzf wabt-1.0.24-*.tar.gz
  209. sudo mv wabt-1.0.24 wabt
  210. - name: Build Sample [wasm-c-api]
  211. run: |
  212. mkdir build && cd build
  213. cmake .. ${{ matrix.make_options }}
  214. cmake --build . --config Release --parallel 4
  215. ./callback
  216. ./callback_chain
  217. ./empty_imports
  218. ./global
  219. ./hello
  220. ./hostref
  221. ./memory
  222. ./reflect
  223. ./table
  224. ./trap
  225. working-directory: samples/wasm-c-api
  226. build_samples_others:
  227. needs: [build_iwasm]
  228. runs-on: ${{ matrix.os }}
  229. strategy:
  230. matrix:
  231. os: [macos-latest]
  232. wasi_sdk_release: ["https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-macos.tar.gz"]
  233. wabt_release: ["https://github.com/WebAssembly/wabt/releases/download/1.0.24/wabt-1.0.24-macos.tar.gz"]
  234. steps:
  235. - name: checkout
  236. uses: actions/checkout@v3
  237. - name: download and install wasi-sdk
  238. run: |
  239. cd /opt
  240. sudo wget ${{ matrix.wasi_sdk_release }}
  241. sudo tar -xzf wasi-sdk-12.0-*.tar.gz
  242. sudo mv wasi-sdk-12.0 wasi-sdk
  243. - name: download and install wabt
  244. run: |
  245. cd /opt
  246. sudo wget ${{ matrix.wabt_release }}
  247. sudo tar -xzf wabt-1.0.24-*.tar.gz
  248. sudo mv wabt-1.0.24 wabt
  249. - name: Build Sample [basic]
  250. run: |
  251. cd samples/basic
  252. ./build.sh
  253. ./run.sh
  254. - name: Build Sample [file]
  255. run: |
  256. cd samples/file
  257. mkdir build && cd build
  258. cmake ..
  259. cmake --build . --config Release --parallel 4
  260. ./src/iwasm -f wasm-app/file.wasm -d .
  261. - name: Build Sample [multi-thread]
  262. run: |
  263. cd samples/multi-thread
  264. mkdir build && cd build
  265. cmake ..
  266. cmake --build . --config Release --parallel 4
  267. ./iwasm wasm-apps/test.wasm
  268. - name: Build Sample [multi-module]
  269. run: |
  270. cd samples/multi-module
  271. mkdir build && cd build
  272. cmake ..
  273. cmake --build . --config Release --parallel 4
  274. ./multi_module
  275. - name: Build Sample [spawn-thread]
  276. run: |
  277. cd samples/spawn-thread
  278. mkdir build && cd build
  279. cmake ..
  280. cmake --build . --config Release --parallel 4
  281. ./spawn_thread
  282. - name: Build Sample [ref-types]
  283. run: |
  284. cd samples/ref-types
  285. mkdir build && cd build
  286. cmake ..
  287. cmake --build . --config Release --parallel 4
  288. ./hello