compilation_on_macos.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. name: compilation on macos
  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_on_intel_macos:
  54. uses: ./.github/workflows/build_llvm_libraries.yml
  55. with:
  56. os: "macos-latest"
  57. arch: "X86"
  58. build_llvm_libraries_on_arm_macos:
  59. uses: ./.github/workflows/build_llvm_libraries.yml
  60. with:
  61. os: "macos-14"
  62. arch: "AArch64 ARM"
  63. build_wamrc:
  64. needs: [build_llvm_libraries_on_intel_macos]
  65. runs-on: ${{ matrix.os }}
  66. strategy:
  67. matrix:
  68. include:
  69. - os: macos-latest
  70. llvm_cache_key: ${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}
  71. steps:
  72. - name: checkout
  73. uses: actions/checkout@v4
  74. - name: Get LLVM libraries
  75. id: retrieve_llvm_libs
  76. uses: actions/cache@v4
  77. with:
  78. path: |
  79. ./core/deps/llvm/build/bin
  80. ./core/deps/llvm/build/include
  81. ./core/deps/llvm/build/lib
  82. ./core/deps/llvm/build/libexec
  83. ./core/deps/llvm/build/share
  84. key: ${{ matrix.llvm_cache_key }}
  85. - name: Quit if cache miss
  86. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
  87. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  88. - name: Build wamrc
  89. run: |
  90. mkdir build && cd build
  91. cmake ..
  92. cmake --build . --config Release --parallel 4
  93. working-directory: wamr-compiler
  94. build_iwasm:
  95. needs: [build_llvm_libraries_on_intel_macos]
  96. runs-on: ${{ matrix.os }}
  97. strategy:
  98. matrix:
  99. make_options_run_mode: [
  100. # Running mode
  101. $AOT_BUILD_OPTIONS,
  102. $CLASSIC_INTERP_BUILD_OPTIONS,
  103. $FAST_INTERP_BUILD_OPTIONS,
  104. $LLVM_LAZY_JIT_BUILD_OPTIONS,
  105. $LLVM_EAGER_JIT_BUILD_OPTIONS,
  106. ]
  107. make_options_feature: [
  108. # Features
  109. "-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
  110. # doesn't support
  111. #"-DWAMR_BUILD_DEBUG_AOT=1",
  112. "-DWAMR_BUILD_DEBUG_INTERP=1",
  113. "-DWAMR_BUILD_DUMP_CALL_STACK=1",
  114. "-DWAMR_BUILD_LIB_PTHREAD=1",
  115. "-DWAMR_BUILD_LIB_WASI_THREADS=1",
  116. "-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1",
  117. "-DWAMR_BUILD_MINI_LOADER=1",
  118. "-DWAMR_BUILD_MEMORY_PROFILING=1",
  119. "-DWAMR_BUILD_MULTI_MODULE=1",
  120. "-DWAMR_BUILD_PERF_PROFILING=1",
  121. "-DWAMR_BUILD_REF_TYPES=1",
  122. "-DWAMR_BUILD_SIMD=1",
  123. "-DWAMR_BUILD_TAIL_CALL=1",
  124. "-DWAMR_DISABLE_HW_BOUND_CHECK=1",
  125. ]
  126. os: [macos-latest]
  127. platform: [darwin]
  128. exclude:
  129. # uncompatiable feature and platform
  130. # uncompatiable mode and feature
  131. # MULTI_MODULE only on INTERP mode and AOT mode
  132. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  133. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  134. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  135. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  136. # SIMD only on JIT/AOT mode
  137. - make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
  138. make_options_feature: "-DWAMR_BUILD_SIMD=1"
  139. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  140. make_options_feature: "-DWAMR_BUILD_SIMD=1"
  141. # DEBUG_INTERP only on CLASSIC INTERP mode
  142. - make_options_run_mode: $AOT_BUILD_OPTIONS
  143. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  144. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  145. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  146. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  147. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  148. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  149. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  150. # DEBUG_AOT only on JIT/AOT mode
  151. - make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
  152. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  153. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  154. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  155. # TODO: DEBUG_AOT on JIT
  156. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  157. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  158. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  159. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  160. # MINI_LOADER only on INTERP mode
  161. - make_options_run_mode: $AOT_BUILD_OPTIONS
  162. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  163. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  164. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  165. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  166. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  167. include:
  168. - os: macos-latest
  169. llvm_cache_key: ${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}
  170. steps:
  171. - name: checkout
  172. uses: actions/checkout@v4
  173. # only download llvm cache when needed
  174. - name: Get LLVM libraries
  175. id: retrieve_llvm_libs
  176. if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS')
  177. uses: actions/cache@v4
  178. with:
  179. path: |
  180. ./core/deps/llvm/build/bin
  181. ./core/deps/llvm/build/include
  182. ./core/deps/llvm/build/lib
  183. ./core/deps/llvm/build/libexec
  184. ./core/deps/llvm/build/share
  185. key: ${{ matrix.llvm_cache_key }}
  186. - name: Quit if cache miss
  187. if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS') && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
  188. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  189. - name: Build iwasm
  190. run: |
  191. mkdir build && cd build
  192. cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
  193. cmake --build . --config Release --parallel 4
  194. working-directory: product-mini/platforms/${{ matrix.platform }}
  195. build_samples_wasm_c_api:
  196. needs: [build_iwasm]
  197. runs-on: ${{ matrix.os }}
  198. strategy:
  199. matrix:
  200. make_options: [
  201. # Running modes supported
  202. $CLASSIC_INTERP_BUILD_OPTIONS,
  203. $FAST_INTERP_BUILD_OPTIONS,
  204. # Running modes unsupported
  205. #$LLVM_LAZY_JIT_BUILD_OPTIONS,
  206. #$LLVM_EAGER_JIT_BUILD_OPTIONS,
  207. #$AOT_BUILD_OPTIONS,
  208. ]
  209. os: [macos-latest]
  210. wasi_sdk_release:
  211. [
  212. "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-macos.tar.gz",
  213. ]
  214. wabt_release:
  215. [
  216. "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-macos-12.tar.gz",
  217. ]
  218. steps:
  219. - name: checkout
  220. uses: actions/checkout@v4
  221. - name: download and install wabt
  222. run: |
  223. cd /opt
  224. sudo wget ${{ matrix.wabt_release }}
  225. sudo tar -xzf wabt-1.0.31-*.tar.gz
  226. sudo mv wabt-1.0.31 wabt
  227. - name: Build Sample [wasm-c-api]
  228. run: |
  229. cmake -S . -B build ${{ matrix.make_options }}
  230. cmake --build build --config Release --parallel 4
  231. ctest --test-dir build
  232. working-directory: samples/wasm-c-api
  233. build_samples_others:
  234. needs: [build_iwasm, build_wamrc, build_llvm_libraries_on_intel_macos, build_llvm_libraries_on_arm_macos]
  235. runs-on: ${{ matrix.os }}
  236. strategy:
  237. matrix:
  238. os: [macos-latest, macos-14]
  239. wasi_sdk_release:
  240. [
  241. "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-macos.tar.gz",
  242. ]
  243. wabt_release:
  244. [
  245. "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-macos-12.tar.gz",
  246. ]
  247. include:
  248. - os: macos-latest
  249. llvm_cache_key: ${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}
  250. - os: macos-14
  251. llvm_cache_key: ${{ needs.build_llvm_libraries_on_arm_macos.outputs.cache_key }}
  252. steps:
  253. - name: checkout
  254. uses: actions/checkout@v4
  255. - name: download and install wasi-sdk
  256. run: |
  257. cd /opt
  258. sudo wget ${{ matrix.wasi_sdk_release }}
  259. sudo tar -xzf wasi-sdk-*.tar.gz
  260. sudo mv wasi-sdk-20.0 wasi-sdk
  261. - name: download and install wabt
  262. run: |
  263. cd /opt
  264. sudo wget ${{ matrix.wabt_release }}
  265. sudo tar -xzf wabt-1.0.31-*.tar.gz
  266. sudo mv wabt-1.0.31 wabt
  267. - name: Build Sample [basic]
  268. run: |
  269. cd samples/basic
  270. ./build.sh
  271. ./run.sh
  272. - name: Build Sample [file]
  273. run: |
  274. cd samples/file
  275. mkdir build && cd build
  276. cmake ..
  277. cmake --build . --config Debug --parallel 4
  278. ./src/iwasm -f wasm-app/file.wasm -d .
  279. - name: Build Sample [multi-thread]
  280. run: |
  281. cd samples/multi-thread
  282. mkdir build && cd build
  283. cmake ..
  284. cmake --build . --config Debug --parallel 4
  285. ./iwasm wasm-apps/test.wasm
  286. - name: Build Sample [multi-module]
  287. run: |
  288. cd samples/multi-module
  289. mkdir build && cd build
  290. cmake ..
  291. cmake --build . --config Debug --parallel 4
  292. ./multi_module mC.wasm
  293. - name: Build Sample [spawn-thread]
  294. run: |
  295. cd samples/spawn-thread
  296. mkdir build && cd build
  297. cmake ..
  298. cmake --build . --config Debug --parallel 4
  299. ./spawn_thread
  300. - name: Build Sample [ref-types]
  301. run: |
  302. cd samples/ref-types
  303. mkdir build && cd build
  304. cmake ..
  305. cmake --build . --config Debug --parallel 4
  306. ./hello
  307. - name: Get LLVM libraries
  308. id: retrieve_llvm_libs
  309. uses: actions/cache@v4
  310. with:
  311. path: |
  312. ./core/deps/llvm/build/bin
  313. ./core/deps/llvm/build/include
  314. ./core/deps/llvm/build/lib
  315. ./core/deps/llvm/build/libexec
  316. ./core/deps/llvm/build/share
  317. key: ${{ matrix.llvm_cache_key }}
  318. - name: Build wamrc
  319. run: |
  320. mkdir build && cd build
  321. cmake ..
  322. cmake --build . --config Release --parallel 4
  323. working-directory: wamr-compiler
  324. - name: Build Sample [wasi-threads]
  325. run: |
  326. cd samples/wasi-threads
  327. mkdir build && cd build
  328. cmake ..
  329. cmake --build . --config Debug --parallel 4
  330. ./iwasm wasm-apps/no_pthread.wasm
  331. ../../../wamr-compiler/build/wamrc --size-level=0 --enable-multi-thread -o wasm-apps/no_pthread.aot wasm-apps/no_pthread.wasm
  332. ./iwasm wasm-apps/no_pthread.aot
  333. - name: Build Sample [shared-module]
  334. run: |
  335. cd samples/shared-module
  336. ./build.sh
  337. ./run.sh
  338. - name: Build Sample [terminate]
  339. run: |
  340. cd samples/terminate
  341. ./build.sh
  342. ./run.sh