compilation_on_android_ubuntu.yml 31 KB

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