compilation_on_android_ubuntu.yml 33 KB

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