compilation_on_macos.yml 13 KB

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