compilation_on_macos.yml 15 KB

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