compilation_on_macos.yml 13 KB

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