compilation_on_android_ubuntu.yml 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880
  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. permissions:
  69. contents: read
  70. jobs:
  71. check_version_h:
  72. permissions:
  73. contents: read
  74. actions: write
  75. uses: ./.github/workflows/check_version_h.yml
  76. build_llvm_libraries_on_ubuntu_2204:
  77. permissions:
  78. contents: read
  79. actions: write
  80. uses: ./.github/workflows/build_llvm_libraries.yml
  81. with:
  82. os: "ubuntu-22.04"
  83. arch: "X86"
  84. build_wamrc:
  85. needs:
  86. [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@v4
  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@v4
  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 ..
  116. cmake --build . --config Release --parallel 4
  117. working-directory: wamr-compiler
  118. build_iwasm:
  119. needs:
  120. [build_llvm_libraries_on_ubuntu_2204]
  121. runs-on: ${{ matrix.os }}
  122. strategy:
  123. matrix:
  124. make_options_run_mode: [
  125. # Running mode
  126. $AOT_BUILD_OPTIONS,
  127. $CLASSIC_INTERP_BUILD_OPTIONS,
  128. $FAST_INTERP_BUILD_OPTIONS,
  129. $FAST_JIT_BUILD_OPTIONS,
  130. $LLVM_LAZY_JIT_BUILD_OPTIONS,
  131. $LLVM_EAGER_JIT_BUILD_OPTIONS,
  132. $MULTI_TIER_JIT_BUILD_OPTIONS,
  133. ]
  134. make_options_feature: [
  135. # Features
  136. "-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
  137. "-DWAMR_BUILD_DEBUG_AOT=1",
  138. "-DWAMR_BUILD_DEBUG_INTERP=1",
  139. "-DWAMR_BUILD_DUMP_CALL_STACK=1",
  140. "-DWAMR_BUILD_LIB_PTHREAD=1",
  141. "-DWAMR_BUILD_LIB_WASI_THREADS=1",
  142. "-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1",
  143. "-DWAMR_BUILD_MINI_LOADER=1",
  144. "-DWAMR_BUILD_MEMORY_PROFILING=1",
  145. "-DWAMR_BUILD_MULTI_MODULE=1",
  146. "-DWAMR_BUILD_PERF_PROFILING=1",
  147. "-DWAMR_BUILD_REF_TYPES=1",
  148. "-DWAMR_BUILD_SIMD=1",
  149. "-DWAMR_BUILD_LIB_SIMDE=1",
  150. "-DWAMR_BUILD_TAIL_CALL=1",
  151. "-DWAMR_DISABLE_HW_BOUND_CHECK=1",
  152. "-DWAMR_BUILD_MEMORY64=1",
  153. "-DWAMR_BUILD_MULTI_MEMORY=1",
  154. "-DWAMR_BUILD_SHARED=1",
  155. ]
  156. os: [ubuntu-22.04]
  157. platform: [android, linux]
  158. exclude:
  159. # incompatible feature and platform
  160. # incompatible mode and feature
  161. # MULTI_MODULE only on INTERP mode and AOT mode
  162. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  163. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  164. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  165. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  166. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  167. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  168. - make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
  169. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  170. # SIMD only on JIT/AOT/fast interpreter mode
  171. - make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
  172. make_options_feature: "-DWAMR_BUILD_SIMD=1"
  173. # DEBUG_INTERP only on CLASSIC INTERP mode
  174. - make_options_run_mode: $AOT_BUILD_OPTIONS
  175. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  176. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  177. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  178. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  179. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  180. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  181. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  182. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  183. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  184. - make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
  185. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  186. # DEBUG_AOT only on JIT/AOT mode
  187. - make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
  188. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  189. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  190. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  191. # TODO: DEBUG_AOT on JIT
  192. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  193. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  194. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  195. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  196. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  197. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  198. - make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
  199. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  200. # MINI_LOADER only on INTERP mode
  201. - make_options_run_mode: $AOT_BUILD_OPTIONS
  202. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  203. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  204. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  205. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  206. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  207. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  208. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  209. - make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
  210. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  211. # Memory64 only on CLASSIC INTERP and AOT mode, and only on 64-bit platform
  212. - make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
  213. platform: android
  214. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  215. make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
  216. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  217. make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
  218. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  219. make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
  220. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  221. make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
  222. - make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
  223. make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
  224. # Multi memory only on CLASSIC INTERP mode, and only on 64-bit platform
  225. - make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
  226. platform: android
  227. - make_options_run_mode: $AOT_BUILD_OPTIONS
  228. make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
  229. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  230. make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
  231. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  232. make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
  233. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  234. make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
  235. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  236. make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
  237. - make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
  238. make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
  239. # Fast-JIT and Multi-Tier-JIT mode don't support android
  240. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  241. platform: android
  242. - make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
  243. platform: android
  244. # LLVM JIT pre-built binary wasn't compiled by Android NDK
  245. # and isn't available for android
  246. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  247. platform: android
  248. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  249. platform: android
  250. # android does not support WAMR_BUILD_SHARED in its CMakeLists.txt.
  251. - make_options_feature: "-DWAMR_BUILD_SHARED=1"
  252. platform: android
  253. include:
  254. - os: ubuntu-22.04
  255. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
  256. steps:
  257. - name: checkout
  258. uses: actions/checkout@v4
  259. # only download llvm cache when needed
  260. - name: Get LLVM libraries
  261. id: retrieve_llvm_libs
  262. if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS')
  263. uses: actions/cache@v4
  264. with:
  265. path: |
  266. ./core/deps/llvm/build/bin
  267. ./core/deps/llvm/build/include
  268. ./core/deps/llvm/build/lib
  269. ./core/deps/llvm/build/libexec
  270. ./core/deps/llvm/build/share
  271. key: ${{ matrix.llvm_cache_key }}
  272. - name: Quit if cache miss
  273. if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS') && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
  274. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  275. - name: Build iwasm for linux
  276. if: matrix.platform == 'linux'
  277. run: |
  278. mkdir build && cd build
  279. cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
  280. cmake --build . --config Release --parallel 4
  281. working-directory: product-mini/platforms/${{ matrix.platform }}
  282. - name: Build iwasm for android
  283. if: matrix.platform == 'android'
  284. run: |
  285. mkdir build && cd build
  286. cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }} \
  287. -DWAMR_BUILD_TARGET=X86_64
  288. cmake --build . --config Release --parallel 4
  289. working-directory: product-mini/platforms/${{ matrix.platform }}
  290. build_unit_tests:
  291. needs:
  292. [
  293. build_llvm_libraries_on_ubuntu_2204,
  294. build_wamrc
  295. ]
  296. runs-on: ${{ matrix.os }}
  297. strategy:
  298. fail-fast: false
  299. matrix:
  300. os: [ubuntu-22.04]
  301. include:
  302. - os: ubuntu-22.04
  303. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
  304. steps:
  305. - name: checkout
  306. uses: actions/checkout@v4
  307. - name: Get LLVM libraries
  308. id: retrieve_llvm_libs
  309. uses: actions/cache@v4
  310. with:
  311. path: |
  312. ./core/deps/llvm/build/bin
  313. ./core/deps/llvm/build/include
  314. ./core/deps/llvm/build/lib
  315. ./core/deps/llvm/build/libexec
  316. ./core/deps/llvm/build/share
  317. key: ${{ matrix.llvm_cache_key }}
  318. - name: Quit if cache miss
  319. if: (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
  320. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  321. - name: install-wasi-sdk-wabt
  322. uses: ./.github/actions/install-wasi-sdk-wabt
  323. with:
  324. os: ${{ matrix.os }}
  325. - name: Build wamrc
  326. run: |
  327. mkdir build && cd build
  328. cmake ..
  329. cmake --build . --config Release --parallel 4
  330. working-directory: wamr-compiler
  331. - name: Build and run unit tests
  332. run: |
  333. mkdir build && cd build
  334. cmake ..
  335. cmake --build . --config Release --parallel 4
  336. ctest
  337. working-directory: tests/unit
  338. build_samples_wasm_c_api:
  339. needs:
  340. [
  341. build_iwasm,
  342. build_llvm_libraries_on_ubuntu_2204,
  343. build_wamrc,
  344. ]
  345. runs-on: ${{ matrix.os }}
  346. strategy:
  347. fail-fast: false
  348. matrix:
  349. make_options: [
  350. # Running mode
  351. $AOT_BUILD_OPTIONS,
  352. $CLASSIC_INTERP_BUILD_OPTIONS,
  353. $FAST_INTERP_BUILD_OPTIONS,
  354. $FAST_JIT_BUILD_OPTIONS,
  355. $LLVM_LAZY_JIT_BUILD_OPTIONS,
  356. $LLVM_EAGER_JIT_BUILD_OPTIONS,
  357. $MULTI_TIER_JIT_BUILD_OPTIONS,
  358. ]
  359. os: [ubuntu-22.04]
  360. include:
  361. - os: ubuntu-22.04
  362. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
  363. steps:
  364. - name: checkout
  365. uses: actions/checkout@v4
  366. - name: Get LLVM libraries
  367. id: retrieve_llvm_libs
  368. if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
  369. uses: actions/cache@v4
  370. with:
  371. path: |
  372. ./core/deps/llvm/build/bin
  373. ./core/deps/llvm/build/include
  374. ./core/deps/llvm/build/lib
  375. ./core/deps/llvm/build/libexec
  376. ./core/deps/llvm/build/share
  377. key: ${{ matrix.llvm_cache_key }}
  378. - name: Quit if cache miss
  379. if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
  380. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  381. - name: install-wasi-sdk-wabt
  382. uses: ./.github/actions/install-wasi-sdk-wabt
  383. with:
  384. os: ${{ matrix.os }}
  385. - name: Build wamrc
  386. if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
  387. run: |
  388. mkdir build && cd build
  389. cmake ..
  390. cmake --build . --config Release --parallel 4
  391. working-directory: wamr-compiler
  392. - name: Build Sample [wasm-c-api]
  393. run: |
  394. VERBOSE=1
  395. cmake -S . -B build ${{ matrix.make_options }}
  396. cmake --build build --config Debug --parallel 4
  397. ctest --test-dir build --output-on-failure
  398. working-directory: samples/wasm-c-api
  399. build_samples_others:
  400. needs:
  401. [
  402. build_iwasm,
  403. build_llvm_libraries_on_ubuntu_2204,
  404. build_wamrc,
  405. ]
  406. runs-on: ${{ matrix.os }}
  407. strategy:
  408. matrix:
  409. os: [ubuntu-22.04]
  410. include:
  411. - os: ubuntu-22.04
  412. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
  413. steps:
  414. - name: checkout
  415. uses: actions/checkout@v4
  416. - name: Get LLVM libraries
  417. id: retrieve_llvm_libs
  418. uses: actions/cache@v4
  419. with:
  420. path: |
  421. ./core/deps/llvm/build/bin
  422. ./core/deps/llvm/build/include
  423. ./core/deps/llvm/build/lib
  424. ./core/deps/llvm/build/libexec
  425. ./core/deps/llvm/build/share
  426. key: ${{ matrix.llvm_cache_key }}
  427. - name: install-wasi-sdk-wabt
  428. uses: ./.github/actions/install-wasi-sdk-wabt
  429. with:
  430. os: ${{ matrix.os }}
  431. - name: Build wamrc
  432. run: |
  433. mkdir build && cd build
  434. cmake ..
  435. cmake --build . --config Release --parallel 4
  436. working-directory: wamr-compiler
  437. - name: Build Sample [basic]
  438. run: |
  439. cd samples/basic
  440. ./build.sh
  441. ./run.sh
  442. - name: Build Sample [file]
  443. run: |
  444. cd samples/file
  445. mkdir build && cd build
  446. cmake ..
  447. cmake --build . --config Debug --parallel 4
  448. ./src/iwasm -f wasm-app/file.wasm -d .
  449. - name: Build Sample [multi-thread]
  450. run: |
  451. cd samples/multi-thread
  452. mkdir build && cd build
  453. cmake ..
  454. cmake --build . --config Debug --parallel 4
  455. ./iwasm wasm-apps/test.wasm
  456. - name: Build Sample [multi-module]
  457. run: |
  458. cd samples/multi-module
  459. mkdir build && cd build
  460. cmake .. -DWAMR_BUILD_AOT=1
  461. cmake --build . --config Debug --parallel 4
  462. ./multi_module mC.wasm
  463. ./multi_module mC.aot
  464. - name: Build Sample [spawn-thread]
  465. run: |
  466. cd samples/spawn-thread
  467. mkdir build && cd build
  468. cmake ..
  469. cmake --build . --config Debug --parallel 4
  470. ./spawn_thread
  471. - name: Build Sample [ref-types]
  472. run: |
  473. cd samples/ref-types
  474. mkdir build && cd build
  475. cmake ..
  476. cmake --build . --config Debug --parallel 4
  477. ./hello
  478. - name: Build Sample [wasi-threads]
  479. run: |
  480. cd samples/wasi-threads
  481. mkdir build && cd build
  482. cmake ..
  483. cmake --build . --config Debug --parallel 4
  484. ./iwasm wasm-apps/no_pthread.wasm
  485. - name: Build Sample [shared-module]
  486. run: |
  487. cd samples/shared-module
  488. ./build.sh
  489. ./run.sh
  490. - name: Build Sample [terminate]
  491. run: |
  492. cd samples/terminate
  493. ./build.sh
  494. ./run.sh
  495. - name: Build Sample [debug-tools]
  496. run: |
  497. cd samples/debug-tools
  498. mkdir build && cd build
  499. cmake ..
  500. cmake --build . --config Debug --parallel 4
  501. ./iwasm wasm-apps/trap.wasm | grep "#" > call_stack.txt
  502. ./iwasm wasm-apps/trap.aot | grep "#" > call_stack_aot.txt
  503. bash -x ../symbolicate.sh
  504. - name: Build Sample [native-stack-overflow]
  505. run: |
  506. cd samples/native-stack-overflow
  507. ./build.sh
  508. ./run.sh test1
  509. ./run.sh test2
  510. - name: Build Sample [shared-heap]
  511. run: |
  512. cd samples/shared-heap
  513. mkdir build && cd build
  514. cmake ..
  515. cmake --build . --config Debug --parallel 4
  516. ./shared_heap_test
  517. ./shared_heap_test --aot
  518. test:
  519. needs:
  520. [
  521. build_iwasm,
  522. build_llvm_libraries_on_ubuntu_2204,
  523. build_wamrc,
  524. ]
  525. runs-on: ${{ matrix.os }}
  526. strategy:
  527. fail-fast: false
  528. matrix:
  529. os: [ubuntu-22.04]
  530. running_mode:
  531. [
  532. "classic-interp",
  533. "fast-interp",
  534. "jit",
  535. "aot",
  536. "fast-jit",
  537. "multi-tier-jit",
  538. ]
  539. test_option:
  540. [
  541. $DEFAULT_TEST_OPTIONS,
  542. $MULTI_MODULES_TEST_OPTIONS,
  543. $SIMD_TEST_OPTIONS,
  544. $THREADS_TEST_OPTIONS,
  545. $WASI_TEST_OPTIONS,
  546. $GC_TEST_OPTIONS,
  547. $MEMORY64_TEST_OPTIONS,
  548. $MULTI_MEMORY_TEST_OPTIONS,
  549. ]
  550. include:
  551. - os: ubuntu-22.04
  552. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
  553. ubuntu_version: "22.04"
  554. - os: ubuntu-22.04
  555. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
  556. running_mode: aot
  557. test_option: $WAMR_COMPILER_TEST_OPTIONS
  558. exclude:
  559. # incompatible modes and features
  560. # classic-interp doesn't support simd
  561. - running_mode: "classic-interp"
  562. test_option: $SIMD_TEST_OPTIONS
  563. # llvm jit doesn't support multi module
  564. - running_mode: "jit"
  565. test_option: $MULTI_MODULES_TEST_OPTIONS
  566. # fast-jit doesn't support multi module, simd
  567. - running_mode: "fast-jit"
  568. test_option: $MULTI_MODULES_TEST_OPTIONS
  569. - running_mode: "fast-jit"
  570. test_option: $SIMD_TEST_OPTIONS
  571. # multi-tier-jit doesn't support multi module, simd
  572. - running_mode: "multi-tier-jit"
  573. test_option: $MULTI_MODULES_TEST_OPTIONS
  574. - running_mode: "multi-tier-jit"
  575. test_option: $SIMD_TEST_OPTIONS
  576. # fast-jit and multi-tier-jit don't support GC
  577. - running_mode: "fast-jit"
  578. test_option: $GC_TEST_OPTIONS
  579. - running_mode: "multi-tier-jit"
  580. test_option: $GC_TEST_OPTIONS
  581. # fast-interp, fast-jit, llvm-jit, multi-tier-jit don't support Memory64
  582. - running_mode: "fast-interp"
  583. test_option: $MEMORY64_TEST_OPTIONS
  584. - running_mode: "fast-jit"
  585. test_option: $MEMORY64_TEST_OPTIONS
  586. - running_mode: "jit"
  587. test_option: $MEMORY64_TEST_OPTIONS
  588. - running_mode: "multi-tier-jit"
  589. test_option: $MEMORY64_TEST_OPTIONS
  590. # aot, fast-interp, fast-jit, llvm-jit, multi-tier-jit don't support Multi Memory
  591. - running_mode: "aot"
  592. test_option: $MULTI_MEMORY_TEST_OPTIONS
  593. - running_mode: "fast-interp"
  594. test_option: $MULTI_MEMORY_TEST_OPTIONS
  595. - running_mode: "fast-jit"
  596. test_option: $MULTI_MEMORY_TEST_OPTIONS
  597. - running_mode: "jit"
  598. test_option: $MULTI_MEMORY_TEST_OPTIONS
  599. - running_mode: "multi-tier-jit"
  600. test_option: $MULTI_MEMORY_TEST_OPTIONS
  601. steps:
  602. - name: checkout
  603. uses: actions/checkout@v4
  604. - name: Set-up OCaml
  605. uses: ocaml/setup-ocaml@v3
  606. if: matrix.test_option == '$GC_TEST_OPTIONS'
  607. with:
  608. ocaml-compiler: 4.13
  609. - name: Set-up Ocamlbuild
  610. if: matrix.test_option == '$GC_TEST_OPTIONS'
  611. run: opam install ocamlbuild dune menhir
  612. - name: download and install wasi-sdk
  613. if: matrix.test_option == '$WASI_TEST_OPTIONS'
  614. uses: ./.github/actions/install-wasi-sdk-wabt
  615. with:
  616. os: ${{ matrix.os }}
  617. # It is a temporary solution until new wasi-sdk that includes bug fixes is released
  618. - name: build wasi-libc from source
  619. if: matrix.test_option == '$WASI_TEST_OPTIONS'
  620. run: |
  621. git clone https://github.com/WebAssembly/wasi-libc
  622. cd wasi-libc
  623. make -j AR=/opt/wasi-sdk/bin/llvm-ar NM=/opt/wasi-sdk/bin/llvm-nm CC=/opt/wasi-sdk/bin/clang THREAD_MODEL=posix
  624. echo "SYSROOT_PATH=$PWD/sysroot" >> $GITHUB_ENV
  625. - name: set env variable(if llvm are used)
  626. if: matrix.running_mode == 'aot' || matrix.running_mode == 'jit' || matrix.running_mode == 'multi-tier-jit'
  627. run: echo "USE_LLVM=true" >> $GITHUB_ENV
  628. - name: set env variable(if x86_32 test needed)
  629. if: >
  630. ((matrix.test_option == '$DEFAULT_TEST_OPTIONS' || matrix.test_option == '$THREADS_TEST_OPTIONS'
  631. || matrix.test_option == '$WASI_TEST_OPTIONS' || matrix.test_option == '$GC_TEST_OPTIONS')
  632. && matrix.test_option != '$MEMORY64_TEST_OPTIONS'
  633. && matrix.running_mode != 'fast-jit' && matrix.running_mode != 'jit' && matrix.running_mode != 'multi-tier-jit')
  634. run: echo "TEST_ON_X86_32=true" >> $GITHUB_ENV
  635. #only download llvm libraries in jit and aot mode
  636. - name: Get LLVM libraries
  637. if: env.USE_LLVM == 'true'
  638. id: retrieve_llvm_libs
  639. uses: actions/cache@v4
  640. with:
  641. path: |
  642. ./core/deps/llvm/build/bin
  643. ./core/deps/llvm/build/include
  644. ./core/deps/llvm/build/lib
  645. ./core/deps/llvm/build/libexec
  646. ./core/deps/llvm/build/share
  647. key: ${{ matrix.llvm_cache_key }}
  648. - name: Quit if cache miss
  649. if: env.USE_LLVM == 'true' && steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
  650. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  651. - name: install jq JSON processor
  652. if: matrix.running_mode == 'aot' && matrix.test_option == '$WASI_TEST_OPTIONS'
  653. run: sudo apt-get update && sudo apt install -y jq
  654. - name: Build WASI thread tests
  655. if: matrix.test_option == '$WASI_TEST_OPTIONS'
  656. run: bash build.sh --sysroot "$SYSROOT_PATH"
  657. working-directory: ./core/iwasm/libraries/lib-wasi-threads/test/
  658. - name: build socket api tests
  659. if: matrix.test_option == '$WASI_TEST_OPTIONS'
  660. run: bash build.sh
  661. working-directory: ./core/iwasm/libraries/lib-socket/test/
  662. - name: run tests
  663. timeout-minutes: 30
  664. if: matrix.test_option != '$GC_TEST_OPTIONS'
  665. run: ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  666. working-directory: ./tests/wamr-test-suites
  667. - name: run gc tests
  668. timeout-minutes: 20
  669. if: matrix.test_option == '$GC_TEST_OPTIONS'
  670. run: |
  671. eval $(opam env)
  672. ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  673. working-directory: ./tests/wamr-test-suites
  674. #only install x32 support libraries when to run x86_32 cases
  675. - name: install x32 support libraries
  676. if: env.TEST_ON_X86_32 == 'true'
  677. run:
  678. # Add another apt repository as some packages cannot
  679. # be downloaded with the github default repository
  680. sudo curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc &&
  681. sudo apt-add-repository https://packages.microsoft.com/ubuntu/${{ matrix.ubuntu_version }}/prod &&
  682. sudo apt-get update &&
  683. sudo apt install -y g++-multilib lib32gcc-9-dev
  684. - name: run tests x86_32
  685. timeout-minutes: 30
  686. if: env.TEST_ON_X86_32 == 'true' && matrix.test_option != '$GC_TEST_OPTIONS'
  687. run: ./test_wamr.sh ${{ env.X86_32_TARGET_TEST_OPTIONS }} ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  688. working-directory: ./tests/wamr-test-suites
  689. - name: run gc tests x86_32
  690. timeout-minutes: 20
  691. if: env.TEST_ON_X86_32 == 'true' && matrix.test_option == '$GC_TEST_OPTIONS'
  692. run: |
  693. eval $(opam env)
  694. ./test_wamr.sh ${{ env.X86_32_TARGET_TEST_OPTIONS }} ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  695. working-directory: ./tests/wamr-test-suites
  696. test-wamr-ide:
  697. needs:
  698. [
  699. build_iwasm
  700. ]
  701. runs-on: ubuntu-22.04
  702. env:
  703. PYTHON_VERSION: '3.10'
  704. PYTHON_UBUNTU_STANDALONE_BUILD: https://github.com/indygreg/python-build-standalone/releases/download/20230507/cpython-3.10.11+20230507-x86_64-unknown-linux-gnu-install_only.tar.gz
  705. steps:
  706. - name: checkout
  707. uses: actions/checkout@v4
  708. - name: install dependencies
  709. run: |
  710. rustup target add wasm32-wasip1
  711. sudo apt update && sudo apt-get install -y lld ninja-build
  712. npm install
  713. working-directory: test-tools/wamr-ide/VSCode-Extension
  714. - name: code style check
  715. run: |
  716. npm install --save-dev prettier
  717. npm run prettier-format-check
  718. working-directory: test-tools/wamr-ide/VSCode-Extension
  719. - name: build iwasm with source debugging feature
  720. run: |
  721. mkdir build
  722. cd build
  723. cmake .. -DWAMR_BUILD_DEBUG_INTERP=1 -DWAMR_BUILD_REF_TYPES=1
  724. make
  725. working-directory: product-mini/platforms/linux
  726. - name: Cache LLDB
  727. id: cache-lldb
  728. uses: actions/cache@v4
  729. env:
  730. cache-name: cache-lldb-vscode
  731. with:
  732. path: test-tools/wamr-ide/VSCode-Extension/resource/debug/linux
  733. key: ${{ env.cache-name }}-${{ hashFiles('build-scripts/lldb_wasm.patch') }}-${{ env.PYTHON_UBUNTU_STANDALONE_BUILD }}
  734. - if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }}
  735. name: get stand-alone python ubuntu
  736. run: |
  737. wget ${{ env.PYTHON_UBUNTU_STANDALONE_BUILD }} -O python.tar.gz
  738. tar -xvf python.tar.gz
  739. working-directory: core/deps
  740. - if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }}
  741. name: download llvm
  742. run: |
  743. wget https://github.com/llvm/llvm-project/archive/1f27fe6128769f00197925c3b8f6abb9d0e5cd2e.zip
  744. unzip -q 1f27fe6128769f00197925c3b8f6abb9d0e5cd2e.zip
  745. mv llvm-project-1f27fe6128769f00197925c3b8f6abb9d0e5cd2e llvm-project
  746. working-directory: core/deps
  747. - if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }}
  748. name: apply wamr patch
  749. run: |
  750. git init
  751. git config user.email "action@github.com"
  752. git config user.name "github action"
  753. git apply ../../../build-scripts/lldb_wasm.patch
  754. working-directory: core/deps/llvm-project
  755. - if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }}
  756. name: build lldb ubuntu
  757. run: |
  758. echo "start to build lldb..."
  759. mkdir -p wamr-lldb
  760. cmake -S ./llvm -B build \
  761. -G Ninja \
  762. -DCMAKE_INSTALL_PREFIX=../wamr-lldb \
  763. -DCMAKE_BUILD_TYPE:STRING="Release" \
  764. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
  765. -DLLVM_ENABLE_PROJECTS="clang;lldb" \
  766. -DLLVM_TARGETS_TO_BUILD:STRING="X86;WebAssembly" \
  767. -DLLVM_BUILD_BENCHMARKS:BOOL=OFF \
  768. -DLLVM_BUILD_DOCS:BOOL=OFF \
  769. -DLLVM_BUILD_EXAMPLES:BOOL=OFF \
  770. -DLLVM_BUILD_LLVM_DYLIB:BOOL=OFF \
  771. -DLLVM_BUILD_TESTS:BOOL=OFF \
  772. -DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF \
  773. -DLLVM_INCLUDE_DOCS:BOOL=OFF \
  774. -DLLVM_INCLUDE_EXAMPLES:BOOL=OFF \
  775. -DLLVM_INCLUDE_TESTS:BOOL=OFF \
  776. -DLLVM_ENABLE_BINDINGS:BOOL=OFF \
  777. -DLLVM_ENABLE_LIBXML2:BOOL=ON \
  778. -DLLVM_ENABLE_LLD:BOOL=ON \
  779. -DLLDB_ENABLE_PYTHON:BOOL=ON \
  780. -DLLDB_EMBED_PYTHON_HOME=ON \
  781. -DLLDB_PYTHON_HOME=.. \
  782. -DLLDB_PYTHON_RELATIVE_PATH=lib/lldb-python \
  783. -DPython3_EXECUTABLE="$(pwd)/../python/bin/python${{ env.PYTHON_VERSION }}"
  784. cmake --build build --target lldb install --parallel $(nproc)
  785. working-directory: core/deps/llvm-project
  786. - if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }}
  787. name: copy lldb to extension folder
  788. run: |
  789. mkdir -p bin
  790. mkdir -p lib
  791. cp ../../../../../../core/deps/llvm-project/lldb/tools/lldb-vscode/package.json ./
  792. cp -r ../../../../../../core/deps/llvm-project/lldb/tools/lldb-vscode/syntaxes/ ./
  793. cp ../../../../../../core/deps/llvm-project/build/bin/lldb* bin
  794. cp ../../../../../../core/deps/llvm-project/build/lib/liblldb*.so lib
  795. cp ../../../../../../core/deps/llvm-project/build/lib/liblldb*.so.* lib
  796. cp -R ../../../../../../core/deps/llvm-project/build/lib/lldb-python lib
  797. cp -R ../../../../../../core/deps/python/lib/python* lib
  798. cp ../../../../../../core/deps/python/lib/libpython${{ env.PYTHON_VERSION }}.so.1.0 lib
  799. working-directory: test-tools/wamr-ide/VSCode-Extension/resource/debug/linux
  800. - name: run tests
  801. timeout-minutes: 5
  802. run: xvfb-run npm run test
  803. working-directory: test-tools/wamr-ide/VSCode-Extension