compilation_on_macos.yml 16 KB

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