compilation_on_macos.yml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  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. wasi_sdk_release:
  217. [
  218. "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-macos.tar.gz",
  219. ]
  220. wabt_release:
  221. [
  222. "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-macos-12.tar.gz",
  223. ]
  224. steps:
  225. - name: checkout
  226. uses: actions/checkout@v4
  227. - name: download and install wabt
  228. run: |
  229. cd /opt
  230. sudo wget ${{ matrix.wabt_release }}
  231. sudo tar -xzf wabt-1.0.31-*.tar.gz
  232. sudo mv wabt-1.0.31 wabt
  233. - name: Build Sample [wasm-c-api]
  234. run: |
  235. cmake -S . -B build ${{ matrix.make_options }}
  236. cmake --build build --config Release --parallel 4
  237. ctest --test-dir build --output-on-failure
  238. working-directory: samples/wasm-c-api
  239. build_samples_others:
  240. needs: [build_iwasm, build_wamrc, build_llvm_libraries_on_intel_macos, build_llvm_libraries_on_arm_macos]
  241. runs-on: ${{ matrix.os }}
  242. strategy:
  243. matrix:
  244. os: [macos-13, macos-14]
  245. wasi_sdk_release:
  246. [
  247. "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-macos.tar.gz",
  248. ]
  249. wabt_release:
  250. [
  251. "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-macos-12.tar.gz",
  252. ]
  253. include:
  254. - os: macos-13
  255. llvm_cache_key: ${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}
  256. - os: macos-14
  257. llvm_cache_key: ${{ needs.build_llvm_libraries_on_arm_macos.outputs.cache_key }}
  258. steps:
  259. - name: checkout
  260. uses: actions/checkout@v4
  261. - name: download and install wasi-sdk
  262. run: |
  263. cd /opt
  264. sudo wget ${{ matrix.wasi_sdk_release }}
  265. sudo tar -xzf wasi-sdk-*.tar.gz
  266. sudo ln -sf wasi-sdk-20.0 wasi-sdk
  267. - name: download and install wabt
  268. run: |
  269. cd /opt
  270. sudo wget ${{ matrix.wabt_release }}
  271. sudo tar -xzf wabt-1.0.31-*.tar.gz
  272. sudo ln -sf wabt-1.0.31 wabt
  273. - name: Build Sample [basic]
  274. run: |
  275. cd samples/basic
  276. ./build.sh
  277. ./run.sh
  278. - name: Build Sample [file]
  279. run: |
  280. cd samples/file
  281. mkdir build && cd build
  282. cmake ..
  283. cmake --build . --config Debug --parallel 4
  284. ./src/iwasm -f wasm-app/file.wasm -d .
  285. - name: Build Sample [multi-thread]
  286. run: |
  287. cd samples/multi-thread
  288. mkdir build && cd build
  289. cmake ..
  290. cmake --build . --config Debug --parallel 4
  291. ./iwasm wasm-apps/test.wasm
  292. - name: Build Sample [multi-module]
  293. run: |
  294. cd samples/multi-module
  295. mkdir build && cd build
  296. cmake ..
  297. cmake --build . --config Debug --parallel 4
  298. ./multi_module mC.wasm
  299. - name: Build Sample [spawn-thread]
  300. run: |
  301. cd samples/spawn-thread
  302. mkdir build && cd build
  303. cmake ..
  304. cmake --build . --config Debug --parallel 4
  305. ./spawn_thread
  306. - name: Build Sample [ref-types]
  307. run: |
  308. cd samples/ref-types
  309. mkdir build && cd build
  310. cmake ..
  311. cmake --build . --config Debug --parallel 4
  312. ./hello
  313. - name: Get LLVM libraries
  314. id: retrieve_llvm_libs
  315. uses: actions/cache@v4
  316. with:
  317. path: |
  318. ./core/deps/llvm/build/bin
  319. ./core/deps/llvm/build/include
  320. ./core/deps/llvm/build/lib
  321. ./core/deps/llvm/build/libexec
  322. ./core/deps/llvm/build/share
  323. key: ${{ matrix.llvm_cache_key }}
  324. - name: Build wamrc
  325. run: |
  326. mkdir build && cd build
  327. cmake ..
  328. cmake --build . --config Release --parallel 4
  329. working-directory: wamr-compiler
  330. - name: Build Sample [wasi-threads]
  331. run: |
  332. cd samples/wasi-threads
  333. mkdir build && cd build
  334. cmake ..
  335. cmake --build . --config Debug --parallel 4
  336. ./iwasm wasm-apps/no_pthread.wasm
  337. ../../../wamr-compiler/build/wamrc --size-level=0 --enable-multi-thread -o wasm-apps/no_pthread.aot wasm-apps/no_pthread.wasm
  338. ./iwasm wasm-apps/no_pthread.aot
  339. - name: Build Sample [shared-module]
  340. run: |
  341. cd samples/shared-module
  342. ./build.sh
  343. ./run.sh
  344. - name: Build Sample [terminate]
  345. run: |
  346. cd samples/terminate
  347. ./build.sh
  348. ./run.sh
  349. - name: Build Sample [debug-tools]
  350. run: |
  351. cd samples/debug-tools
  352. mkdir build && cd build
  353. cmake ..
  354. cmake --build . --config Debug --parallel 4
  355. ./iwasm wasm-apps/trap.wasm | grep "#" > call_stack.txt
  356. ./iwasm wasm-apps/trap.aot | grep "#" > call_stack_aot.txt
  357. bash -x ../symbolicate.sh
  358. - name: Build Sample [native-stack-overflow]
  359. run: |
  360. cd samples/native-stack-overflow
  361. ./build.sh
  362. ./run.sh test1
  363. ./run.sh test2
  364. - name: Build Sample [shared-heap]
  365. run: |
  366. cd samples/shared-heap
  367. mkdir build && cd build
  368. cmake ..
  369. cmake --build . --config Debug --parallel 4
  370. ./shared_heap_test
  371. ./shared_heap_test --aot