compilation_on_android_ubuntu.yml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. name: compilation on android, ubuntu-22.04
  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_android_ubuntu.yml"
  13. - "build-scripts/**"
  14. - "core/**"
  15. - "!core/deps/**"
  16. - "product-mini/**"
  17. - "samples/**"
  18. - "!samples/workload/**"
  19. - "tests/wamr-test-suites/**"
  20. - "tests/unit/**"
  21. - "wamr-compiler/**"
  22. - "test-tools/wamr-ide/**"
  23. # will be triggered on push events
  24. push:
  25. branches:
  26. - main
  27. - "dev/**"
  28. paths:
  29. - ".github/workflows/build_llvm_libraries.yml"
  30. - ".github/workflows/compilation_on_android_ubuntu.yml"
  31. - "build-scripts/**"
  32. - "core/**"
  33. - "!core/deps/**"
  34. - "product-mini/**"
  35. - "samples/**"
  36. - "!samples/workload/**"
  37. - "tests/wamr-test-suites/**"
  38. - "tests/unit/**"
  39. - "wamr-compiler/**"
  40. - "test-tools/wamr-ide/**"
  41. # allow to be triggered manually
  42. workflow_dispatch:
  43. # Cancel any in-flight jobs for the same PR/branch so there's only one active
  44. # at a time
  45. concurrency:
  46. group: ${{ github.workflow }}-${{ github.ref }}
  47. cancel-in-progress: true
  48. env:
  49. # For BUILD
  50. 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"
  51. 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"
  52. 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"
  53. 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"
  54. 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"
  55. 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"
  56. 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"
  57. # For Spec Test
  58. DEFAULT_TEST_OPTIONS: "-s spec -b -P"
  59. MULTI_MODULES_TEST_OPTIONS: "-s spec -b -M -P"
  60. SIMD_TEST_OPTIONS: "-s spec -b -S -P"
  61. THREADS_TEST_OPTIONS: "-s spec -b -p -P"
  62. X86_32_TARGET_TEST_OPTIONS: "-m x86_32 -P"
  63. WASI_TEST_OPTIONS: "-s wasi_certification -w"
  64. WAMR_COMPILER_TEST_OPTIONS: "-s wamr_compiler -S -b -P"
  65. GC_TEST_OPTIONS: "-s spec -G -b -P"
  66. MEMORY64_TEST_OPTIONS: "-s spec -W -b -P"
  67. MULTI_MEMORY_TEST_OPTIONS: "-s spec -E -b -P"
  68. EXTENDED_CONST_EXPR_TEST_OPTIONS: "-s spec -N -b -P"
  69. permissions:
  70. contents: read
  71. jobs:
  72. check_version_h:
  73. permissions:
  74. contents: read
  75. actions: write
  76. uses: ./.github/workflows/check_version_h.yml
  77. build_llvm_libraries_on_ubuntu_2204:
  78. permissions:
  79. contents: read
  80. actions: write
  81. uses: ./.github/workflows/build_llvm_libraries.yml
  82. with:
  83. os: "ubuntu-22.04"
  84. arch: "X86"
  85. build_wamrc:
  86. needs: [build_llvm_libraries_on_ubuntu_2204]
  87. runs-on: ${{ matrix.os }}
  88. strategy:
  89. matrix:
  90. include:
  91. - os: ubuntu-22.04
  92. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
  93. steps:
  94. - name: checkout
  95. uses: actions/checkout@v6.0.1
  96. # since jobs.id can't contain the dot character
  97. # it is hard to use `format` to assemble the cache key
  98. - name: Get LLVM libraries
  99. id: retrieve_llvm_libs
  100. uses: actions/cache@v5
  101. with:
  102. path: |
  103. ./core/deps/llvm/build/bin
  104. ./core/deps/llvm/build/include
  105. ./core/deps/llvm/build/lib
  106. ./core/deps/llvm/build/libexec
  107. ./core/deps/llvm/build/share
  108. key: ${{ matrix.llvm_cache_key }}
  109. - name: Quit if cache miss
  110. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
  111. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  112. - name: Build wamrc
  113. run: |
  114. mkdir build && cd build
  115. cmake .. -DCMAKE_C_FLAGS="-Werror"
  116. cmake --build . --config Release --parallel 4
  117. working-directory: wamr-compiler
  118. build_iwasm:
  119. needs: [build_llvm_libraries_on_ubuntu_2204]
  120. runs-on: ${{ matrix.os }}
  121. strategy:
  122. matrix:
  123. make_options_run_mode: [
  124. # Running mode
  125. $AOT_BUILD_OPTIONS,
  126. $CLASSIC_INTERP_BUILD_OPTIONS,
  127. $FAST_INTERP_BUILD_OPTIONS,
  128. $FAST_JIT_BUILD_OPTIONS,
  129. $LLVM_LAZY_JIT_BUILD_OPTIONS,
  130. $LLVM_EAGER_JIT_BUILD_OPTIONS,
  131. $MULTI_TIER_JIT_BUILD_OPTIONS,
  132. ]
  133. make_options_feature: [
  134. # Features
  135. "-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
  136. "-DWAMR_BUILD_DEBUG_AOT=1",
  137. "-DWAMR_BUILD_DEBUG_INTERP=1",
  138. "-DWAMR_BUILD_DUMP_CALL_STACK=1",
  139. "-DWAMR_BUILD_LIB_PTHREAD=1",
  140. "-DWAMR_BUILD_LIB_WASI_THREADS=1",
  141. "-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1",
  142. "-DWAMR_BUILD_MINI_LOADER=1",
  143. "-DWAMR_BUILD_MEMORY_PROFILING=1",
  144. "-DWAMR_BUILD_MULTI_MODULE=1",
  145. "-DWAMR_BUILD_PERF_PROFILING=1",
  146. "-DWAMR_BUILD_LIB_SIMDE=1",
  147. "-DWAMR_BUILD_TAIL_CALL=1",
  148. "-DWAMR_DISABLE_HW_BOUND_CHECK=1",
  149. "-DWAMR_BUILD_MEMORY64=1",
  150. "-DWAMR_BUILD_MULTI_MEMORY=1",
  151. "-DWAMR_BUILD_SHARED=1",
  152. "-DWAMR_BUILD_EXTENDED_CONST_EXPR=1",
  153. "-DWAMR_BUILD_LIME1=1 -DWAMR_BUILD_BULK_MEMORY=0 -DWAMR_BUILD_REF_TYPES=0 -DWAMR_BUILD_SIMD=0",
  154. ]
  155. os: [ubuntu-22.04]
  156. platform: [android, linux]
  157. exclude:
  158. # incompatible feature and platform and mode
  159. # MULTI_MODULE only on INTERP mode and AOT mode
  160. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  161. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  162. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  163. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  164. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  165. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  166. - make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
  167. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  168. # DEBUG_INTERP only on CLASSIC INTERP mode
  169. - make_options_run_mode: $AOT_BUILD_OPTIONS
  170. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  171. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  172. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  173. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  174. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  175. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  176. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  177. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  178. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  179. - make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
  180. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  181. # DEBUG_AOT only on JIT/AOT mode
  182. - make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
  183. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  184. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  185. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  186. # TODO: DEBUG_AOT on JIT
  187. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  188. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  189. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  190. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  191. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  192. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  193. - make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
  194. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  195. # MINI_LOADER only on INTERP mode
  196. - make_options_run_mode: $AOT_BUILD_OPTIONS
  197. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  198. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  199. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  200. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  201. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  202. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  203. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  204. - make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
  205. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  206. # Memory64 only on CLASSIC INTERP and AOT mode, and only on 64-bit platform
  207. - make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
  208. platform: android
  209. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  210. make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
  211. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  212. make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
  213. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  214. make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
  215. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  216. make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
  217. - make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
  218. make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
  219. # Multi memory only on CLASSIC INTERP mode, and only on 64-bit platform
  220. - make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
  221. platform: android
  222. - make_options_run_mode: $AOT_BUILD_OPTIONS
  223. make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
  224. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  225. make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
  226. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  227. make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
  228. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  229. make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
  230. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  231. make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
  232. - make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
  233. make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
  234. # Fast-JIT and Multi-Tier-JIT mode don't support android
  235. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  236. platform: android
  237. - make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
  238. platform: android
  239. # LLVM JIT pre-built binary wasn't compiled by Android NDK
  240. # and isn't available for android
  241. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  242. platform: android
  243. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  244. platform: android
  245. # android does not support WAMR_BUILD_SHARED in its CMakeLists.txt.
  246. - make_options_feature: "-DWAMR_BUILD_SHARED=1"
  247. platform: android
  248. include:
  249. - os: ubuntu-22.04
  250. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
  251. # classic interp doesn't support SIMD
  252. - make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
  253. extra_options: "-DWAMR_BUILD_SIMD=0"
  254. # fast jit doesn't support SIMD
  255. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  256. extra_options: "-DWAMR_BUILD_SIMD=0"
  257. # multi-tier jit doesn't support SIMD
  258. - make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
  259. extra_options: "-DWAMR_BUILD_SIMD=0"
  260. steps:
  261. - name: checkout
  262. uses: actions/checkout@v6.0.1
  263. # only download llvm cache when needed
  264. - name: Get LLVM libraries
  265. id: retrieve_llvm_libs
  266. if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS')
  267. uses: actions/cache@v5
  268. with:
  269. path: |
  270. ./core/deps/llvm/build/bin
  271. ./core/deps/llvm/build/include
  272. ./core/deps/llvm/build/lib
  273. ./core/deps/llvm/build/libexec
  274. ./core/deps/llvm/build/share
  275. key: ${{ matrix.llvm_cache_key }}
  276. - name: Quit if cache miss
  277. if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS') && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
  278. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  279. - name: Build iwasm for linux
  280. if: matrix.platform == 'linux'
  281. run: |
  282. mkdir build && cd build
  283. cmake .. -DCMAKE_C_FLAGS="-Werror" ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }} ${{ matrix.extra_options}}
  284. cmake --build . --config Release --parallel 4
  285. working-directory: product-mini/platforms/${{ matrix.platform }}
  286. - name: Build iwasm for android
  287. if: matrix.platform == 'android'
  288. run: |
  289. mkdir build && cd build
  290. cmake .. -DCMAKE_C_FLAGS="-Werror" ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }} \
  291. -DWAMR_BUILD_TARGET=X86_64
  292. cmake --build . --config Release --parallel 4
  293. working-directory: product-mini/platforms/${{ matrix.platform }}
  294. build_unit_tests:
  295. needs: [build_llvm_libraries_on_ubuntu_2204, build_wamrc]
  296. runs-on: ${{ matrix.os }}
  297. strategy:
  298. fail-fast: false
  299. matrix:
  300. os: [ubuntu-22.04]
  301. build_target: ["X86_64", "X86_32"]
  302. include:
  303. - os: ubuntu-22.04
  304. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
  305. steps:
  306. - name: checkout
  307. uses: actions/checkout@v6.0.1
  308. - name: Get LLVM libraries
  309. id: retrieve_llvm_libs
  310. uses: actions/cache@v5
  311. with:
  312. path: |
  313. ./core/deps/llvm/build/bin
  314. ./core/deps/llvm/build/include
  315. ./core/deps/llvm/build/lib
  316. ./core/deps/llvm/build/libexec
  317. ./core/deps/llvm/build/share
  318. key: ${{ matrix.llvm_cache_key }}
  319. - name: Quit if cache miss
  320. if: (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
  321. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  322. - name: install-wasi-sdk-wabt
  323. uses: ./.github/actions/install-wasi-sdk-wabt
  324. with:
  325. os: ${{ matrix.os }}
  326. - name: Build wamrc
  327. run: |
  328. mkdir build && cd build
  329. cmake ..
  330. cmake --build . --config Release --parallel 4
  331. working-directory: wamr-compiler
  332. - name: Install dependencies for X86_32
  333. if: matrix.build_target == 'X86_32'
  334. run: |
  335. sudo dpkg --add-architecture i386
  336. sudo apt-get update
  337. sudo apt-get install -y g++-multilib libzstd-dev:i386 zlib1g-dev:i386
  338. - name: Build and run unit tests
  339. run: |
  340. mkdir build && cd build
  341. cmake .. -DWAMR_BUILD_TARGET=${{ matrix.build_target }}
  342. cmake --build . --parallel 4
  343. ctest --output-on-failure
  344. working-directory: tests/unit
  345. build_regression_tests:
  346. needs: [build_llvm_libraries_on_ubuntu_2204]
  347. runs-on: ${{ matrix.os }}
  348. strategy:
  349. matrix:
  350. os: [ubuntu-22.04]
  351. include:
  352. - os: ubuntu-22.04
  353. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
  354. steps:
  355. - name: checkout
  356. uses: actions/checkout@v6.0.1
  357. - name: Get LLVM libraries
  358. id: retrieve_llvm_libs
  359. uses: actions/cache@v5
  360. with:
  361. path: |
  362. ./core/deps/llvm/build/bin
  363. ./core/deps/llvm/build/include
  364. ./core/deps/llvm/build/lib
  365. ./core/deps/llvm/build/libexec
  366. ./core/deps/llvm/build/share
  367. key: ${{ matrix.llvm_cache_key }}
  368. - name: Quit if cache miss
  369. if: (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
  370. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  371. - name: Build wamrc and iwasm
  372. run: |
  373. ./build_wamr.sh
  374. working-directory: tests/regression/ba-issues
  375. - name: Run regression tests
  376. run: |
  377. python run.py
  378. working-directory: tests/regression/ba-issues
  379. build_samples_wasm_c_api:
  380. needs: [build_iwasm, build_llvm_libraries_on_ubuntu_2204, build_wamrc]
  381. runs-on: ${{ matrix.os }}
  382. strategy:
  383. fail-fast: false
  384. matrix:
  385. make_options: [
  386. # Running mode
  387. $AOT_BUILD_OPTIONS,
  388. $CLASSIC_INTERP_BUILD_OPTIONS,
  389. $FAST_INTERP_BUILD_OPTIONS,
  390. $FAST_JIT_BUILD_OPTIONS,
  391. $LLVM_LAZY_JIT_BUILD_OPTIONS,
  392. $LLVM_EAGER_JIT_BUILD_OPTIONS,
  393. $MULTI_TIER_JIT_BUILD_OPTIONS,
  394. ]
  395. os: [ubuntu-22.04]
  396. include:
  397. - os: ubuntu-22.04
  398. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
  399. # classic interp doesn't support SIMD
  400. - make_options: $CLASSIC_INTERP_BUILD_OPTIONS
  401. extra_options: "-DWAMR_BUILD_SIMD=0"
  402. # fast jit doesn't support Multi-module and SIMD
  403. - make_options: $FAST_JIT_BUILD_OPTIONS
  404. extra_options: "-DWAMR_BUILD_SIMD=0 -DWAMR_BUILD_MULTI_MODULE=0"
  405. # multi-tier jit doesn't support Multi-module and SIMD
  406. - make_options: $MULTI_TIER_JIT_BUILD_OPTIONS
  407. extra_options: "-DWAMR_BUILD_SIMD=0 -DWAMR_BUILD_MULTI_MODULE=0"
  408. # LLVM JIT doesn't support Multi-module
  409. - make_options: $LLVM_LAZY_JIT_BUILD_OPTIONS
  410. extra_options: "-DWAMR_BUILD_MULTI_MODULE=0"
  411. - make_options: $LLVM_EAGER_JIT_BUILD_OPTIONS
  412. extra_options: "-DWAMR_BUILD_MULTI_MODULE=0"
  413. steps:
  414. - name: checkout
  415. uses: actions/checkout@v6.0.1
  416. - name: Get LLVM libraries
  417. id: retrieve_llvm_libs
  418. if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
  419. uses: actions/cache@v5
  420. with:
  421. path: |
  422. ./core/deps/llvm/build/bin
  423. ./core/deps/llvm/build/include
  424. ./core/deps/llvm/build/lib
  425. ./core/deps/llvm/build/libexec
  426. ./core/deps/llvm/build/share
  427. key: ${{ matrix.llvm_cache_key }}
  428. - name: Quit if cache miss
  429. if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
  430. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  431. - name: install-wasi-sdk-wabt
  432. uses: ./.github/actions/install-wasi-sdk-wabt
  433. with:
  434. os: ${{ matrix.os }}
  435. - name: Build wamrc
  436. if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
  437. run: |
  438. mkdir build && cd build
  439. cmake ..
  440. cmake --build . --config Release --parallel 4
  441. working-directory: wamr-compiler
  442. - name: Build Sample [wasm-c-api]
  443. run: |
  444. VERBOSE=1
  445. cmake -S . -B build ${{ matrix.make_options }} ${{ matrix.extra_options }}
  446. cmake --build build --config Debug --parallel 4
  447. ctest --test-dir build --output-on-failure
  448. working-directory: samples/wasm-c-api
  449. - name: Build Sample [printversion]
  450. run: |
  451. ./test.sh
  452. working-directory: samples/printversion
  453. build_samples_others:
  454. needs: [build_iwasm, build_llvm_libraries_on_ubuntu_2204, build_wamrc]
  455. runs-on: ${{ matrix.os }}
  456. strategy:
  457. matrix:
  458. os: [ubuntu-22.04]
  459. include:
  460. - os: ubuntu-22.04
  461. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
  462. steps:
  463. - name: checkout
  464. uses: actions/checkout@v6.0.1
  465. - name: Get LLVM libraries
  466. id: retrieve_llvm_libs
  467. uses: actions/cache@v5
  468. with:
  469. path: |
  470. ./core/deps/llvm/build/bin
  471. ./core/deps/llvm/build/include
  472. ./core/deps/llvm/build/lib
  473. ./core/deps/llvm/build/libexec
  474. ./core/deps/llvm/build/share
  475. key: ${{ matrix.llvm_cache_key }}
  476. - name: install-wasi-sdk-wabt
  477. uses: ./.github/actions/install-wasi-sdk-wabt
  478. with:
  479. os: ${{ matrix.os }}
  480. - name: Build wamrc
  481. run: |
  482. mkdir build && cd build
  483. cmake ..
  484. cmake --build . --config Release --parallel 4
  485. working-directory: wamr-compiler
  486. - name: Build Sample [basic]
  487. run: |
  488. cd samples/basic
  489. ./build.sh
  490. ./run.sh
  491. - name: Build Sample [file]
  492. run: |
  493. cd samples/file
  494. mkdir build && cd build
  495. cmake ..
  496. cmake --build . --config Debug --parallel 4
  497. ./src/iwasm -f wasm-app/file.wasm -d .
  498. - name: Build Sample [multi-thread]
  499. run: |
  500. cd samples/multi-thread
  501. mkdir build && cd build
  502. cmake ..
  503. cmake --build . --config Debug --parallel 4
  504. ./iwasm wasm-apps/test.wasm
  505. - name: Build Sample [multi-module]
  506. run: |
  507. cd samples/multi-module
  508. mkdir build && cd build
  509. cmake .. -DWAMR_BUILD_AOT=1
  510. cmake --build . --config Debug --parallel 4
  511. ./multi_module mC.wasm
  512. ./multi_module mC.aot
  513. - name: Build Sample [spawn-thread]
  514. run: |
  515. cd samples/spawn-thread
  516. mkdir build && cd build
  517. cmake ..
  518. cmake --build . --config Debug --parallel 4
  519. ./spawn_thread
  520. - name: Build Sample [ref-types]
  521. run: |
  522. cd samples/ref-types
  523. mkdir build && cd build
  524. cmake ..
  525. cmake --build . --config Debug --parallel 4
  526. ./hello
  527. - name: Build Sample [wasi-threads]
  528. run: |
  529. cd samples/wasi-threads
  530. mkdir build && cd build
  531. cmake ..
  532. cmake --build . --config Debug --parallel 4
  533. ./iwasm wasm-apps/no_pthread.wasm
  534. - name: Build Sample [shared-module]
  535. run: |
  536. cd samples/shared-module
  537. ./build.sh
  538. ./run.sh
  539. - name: Build Sample [terminate]
  540. run: |
  541. cd samples/terminate
  542. ./build.sh
  543. ./run.sh
  544. - name: Build Sample [debug-tools]
  545. run: |
  546. cd samples/debug-tools
  547. mkdir build && cd build
  548. cmake ..
  549. cmake --build . --config Debug --parallel 4
  550. ./iwasm wasm-apps/trap.wasm | grep "#" > call_stack.txt
  551. ./iwasm wasm-apps/trap.aot | grep "#" > call_stack_aot.txt
  552. bash -x ../symbolicate.sh
  553. - name: Build Sample [native-stack-overflow]
  554. run: |
  555. cd samples/native-stack-overflow
  556. ./build.sh
  557. ./run.sh test1
  558. ./run.sh test2
  559. - name: Build Sample [shared-heap]
  560. run: |
  561. cd samples/shared-heap
  562. mkdir build && cd build
  563. cmake ..
  564. cmake --build . --config Debug --parallel 4
  565. ./shared_heap_test
  566. ./shared_heap_test --aot
  567. - name: Build Sample [import-func-callback]
  568. run: |
  569. cd samples/import-func-callback
  570. mkdir build && cd build
  571. cmake ..
  572. cmake --build . --config Release --parallel 4
  573. ./import-func-callback
  574. test:
  575. needs: [build_iwasm, build_llvm_libraries_on_ubuntu_2204, build_wamrc]
  576. runs-on: ${{ matrix.os }}
  577. strategy:
  578. fail-fast: false
  579. matrix:
  580. os: [ubuntu-22.04]
  581. running_mode:
  582. [
  583. "classic-interp",
  584. "fast-interp",
  585. "jit",
  586. "aot",
  587. "fast-jit",
  588. "multi-tier-jit",
  589. ]
  590. test_option:
  591. [
  592. $DEFAULT_TEST_OPTIONS,
  593. $MULTI_MODULES_TEST_OPTIONS,
  594. $SIMD_TEST_OPTIONS,
  595. $THREADS_TEST_OPTIONS,
  596. $WASI_TEST_OPTIONS,
  597. $GC_TEST_OPTIONS,
  598. $MEMORY64_TEST_OPTIONS,
  599. $MULTI_MEMORY_TEST_OPTIONS,
  600. $EXTENDED_CONST_EXPR_TEST_OPTIONS,
  601. ]
  602. include:
  603. - os: ubuntu-22.04
  604. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
  605. ubuntu_version: "22.04"
  606. - os: ubuntu-22.04
  607. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
  608. running_mode: aot
  609. test_option: $WAMR_COMPILER_TEST_OPTIONS
  610. steps:
  611. - name: checkout
  612. uses: actions/checkout@v6.0.1
  613. - name: Set-up OCaml
  614. uses: ocaml/setup-ocaml@v3
  615. if: matrix.test_option == '$GC_TEST_OPTIONS'
  616. with:
  617. ocaml-compiler: 4.13
  618. - name: Set-up Ocamlbuild
  619. if: matrix.test_option == '$GC_TEST_OPTIONS'
  620. run: opam install ocamlbuild dune menhir
  621. - name: download and install wasi-sdk
  622. if: matrix.test_option == '$WASI_TEST_OPTIONS'
  623. uses: ./.github/actions/install-wasi-sdk-wabt
  624. with:
  625. os: ${{ matrix.os }}
  626. - name: set env variable(if llvm are used)
  627. if: matrix.running_mode == 'aot' || matrix.running_mode == 'jit' || matrix.running_mode == 'multi-tier-jit'
  628. run: echo "USE_LLVM=true" >> $GITHUB_ENV
  629. - name: set env variable(if x86_32 test needed)
  630. if: >
  631. ((matrix.test_option == '$DEFAULT_TEST_OPTIONS' || matrix.test_option == '$THREADS_TEST_OPTIONS'
  632. || matrix.test_option == '$WASI_TEST_OPTIONS' || matrix.test_option == '$GC_TEST_OPTIONS')
  633. && matrix.test_option != '$MEMORY64_TEST_OPTIONS'
  634. && matrix.running_mode != 'fast-jit' && matrix.running_mode != 'jit' && matrix.running_mode != 'multi-tier-jit')
  635. run: echo "TEST_ON_X86_32=true" >> $GITHUB_ENV
  636. #only download llvm libraries in jit and aot mode
  637. - name: Get LLVM libraries
  638. if: env.USE_LLVM == 'true'
  639. id: retrieve_llvm_libs
  640. uses: actions/cache@v5
  641. with:
  642. path: |
  643. ./core/deps/llvm/build/bin
  644. ./core/deps/llvm/build/include
  645. ./core/deps/llvm/build/lib
  646. ./core/deps/llvm/build/libexec
  647. ./core/deps/llvm/build/share
  648. key: ${{ matrix.llvm_cache_key }}
  649. - name: Quit if cache miss
  650. if: env.USE_LLVM == 'true' && steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
  651. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  652. - name: install jq JSON processor
  653. if: matrix.running_mode == 'aot' && matrix.test_option == '$WASI_TEST_OPTIONS'
  654. run: sudo apt-get update && sudo apt install -y jq
  655. - name: Build WASI thread tests
  656. if: matrix.test_option == '$WASI_TEST_OPTIONS'
  657. run: bash build.sh
  658. working-directory: ./core/iwasm/libraries/lib-wasi-threads/test/
  659. - name: build socket api tests
  660. if: matrix.test_option == '$WASI_TEST_OPTIONS'
  661. run: bash build.sh
  662. working-directory: ./core/iwasm/libraries/lib-socket/test/
  663. - name: run tests
  664. timeout-minutes: 30
  665. if: matrix.test_option != '$GC_TEST_OPTIONS'
  666. run: ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  667. working-directory: ./tests/wamr-test-suites
  668. - name: run gc tests
  669. timeout-minutes: 20
  670. if: matrix.test_option == '$GC_TEST_OPTIONS'
  671. run: |
  672. eval $(opam env)
  673. ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  674. working-directory: ./tests/wamr-test-suites
  675. #only install x32 support libraries when to run x86_32 cases
  676. - name: install x32 support libraries
  677. if: env.TEST_ON_X86_32 == 'true'
  678. run:
  679. # Add another apt repository as some packages cannot
  680. # be downloaded with the github default repository
  681. sudo curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc &&
  682. sudo apt-add-repository https://packages.microsoft.com/ubuntu/${{ matrix.ubuntu_version }}/prod &&
  683. sudo apt-get update &&
  684. sudo apt install -y g++-multilib lib32gcc-9-dev
  685. - name: run tests x86_32
  686. timeout-minutes: 30
  687. if: env.TEST_ON_X86_32 == 'true' && matrix.test_option != '$GC_TEST_OPTIONS'
  688. run: ./test_wamr.sh ${{ env.X86_32_TARGET_TEST_OPTIONS }} ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  689. working-directory: ./tests/wamr-test-suites
  690. - name: run gc tests x86_32
  691. timeout-minutes: 20
  692. if: env.TEST_ON_X86_32 == 'true' && matrix.test_option == '$GC_TEST_OPTIONS'
  693. run: |
  694. eval $(opam env)
  695. ./test_wamr.sh ${{ env.X86_32_TARGET_TEST_OPTIONS }} ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  696. working-directory: ./tests/wamr-test-suites