compilation_on_macos.yml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  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@v5
  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 .. -DCMAKE_C_FLAGS="-Werror"
  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. "-DWAMR_BUILD_EXTENDED_CONST_EXPR=1",
  135. ]
  136. os: [macos-13]
  137. platform: [darwin]
  138. exclude:
  139. # incompatible feature and platform
  140. # incompatible mode and feature
  141. # MULTI_MODULE only on INTERP mode and AOT mode
  142. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  143. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  144. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  145. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  146. # SIMD only on JIT/AOT mode
  147. - make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
  148. make_options_feature: "-DWAMR_BUILD_SIMD=1"
  149. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  150. make_options_feature: "-DWAMR_BUILD_SIMD=1"
  151. # DEBUG_INTERP only on CLASSIC INTERP mode
  152. - make_options_run_mode: $AOT_BUILD_OPTIONS
  153. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  154. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  155. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  156. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  157. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  158. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  159. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  160. # DEBUG_AOT only on JIT/AOT mode
  161. - make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
  162. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  163. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  164. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  165. # TODO: DEBUG_AOT on JIT
  166. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  167. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  168. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  169. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  170. # MINI_LOADER only on INTERP mode
  171. - make_options_run_mode: $AOT_BUILD_OPTIONS
  172. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  173. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  174. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  175. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  176. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  177. include:
  178. - os: macos-13
  179. llvm_cache_key: ${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}
  180. steps:
  181. - name: checkout
  182. uses: actions/checkout@v5
  183. # only download llvm cache when needed
  184. - name: Get LLVM libraries
  185. id: retrieve_llvm_libs
  186. if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS')
  187. uses: actions/cache@v4
  188. with:
  189. path: |
  190. ./core/deps/llvm/build/bin
  191. ./core/deps/llvm/build/include
  192. ./core/deps/llvm/build/lib
  193. ./core/deps/llvm/build/libexec
  194. ./core/deps/llvm/build/share
  195. key: ${{ matrix.llvm_cache_key }}
  196. - name: Quit if cache miss
  197. if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS') && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
  198. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  199. - name: Build iwasm
  200. run: |
  201. mkdir build && cd build
  202. cmake .. -DCMAKE_C_FLAGS="-Werror" ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
  203. cmake --build . --config Release --parallel 4
  204. working-directory: product-mini/platforms/${{ matrix.platform }}
  205. build_samples_wasm_c_api:
  206. needs:
  207. [
  208. build_iwasm,
  209. build_llvm_libraries_on_intel_macos,
  210. build_wamrc,
  211. ]
  212. runs-on: ${{ matrix.os }}
  213. strategy:
  214. matrix:
  215. make_options: [
  216. $AOT_BUILD_OPTIONS,
  217. $CLASSIC_INTERP_BUILD_OPTIONS,
  218. $FAST_INTERP_BUILD_OPTIONS,
  219. $FAST_JIT_BUILD_OPTIONS,
  220. $LLVM_LAZY_JIT_BUILD_OPTIONS,
  221. $LLVM_EAGER_JIT_BUILD_OPTIONS,
  222. $MULTI_TIER_JIT_BUILD_OPTIONS,
  223. ]
  224. os: [macos-13]
  225. include:
  226. - os: macos-13
  227. llvm_cache_key: ${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}
  228. steps:
  229. - name: checkout
  230. uses: actions/checkout@v5
  231. - name: Get LLVM libraries
  232. id: retrieve_llvm_libs
  233. if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
  234. uses: actions/cache@v4
  235. with:
  236. path: |
  237. ./core/deps/llvm/build/bin
  238. ./core/deps/llvm/build/include
  239. ./core/deps/llvm/build/lib
  240. ./core/deps/llvm/build/libexec
  241. ./core/deps/llvm/build/share
  242. key: ${{ matrix.llvm_cache_key }}
  243. - name: Quit if cache miss
  244. if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
  245. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  246. - name: install-wasi-sdk-wabt
  247. uses: ./.github/actions/install-wasi-sdk-wabt
  248. with:
  249. os: ${{ matrix.os }}
  250. - name: Build wamrc
  251. if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
  252. run: |
  253. mkdir build && cd build
  254. cmake ..
  255. cmake --build . --config Release --parallel 4
  256. working-directory: wamr-compiler
  257. - name: Build Sample [wasm-c-api]
  258. run: |
  259. VERBOSE=1
  260. cmake -S . -B build ${{ matrix.make_options }}
  261. cmake --build build --config Debug --parallel 4
  262. ctest --test-dir build --output-on-failure
  263. working-directory: samples/wasm-c-api
  264. - name: Build Sample [printversion]
  265. run: |
  266. ./test.sh
  267. working-directory: samples/printversion
  268. build_samples_others:
  269. needs: [build_iwasm, build_wamrc, build_llvm_libraries_on_intel_macos, build_llvm_libraries_on_arm_macos]
  270. runs-on: ${{ matrix.os }}
  271. strategy:
  272. matrix:
  273. os: [macos-13, macos-14]
  274. include:
  275. - os: macos-13
  276. llvm_cache_key: ${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}
  277. - os: macos-14
  278. llvm_cache_key: ${{ needs.build_llvm_libraries_on_arm_macos.outputs.cache_key }}
  279. steps:
  280. - name: checkout
  281. uses: actions/checkout@v5
  282. - name: install-wasi-sdk-wabt
  283. uses: ./.github/actions/install-wasi-sdk-wabt
  284. with:
  285. os: ${{ matrix.os }}
  286. - name: Build Sample [basic]
  287. run: |
  288. cd samples/basic
  289. ./build.sh
  290. ./run.sh
  291. - name: Build Sample [file]
  292. run: |
  293. cd samples/file
  294. mkdir build && cd build
  295. cmake ..
  296. cmake --build . --config Debug --parallel 4
  297. ./src/iwasm -f wasm-app/file.wasm -d .
  298. - name: Build Sample [multi-thread]
  299. run: |
  300. cd samples/multi-thread
  301. mkdir build && cd build
  302. cmake ..
  303. cmake --build . --config Debug --parallel 4
  304. ./iwasm wasm-apps/test.wasm
  305. - name: Build Sample [multi-module]
  306. run: |
  307. cd samples/multi-module
  308. mkdir build && cd build
  309. cmake ..
  310. cmake --build . --config Debug --parallel 4
  311. ./multi_module mC.wasm
  312. - name: Build Sample [spawn-thread]
  313. run: |
  314. cd samples/spawn-thread
  315. mkdir build && cd build
  316. cmake ..
  317. cmake --build . --config Debug --parallel 4
  318. ./spawn_thread
  319. - name: Build Sample [ref-types]
  320. run: |
  321. cd samples/ref-types
  322. mkdir build && cd build
  323. cmake ..
  324. cmake --build . --config Debug --parallel 4
  325. ./hello
  326. - name: Get LLVM libraries
  327. id: retrieve_llvm_libs
  328. uses: actions/cache@v4
  329. with:
  330. path: |
  331. ./core/deps/llvm/build/bin
  332. ./core/deps/llvm/build/include
  333. ./core/deps/llvm/build/lib
  334. ./core/deps/llvm/build/libexec
  335. ./core/deps/llvm/build/share
  336. key: ${{ matrix.llvm_cache_key }}
  337. - name: Build wamrc
  338. run: |
  339. mkdir build && cd build
  340. cmake ..
  341. cmake --build . --config Release --parallel 4
  342. working-directory: wamr-compiler
  343. # cmake --build . --config Debug --parallel 4
  344. - name: Build Sample [wasi-threads]
  345. run: |
  346. cd samples/wasi-threads
  347. mkdir build && cd build
  348. cmake ..
  349. cmake --build . --config Debug --verbose
  350. ./iwasm wasm-apps/no_pthread.wasm
  351. ../../../wamr-compiler/build/wamrc --size-level=0 --enable-multi-thread -o wasm-apps/no_pthread.aot wasm-apps/no_pthread.wasm
  352. ./iwasm wasm-apps/no_pthread.aot
  353. - name: Build Sample [shared-module]
  354. run: |
  355. cd samples/shared-module
  356. ./build.sh
  357. ./run.sh
  358. - name: Build Sample [terminate]
  359. run: |
  360. cd samples/terminate
  361. ./build.sh
  362. ./run.sh
  363. - name: Build Sample [debug-tools]
  364. run: |
  365. cd samples/debug-tools
  366. mkdir build && cd build
  367. cmake ..
  368. cmake --build . --config Debug --parallel 4
  369. ./iwasm wasm-apps/trap.wasm | grep "#" > call_stack.txt
  370. ./iwasm wasm-apps/trap.aot | grep "#" > call_stack_aot.txt
  371. bash -x ../symbolicate.sh
  372. - name: Build Sample [native-stack-overflow]
  373. run: |
  374. cd samples/native-stack-overflow
  375. ./build.sh
  376. ./run.sh test1
  377. ./run.sh test2
  378. - name: Build Sample [shared-heap]
  379. run: |
  380. cd samples/shared-heap
  381. mkdir build && cd build
  382. cmake ..
  383. cmake --build . --config Debug --parallel 4
  384. ./shared_heap_test
  385. ./shared_heap_test --aot