compilation_on_macos.yml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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. paths-ignore:
  8. - "assembly-script/**"
  9. - "ci/**"
  10. - "doc/**"
  11. - "test-tools/**"
  12. - ".github/workflows/compilation_on_macos.yml"
  13. # will be triggered on push events
  14. push:
  15. paths-ignore:
  16. - "assembly-script/**"
  17. - "ci/**"
  18. - "doc/**"
  19. - "test-tools/**"
  20. - ".github/workflows/compilation_on_macos.yml"
  21. # allow to be triggered manually
  22. workflow_dispatch:
  23. # Cancel any in-flight jobs for the same PR/branch so there's only one active
  24. # at a time
  25. concurrency:
  26. group: ${{ github.workflow }}-${{ github.ref }}
  27. cancel-in-progress: true
  28. env:
  29. 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"
  30. 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"
  31. 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"
  32. 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"
  33. MC_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"
  34. LLVM_CACHE_SUFFIX: "build-llvm_libraries_ex"
  35. jobs:
  36. # Cancel any in-flight jobs for the same PR/branch so there's only one active
  37. # at a time
  38. cancel_previous:
  39. runs-on: ${{ matrix.os }}
  40. strategy:
  41. matrix:
  42. os: [macos-latest]
  43. steps:
  44. - name: Cancel Workflow Action
  45. uses: styfle/cancel-workflow-action@0.9.1
  46. with:
  47. access_token: ${{ github.token }}
  48. # set different traffic lights based on the current repo and the running OS.
  49. # according to light colors, the workflow will run different jobs
  50. check_repo:
  51. needs: cancel_previous
  52. runs-on: ${{ matrix.os }}
  53. strategy:
  54. matrix:
  55. os: [macos-latest]
  56. outputs:
  57. traffic_light: ${{ steps.do_check.outputs.light }}
  58. steps:
  59. - name: do_check
  60. id: do_check
  61. if: ${{ matrix.os == 'macos-latest' }}
  62. run: |
  63. if [[ ${{ github.repository }} == */wasm-micro-runtime ]]; then
  64. echo "::set-output name=light::green"
  65. else
  66. echo "::set-output name=light::red"
  67. fi
  68. build_llvm_libraries:
  69. needs: check_repo
  70. runs-on: ${{ matrix.os }}
  71. strategy:
  72. matrix:
  73. os: [macos-latest]
  74. include:
  75. - os: macos-latest
  76. light: ${{ needs.check_repo.outputs.traffic_light }}
  77. steps:
  78. - name: light status
  79. run: echo "matrix.os=${{ matrix.os }}, light=${{ matrix.light }}"
  80. - name: checkout
  81. if: ${{ matrix.light == 'green' }}
  82. uses: actions/checkout@v3
  83. - name: Cache LLVM libraries
  84. id: cache_llvm
  85. if: ${{ matrix.light == 'green' }}
  86. uses: actions/cache@v3
  87. with:
  88. path: |
  89. ./core/deps/llvm/build/bin
  90. ./core/deps/llvm/build/include
  91. ./core/deps/llvm/build/lib
  92. ./core/deps/llvm/build/libexec
  93. ./core/deps/llvm/build/share
  94. key: ${{ matrix.os }}-${{ env.LLVM_CACHE_SUFFIX }}
  95. - name: Build llvm and clang from source
  96. id: build_llvm
  97. if: ${{ matrix.light == 'green' && steps.cache_llvm.outputs.cache-hit != 'true' }}
  98. run: /usr/bin/env python3 ./build_llvm.py --arch X86 WebAssembly
  99. working-directory: build-scripts
  100. build_wamrc:
  101. needs: [build_llvm_libraries, check_repo]
  102. runs-on: ${{ matrix.os }}
  103. strategy:
  104. matrix:
  105. os: [macos-latest]
  106. include:
  107. - os: macos-latest
  108. light: ${{ needs.check_repo.outputs.traffic_light }}
  109. steps:
  110. - name: light status
  111. run: echo "matrix.os=${{ matrix.os }}, light=${{ matrix.light }}"
  112. - name: checkout
  113. if: ${{ matrix.light == 'green' }}
  114. uses: actions/checkout@v3
  115. - name: Get LLVM libraries
  116. id: cache_llvm
  117. if: ${{ matrix.light == 'green' }}
  118. uses: actions/cache@v3
  119. with:
  120. path: |
  121. ./core/deps/llvm/build/bin
  122. ./core/deps/llvm/build/include
  123. ./core/deps/llvm/build/lib
  124. ./core/deps/llvm/build/libexec
  125. ./core/deps/llvm/build/share
  126. key: ${{ matrix.os }}-${{ env.LLVM_CACHE_SUFFIX }}
  127. - name: Quit if cache miss
  128. if: ${{ matrix.light == 'green' && steps.cache_llvm.outputs.cache-hit != 'true' }}
  129. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  130. - name: Build wamrc
  131. if: ${{ matrix.light == 'green' }}
  132. run: |
  133. mkdir build && cd build
  134. cmake ..
  135. cmake --build . --config Release --parallel 4
  136. working-directory: wamr-compiler
  137. build_iwasm:
  138. needs: [build_llvm_libraries, check_repo]
  139. runs-on: ${{ matrix.os }}
  140. strategy:
  141. matrix:
  142. make_options_run_mode: [
  143. # Running mode
  144. $AOT_BUILD_OPTIONS,
  145. $CLASSIC_INTERP_BUILD_OPTIONS,
  146. $FAST_INTERP_BUILD_OPTIONS,
  147. $LAZY_JIT_BUILD_OPTIONS,
  148. $MC_JIT_BUILD_OPTIONS,
  149. ]
  150. make_options_feature: [
  151. # Features
  152. "-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
  153. # doesn't support
  154. #"-DWAMR_BUILD_DEBUG_AOT=1",
  155. "-DWAMR_BUILD_DEBUG_INTERP=1",
  156. "-DWAMR_BUILD_DUMP_CALL_STACK=1",
  157. "-DWAMR_BUILD_LIB_PTHREAD=1",
  158. "-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1",
  159. "-DWAMR_BUILD_MINI_LOADER=1",
  160. "-DWAMR_BUILD_MEMORY_PROFILING=1",
  161. "-DWAMR_BUILD_MULTI_MODULE=1",
  162. "-DWAMR_BUILD_PERF_PROFILING=1",
  163. "-DWAMR_BUILD_REF_TYPES=1",
  164. "-DWAMR_BUILD_SIMD=1",
  165. "-DWAMR_BUILD_TAIL_CALL=1",
  166. "-DWAMR_DISABLE_HW_BOUND_CHECK=1",
  167. ]
  168. os: [macos-latest]
  169. platform: [darwin]
  170. exclude:
  171. # uncompatiable feature and platform
  172. # uncompatiable mode and feature
  173. # MULTI_MODULE only on INTERP mode
  174. - make_options_run_mode: $LAZY_JIT_BUILD_OPTIONS
  175. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  176. - make_options_run_mode: $AOT_BUILD_OPTIONS
  177. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  178. - make_options_run_mode: $MC_JIT_BUILD_OPTIONS
  179. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  180. # SIMD only on JIT/AOT mode
  181. - make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
  182. make_options_feature: "-DWAMR_BUILD_SIMD=1"
  183. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  184. make_options_feature: "-DWAMR_BUILD_SIMD=1"
  185. # DEBUG_INTERP only on CLASSIC INTERP mode
  186. - make_options_run_mode: $AOT_BUILD_OPTIONS
  187. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  188. - make_options_run_mode: $LAZY_JIT_BUILD_OPTIONS
  189. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  190. - make_options_run_mode: $MC_JIT_BUILD_OPTIONS
  191. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  192. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  193. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  194. # DEBUG_AOT only on JIT/AOT mode
  195. - make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
  196. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  197. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  198. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  199. # TODO: DEBUG_AOT on JIT
  200. - make_options_run_mode: $LAZY_JIT_BUILD_OPTIONS
  201. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  202. - make_options_run_mode: $MC_JIT_BUILD_OPTIONS
  203. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  204. # MINI_LOADER only on INTERP mode
  205. - make_options_run_mode: $AOT_BUILD_OPTIONS
  206. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  207. - make_options_run_mode: $LAZY_JIT_BUILD_OPTIONS
  208. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  209. - make_options_run_mode: $MC_JIT_BUILD_OPTIONS
  210. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  211. include:
  212. - os: macos-latest
  213. light: ${{ needs.check_repo.outputs.traffic_light }}
  214. steps:
  215. - name: light status
  216. run: echo "matrix.os=${{ matrix.os }}, light=${{ matrix.light }}"
  217. - name: checkout
  218. if: ${{ matrix.light == 'green' }}
  219. uses: actions/checkout@v3
  220. # only download llvm cache when needed
  221. - name: Get LLVM libraries
  222. id: cache_llvm
  223. if: (matrix.light == 'green') && (endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS'))
  224. uses: actions/cache@v3
  225. with:
  226. path: |
  227. ./core/deps/llvm/build/bin
  228. ./core/deps/llvm/build/include
  229. ./core/deps/llvm/build/lib
  230. ./core/deps/llvm/build/libexec
  231. ./core/deps/llvm/build/share
  232. key: ${{ matrix.os }}-${{ env.LLVM_CACHE_SUFFIX }}
  233. - name: Quit if cache miss
  234. if: (matrix.light == 'green') && (endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS')) && (steps.cache_llvm.outputs.cache-hit != 'true')
  235. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  236. - name: Build iwasm
  237. if: ${{ matrix.light == 'green' }}
  238. run: |
  239. mkdir build && cd build
  240. cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
  241. cmake --build . --config Release --parallel 4
  242. working-directory: product-mini/platforms/${{ matrix.platform }}
  243. build_samples_wasm_c_api:
  244. needs: [build_iwasm, check_repo]
  245. runs-on: ${{ matrix.os }}
  246. strategy:
  247. matrix:
  248. make_options: [
  249. # Running mode
  250. $CLASSIC_INTERP_BUILD_OPTIONS,
  251. $FAST_INTERP_BUILD_OPTIONS,
  252. # doesn't support
  253. #$LAZY_JIT_BUILD_OPTIONS,
  254. #$MC_JIT_BUILD_OPTIONS,
  255. #$AOT_BUILD_OPTIONS,
  256. ]
  257. os: [macos-latest]
  258. include:
  259. - os: macos-latest
  260. light: ${{ needs.check_repo.outputs.traffic_light }}
  261. wasi_sdk_release: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-macos.tar.gz
  262. wabt_release: https://github.com/WebAssembly/wabt/releases/download/1.0.24/wabt-1.0.24-macos.tar.gz
  263. steps:
  264. - name: light status
  265. run: echo "matrix.os=${{ matrix.os }}, light=${{ matrix.light }}"
  266. - name: checkout
  267. if: ${{ matrix.light == 'green' }}
  268. uses: actions/checkout@v3
  269. - name: download and install wabt
  270. if: ${{ matrix.light == 'green' }}
  271. run: |
  272. cd /opt
  273. sudo wget ${{ matrix.wabt_release }}
  274. sudo tar -xzf wabt-1.0.24-*.tar.gz
  275. sudo mv wabt-1.0.24 wabt
  276. - name: Build Sample [wasm-c-api]
  277. if: ${{ matrix.light == 'green' }}
  278. run: |
  279. mkdir build && cd build
  280. cmake .. ${{ matrix.make_options }}
  281. cmake --build . --config Release --parallel 4
  282. ./callback
  283. ./callback_chain
  284. ./empty_imports
  285. ./global
  286. ./hello
  287. ./hostref
  288. ./memory
  289. ./reflect
  290. ./table
  291. ./trap
  292. working-directory: samples/wasm-c-api
  293. build_samples_others:
  294. needs: [build_iwasm, check_repo]
  295. runs-on: ${{ matrix.os }}
  296. strategy:
  297. matrix:
  298. include:
  299. - os: macos-latest
  300. light: ${{ needs.check_repo.outputs.traffic_light }}
  301. wasi_sdk_release: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-macos.tar.gz
  302. wabt_release: https://github.com/WebAssembly/wabt/releases/download/1.0.24/wabt-1.0.24-macos.tar.gz
  303. steps:
  304. - name: light status
  305. run: echo "matrix.os=${{ matrix.os }}, light=${{ matrix.light }}"
  306. - name: checkout
  307. if: ${{ matrix.light == 'green' }}
  308. uses: actions/checkout@v3
  309. - name: download and install wasi-sdk
  310. if: ${{ matrix.light == 'green' }}
  311. run: |
  312. cd /opt
  313. sudo wget ${{ matrix.wasi_sdk_release }}
  314. sudo tar -xzf wasi-sdk-12.0-*.tar.gz
  315. sudo mv wasi-sdk-12.0 wasi-sdk
  316. - name: download and install wabt
  317. if: ${{ matrix.light == 'green' }}
  318. run: |
  319. cd /opt
  320. sudo wget ${{ matrix.wabt_release }}
  321. sudo tar -xzf wabt-1.0.24-*.tar.gz
  322. sudo mv wabt-1.0.24 wabt
  323. - name: Build Sample [basic]
  324. if: ${{ matrix.light == 'green' }}
  325. run: |
  326. cd samples/basic
  327. ./build.sh
  328. ./run.sh
  329. - name: Build Sample [file]
  330. if: ${{ matrix.light == 'green' }}
  331. run: |
  332. cd samples/file
  333. mkdir build && cd build
  334. cmake ..
  335. cmake --build . --config Release --parallel 4
  336. ./src/iwasm -f wasm-app/file.wasm -d .
  337. - name: Build Sample [multi-thread]
  338. if: ${{ matrix.light == 'green' }}
  339. run: |
  340. cd samples/multi-thread
  341. mkdir build && cd build
  342. cmake ..
  343. cmake --build . --config Release --parallel 4
  344. ./iwasm wasm-apps/test.wasm
  345. - name: Build Sample [multi-module]
  346. if: ${{ matrix.light == 'green' }}
  347. run: |
  348. cd samples/multi-module
  349. mkdir build && cd build
  350. cmake ..
  351. cmake --build . --config Release --parallel 4
  352. ./multi_module
  353. - name: Build Sample [spawn-thread]
  354. if: ${{ matrix.light == 'green' }}
  355. run: |
  356. cd samples/spawn-thread
  357. mkdir build && cd build
  358. cmake ..
  359. cmake --build . --config Release --parallel 4
  360. ./spawn_thread
  361. - name: Build Sample [ref-types]
  362. if: ${{ matrix.light == 'green' }}
  363. run: |
  364. cd samples/ref-types
  365. mkdir build && cd build
  366. cmake ..
  367. cmake --build . --config Release --parallel 4
  368. ./hello