compilation_on_android_ubuntu.yml 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925
  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. wasi_sdk_release:
  302. [
  303. "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz",
  304. ]
  305. wabt_release:
  306. [
  307. "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz",
  308. ]
  309. include:
  310. - os: ubuntu-22.04
  311. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
  312. steps:
  313. - name: checkout
  314. uses: actions/checkout@v4
  315. - name: Get LLVM libraries
  316. id: retrieve_llvm_libs
  317. uses: actions/cache@v4
  318. with:
  319. path: |
  320. ./core/deps/llvm/build/bin
  321. ./core/deps/llvm/build/include
  322. ./core/deps/llvm/build/lib
  323. ./core/deps/llvm/build/libexec
  324. ./core/deps/llvm/build/share
  325. key: ${{ matrix.llvm_cache_key }}
  326. - name: Quit if cache miss
  327. if: (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
  328. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  329. - name: download and install wasi-sdk
  330. run: |
  331. cd /opt
  332. sudo wget ${{ matrix.wasi_sdk_release }}
  333. sudo tar -xzf wasi-sdk-*.tar.gz
  334. sudo ln -sf wasi-sdk-20.0 wasi-sdk
  335. - name: download and install wabt
  336. run: |
  337. cd /opt
  338. sudo wget ${{ matrix.wabt_release }}
  339. sudo tar -xzf wabt-1.0.31-*.tar.gz
  340. sudo mv wabt-1.0.31 wabt
  341. - name: Build wamrc
  342. run: |
  343. mkdir build && cd build
  344. cmake ..
  345. cmake --build . --config Release --parallel 4
  346. working-directory: wamr-compiler
  347. - name: Build and run unit tests
  348. run: |
  349. mkdir build && cd build
  350. cmake ..
  351. cmake --build . --config Release --parallel 4
  352. ctest
  353. working-directory: tests/unit
  354. build_samples_wasm_c_api:
  355. needs:
  356. [
  357. build_iwasm,
  358. build_llvm_libraries_on_ubuntu_2204,
  359. build_wamrc,
  360. ]
  361. runs-on: ${{ matrix.os }}
  362. strategy:
  363. fail-fast: false
  364. matrix:
  365. make_options: [
  366. # Running mode
  367. $AOT_BUILD_OPTIONS,
  368. $CLASSIC_INTERP_BUILD_OPTIONS,
  369. $FAST_INTERP_BUILD_OPTIONS,
  370. $FAST_JIT_BUILD_OPTIONS,
  371. $LLVM_LAZY_JIT_BUILD_OPTIONS,
  372. $LLVM_EAGER_JIT_BUILD_OPTIONS,
  373. $MULTI_TIER_JIT_BUILD_OPTIONS,
  374. ]
  375. os: [ubuntu-22.04]
  376. wasi_sdk_release:
  377. [
  378. "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz",
  379. ]
  380. wabt_release:
  381. [
  382. "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz",
  383. ]
  384. include:
  385. - os: ubuntu-22.04
  386. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
  387. steps:
  388. - name: checkout
  389. uses: actions/checkout@v4
  390. - name: Get LLVM libraries
  391. id: retrieve_llvm_libs
  392. if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
  393. uses: actions/cache@v4
  394. with:
  395. path: |
  396. ./core/deps/llvm/build/bin
  397. ./core/deps/llvm/build/include
  398. ./core/deps/llvm/build/lib
  399. ./core/deps/llvm/build/libexec
  400. ./core/deps/llvm/build/share
  401. key: ${{ matrix.llvm_cache_key }}
  402. - name: Quit if cache miss
  403. if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
  404. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  405. - name: download and install wabt
  406. run: |
  407. cd /opt
  408. sudo wget ${{ matrix.wabt_release }}
  409. sudo tar -xzf wabt-1.0.31-*.tar.gz
  410. sudo mv wabt-1.0.31 wabt
  411. - name: Build wamrc
  412. if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
  413. run: |
  414. mkdir build && cd build
  415. cmake ..
  416. cmake --build . --config Release --parallel 4
  417. working-directory: wamr-compiler
  418. - name: Build Sample [wasm-c-api]
  419. run: |
  420. VERBOSE=1
  421. cmake -S . -B build ${{ matrix.make_options }}
  422. cmake --build build --config Debug --parallel 4
  423. ctest --test-dir build --output-on-failure
  424. working-directory: samples/wasm-c-api
  425. build_samples_others:
  426. needs:
  427. [
  428. build_iwasm,
  429. build_llvm_libraries_on_ubuntu_2204,
  430. build_wamrc,
  431. ]
  432. runs-on: ${{ matrix.os }}
  433. strategy:
  434. matrix:
  435. os: [ubuntu-22.04]
  436. wasi_sdk_release:
  437. [
  438. "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz",
  439. ]
  440. wabt_release:
  441. [
  442. "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz",
  443. ]
  444. include:
  445. - os: ubuntu-22.04
  446. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
  447. steps:
  448. - name: checkout
  449. uses: actions/checkout@v4
  450. - name: download and install wasi-sdk
  451. run: |
  452. cd /opt
  453. sudo wget ${{ matrix.wasi_sdk_release }}
  454. sudo tar -xzf wasi-sdk-*.tar.gz
  455. sudo ln -sf wasi-sdk-20.0 wasi-sdk
  456. - name: download and install wabt
  457. run: |
  458. cd /opt
  459. sudo wget ${{ matrix.wabt_release }}
  460. sudo tar -xzf wabt-1.0.31-*.tar.gz
  461. sudo ln -sf wabt-1.0.31 wabt
  462. - name: Get LLVM libraries
  463. id: retrieve_llvm_libs
  464. uses: actions/cache@v4
  465. with:
  466. path: |
  467. ./core/deps/llvm/build/bin
  468. ./core/deps/llvm/build/include
  469. ./core/deps/llvm/build/lib
  470. ./core/deps/llvm/build/libexec
  471. ./core/deps/llvm/build/share
  472. key: ${{ matrix.llvm_cache_key }}
  473. - name: Build wamrc
  474. run: |
  475. mkdir build && cd build
  476. cmake ..
  477. cmake --build . --config Release --parallel 4
  478. working-directory: wamr-compiler
  479. - name: Build Sample [basic]
  480. run: |
  481. cd samples/basic
  482. ./build.sh
  483. ./run.sh
  484. - name: Build Sample [file]
  485. run: |
  486. cd samples/file
  487. mkdir build && cd build
  488. cmake ..
  489. cmake --build . --config Debug --parallel 4
  490. ./src/iwasm -f wasm-app/file.wasm -d .
  491. - name: Build Sample [multi-thread]
  492. run: |
  493. cd samples/multi-thread
  494. mkdir build && cd build
  495. cmake ..
  496. cmake --build . --config Debug --parallel 4
  497. ./iwasm wasm-apps/test.wasm
  498. - name: Build Sample [multi-module]
  499. run: |
  500. cd samples/multi-module
  501. mkdir build && cd build
  502. cmake .. -DWAMR_BUILD_AOT=1
  503. cmake --build . --config Debug --parallel 4
  504. ./multi_module mC.wasm
  505. ./multi_module mC.aot
  506. - name: Build Sample [spawn-thread]
  507. run: |
  508. cd samples/spawn-thread
  509. mkdir build && cd build
  510. cmake ..
  511. cmake --build . --config Debug --parallel 4
  512. ./spawn_thread
  513. - name: Build Sample [ref-types]
  514. run: |
  515. cd samples/ref-types
  516. mkdir build && cd build
  517. cmake ..
  518. cmake --build . --config Debug --parallel 4
  519. ./hello
  520. - name: Build Sample [wasi-threads]
  521. run: |
  522. cd samples/wasi-threads
  523. mkdir build && cd build
  524. cmake ..
  525. cmake --build . --config Debug --parallel 4
  526. ./iwasm wasm-apps/no_pthread.wasm
  527. - name: Build Sample [shared-module]
  528. run: |
  529. cd samples/shared-module
  530. ./build.sh
  531. ./run.sh
  532. - name: Build Sample [terminate]
  533. run: |
  534. cd samples/terminate
  535. ./build.sh
  536. ./run.sh
  537. - name: Build Sample [debug-tools]
  538. run: |
  539. cd samples/debug-tools
  540. mkdir build && cd build
  541. cmake ..
  542. cmake --build . --config Debug --parallel 4
  543. ./iwasm wasm-apps/trap.wasm | grep "#" > call_stack.txt
  544. ./iwasm wasm-apps/trap.aot | grep "#" > call_stack_aot.txt
  545. bash -x ../symbolicate.sh
  546. - name: Build Sample [native-stack-overflow]
  547. run: |
  548. cd samples/native-stack-overflow
  549. ./build.sh
  550. ./run.sh test1
  551. ./run.sh test2
  552. - name: Build Sample [shared-heap]
  553. run: |
  554. cd samples/shared-heap
  555. mkdir build && cd build
  556. cmake ..
  557. cmake --build . --config Debug --parallel 4
  558. ./shared_heap_test
  559. ./shared_heap_test --aot
  560. test:
  561. needs:
  562. [
  563. build_iwasm,
  564. build_llvm_libraries_on_ubuntu_2204,
  565. build_wamrc,
  566. ]
  567. runs-on: ${{ matrix.os }}
  568. strategy:
  569. fail-fast: false
  570. matrix:
  571. os: [ubuntu-22.04]
  572. running_mode:
  573. [
  574. "classic-interp",
  575. "fast-interp",
  576. "jit",
  577. "aot",
  578. "fast-jit",
  579. "multi-tier-jit",
  580. ]
  581. test_option:
  582. [
  583. $DEFAULT_TEST_OPTIONS,
  584. $MULTI_MODULES_TEST_OPTIONS,
  585. $SIMD_TEST_OPTIONS,
  586. $THREADS_TEST_OPTIONS,
  587. $WASI_TEST_OPTIONS,
  588. $GC_TEST_OPTIONS,
  589. $MEMORY64_TEST_OPTIONS,
  590. $MULTI_MEMORY_TEST_OPTIONS,
  591. ]
  592. wasi_sdk_release:
  593. [
  594. "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz",
  595. ]
  596. include:
  597. - os: ubuntu-22.04
  598. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
  599. ubuntu_version: "22.04"
  600. - os: ubuntu-22.04
  601. llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
  602. running_mode: aot
  603. test_option: $WAMR_COMPILER_TEST_OPTIONS
  604. exclude:
  605. # incompatible modes and features
  606. # classic-interp doesn't support simd
  607. - running_mode: "classic-interp"
  608. test_option: $SIMD_TEST_OPTIONS
  609. # llvm jit doesn't support multi module
  610. - running_mode: "jit"
  611. test_option: $MULTI_MODULES_TEST_OPTIONS
  612. # fast-jit doesn't support multi module, simd
  613. - running_mode: "fast-jit"
  614. test_option: $MULTI_MODULES_TEST_OPTIONS
  615. - running_mode: "fast-jit"
  616. test_option: $SIMD_TEST_OPTIONS
  617. # multi-tier-jit doesn't support multi module, simd
  618. - running_mode: "multi-tier-jit"
  619. test_option: $MULTI_MODULES_TEST_OPTIONS
  620. - running_mode: "multi-tier-jit"
  621. test_option: $SIMD_TEST_OPTIONS
  622. # fast-jit and multi-tier-jit don't support GC
  623. - running_mode: "fast-jit"
  624. test_option: $GC_TEST_OPTIONS
  625. - running_mode: "multi-tier-jit"
  626. test_option: $GC_TEST_OPTIONS
  627. # fast-interp, fast-jit, llvm-jit, multi-tier-jit don't support Memory64
  628. - running_mode: "fast-interp"
  629. test_option: $MEMORY64_TEST_OPTIONS
  630. - running_mode: "fast-jit"
  631. test_option: $MEMORY64_TEST_OPTIONS
  632. - running_mode: "jit"
  633. test_option: $MEMORY64_TEST_OPTIONS
  634. - running_mode: "multi-tier-jit"
  635. test_option: $MEMORY64_TEST_OPTIONS
  636. # aot, fast-interp, fast-jit, llvm-jit, multi-tier-jit don't support Multi Memory
  637. - running_mode: "aot"
  638. test_option: $MULTI_MEMORY_TEST_OPTIONS
  639. - running_mode: "fast-interp"
  640. test_option: $MULTI_MEMORY_TEST_OPTIONS
  641. - running_mode: "fast-jit"
  642. test_option: $MULTI_MEMORY_TEST_OPTIONS
  643. - running_mode: "jit"
  644. test_option: $MULTI_MEMORY_TEST_OPTIONS
  645. - running_mode: "multi-tier-jit"
  646. test_option: $MULTI_MEMORY_TEST_OPTIONS
  647. steps:
  648. - name: checkout
  649. uses: actions/checkout@v4
  650. - name: Set-up OCaml
  651. uses: ocaml/setup-ocaml@v3
  652. if: matrix.test_option == '$GC_TEST_OPTIONS'
  653. with:
  654. ocaml-compiler: 4.13
  655. - name: Set-up Ocamlbuild
  656. if: matrix.test_option == '$GC_TEST_OPTIONS'
  657. run: opam install ocamlbuild dune menhir
  658. - name: download and install wasi-sdk
  659. if: matrix.test_option == '$WASI_TEST_OPTIONS'
  660. run: |
  661. cd /opt
  662. sudo wget ${{ matrix.wasi_sdk_release }}
  663. sudo tar -xzf wasi-sdk-*.tar.gz
  664. sudo mv wasi-sdk-20.0 wasi-sdk
  665. # It is a temporary solution until new wasi-sdk that includes bug fixes is released
  666. - name: build wasi-libc from source
  667. if: matrix.test_option == '$WASI_TEST_OPTIONS'
  668. run: |
  669. git clone https://github.com/WebAssembly/wasi-libc
  670. cd wasi-libc
  671. 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
  672. echo "SYSROOT_PATH=$PWD/sysroot" >> $GITHUB_ENV
  673. - name: set env variable(if llvm are used)
  674. if: matrix.running_mode == 'aot' || matrix.running_mode == 'jit' || matrix.running_mode == 'multi-tier-jit'
  675. run: echo "USE_LLVM=true" >> $GITHUB_ENV
  676. - name: set env variable(if x86_32 test needed)
  677. if: >
  678. ((matrix.test_option == '$DEFAULT_TEST_OPTIONS' || matrix.test_option == '$THREADS_TEST_OPTIONS'
  679. || matrix.test_option == '$WASI_TEST_OPTIONS' || matrix.test_option == '$GC_TEST_OPTIONS')
  680. && matrix.test_option != '$MEMORY64_TEST_OPTIONS'
  681. && matrix.running_mode != 'fast-jit' && matrix.running_mode != 'jit' && matrix.running_mode != 'multi-tier-jit')
  682. run: echo "TEST_ON_X86_32=true" >> $GITHUB_ENV
  683. #only download llvm libraries in jit and aot mode
  684. - name: Get LLVM libraries
  685. if: env.USE_LLVM == 'true'
  686. id: retrieve_llvm_libs
  687. uses: actions/cache@v4
  688. with:
  689. path: |
  690. ./core/deps/llvm/build/bin
  691. ./core/deps/llvm/build/include
  692. ./core/deps/llvm/build/lib
  693. ./core/deps/llvm/build/libexec
  694. ./core/deps/llvm/build/share
  695. key: ${{ matrix.llvm_cache_key }}
  696. - name: Quit if cache miss
  697. if: env.USE_LLVM == 'true' && steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
  698. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  699. - name: install jq JSON processor
  700. if: matrix.running_mode == 'aot' && matrix.test_option == '$WASI_TEST_OPTIONS'
  701. run: sudo apt-get update && sudo apt install -y jq
  702. - name: Build WASI thread tests
  703. if: matrix.test_option == '$WASI_TEST_OPTIONS'
  704. run: bash build.sh --sysroot "$SYSROOT_PATH"
  705. working-directory: ./core/iwasm/libraries/lib-wasi-threads/test/
  706. - name: build socket api tests
  707. if: matrix.test_option == '$WASI_TEST_OPTIONS'
  708. run: bash build.sh
  709. working-directory: ./core/iwasm/libraries/lib-socket/test/
  710. - name: run tests
  711. timeout-minutes: 30
  712. if: matrix.test_option != '$GC_TEST_OPTIONS'
  713. run: ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  714. working-directory: ./tests/wamr-test-suites
  715. - name: run gc tests
  716. timeout-minutes: 20
  717. if: matrix.test_option == '$GC_TEST_OPTIONS'
  718. run: |
  719. eval $(opam env)
  720. ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  721. working-directory: ./tests/wamr-test-suites
  722. #only install x32 support libraries when to run x86_32 cases
  723. - name: install x32 support libraries
  724. if: env.TEST_ON_X86_32 == 'true'
  725. run:
  726. # Add another apt repository as some packages cannot
  727. # be downloaded with the github default repository
  728. sudo curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc &&
  729. sudo apt-add-repository https://packages.microsoft.com/ubuntu/${{ matrix.ubuntu_version }}/prod &&
  730. sudo apt-get update &&
  731. sudo apt install -y g++-multilib lib32gcc-9-dev
  732. - name: run tests x86_32
  733. timeout-minutes: 30
  734. if: env.TEST_ON_X86_32 == 'true' && matrix.test_option != '$GC_TEST_OPTIONS'
  735. run: ./test_wamr.sh ${{ env.X86_32_TARGET_TEST_OPTIONS }} ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  736. working-directory: ./tests/wamr-test-suites
  737. - name: run gc tests x86_32
  738. timeout-minutes: 20
  739. if: env.TEST_ON_X86_32 == 'true' && matrix.test_option == '$GC_TEST_OPTIONS'
  740. run: |
  741. eval $(opam env)
  742. ./test_wamr.sh ${{ env.X86_32_TARGET_TEST_OPTIONS }} ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  743. working-directory: ./tests/wamr-test-suites
  744. test-wamr-ide:
  745. needs:
  746. [
  747. build_iwasm
  748. ]
  749. runs-on: ubuntu-22.04
  750. env:
  751. PYTHON_VERSION: '3.10'
  752. 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
  753. steps:
  754. - name: checkout
  755. uses: actions/checkout@v4
  756. - name: install dependencies
  757. run: |
  758. rustup target add wasm32-wasip1
  759. sudo apt update && sudo apt-get install -y lld ninja-build
  760. npm install
  761. working-directory: test-tools/wamr-ide/VSCode-Extension
  762. - name: code style check
  763. run: |
  764. npm install --save-dev prettier
  765. npm run prettier-format-check
  766. working-directory: test-tools/wamr-ide/VSCode-Extension
  767. - name: build iwasm with source debugging feature
  768. run: |
  769. mkdir build
  770. cd build
  771. cmake .. -DWAMR_BUILD_DEBUG_INTERP=1 -DWAMR_BUILD_REF_TYPES=1
  772. make
  773. working-directory: product-mini/platforms/linux
  774. - name: Cache LLDB
  775. id: cache-lldb
  776. uses: actions/cache@v4
  777. env:
  778. cache-name: cache-lldb-vscode
  779. with:
  780. path: test-tools/wamr-ide/VSCode-Extension/resource/debug/linux
  781. key: ${{ env.cache-name }}-${{ hashFiles('build-scripts/lldb_wasm.patch') }}-${{ env.PYTHON_UBUNTU_STANDALONE_BUILD }}
  782. - if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }}
  783. name: get stand-alone python ubuntu
  784. run: |
  785. wget ${{ env.PYTHON_UBUNTU_STANDALONE_BUILD }} -O python.tar.gz
  786. tar -xvf python.tar.gz
  787. working-directory: core/deps
  788. - if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }}
  789. name: download llvm
  790. run: |
  791. wget https://github.com/llvm/llvm-project/archive/1f27fe6128769f00197925c3b8f6abb9d0e5cd2e.zip
  792. unzip -q 1f27fe6128769f00197925c3b8f6abb9d0e5cd2e.zip
  793. mv llvm-project-1f27fe6128769f00197925c3b8f6abb9d0e5cd2e llvm-project
  794. working-directory: core/deps
  795. - if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }}
  796. name: apply wamr patch
  797. run: |
  798. git init
  799. git config user.email "action@github.com"
  800. git config user.name "github action"
  801. git apply ../../../build-scripts/lldb_wasm.patch
  802. working-directory: core/deps/llvm-project
  803. - if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }}
  804. name: build lldb ubuntu
  805. run: |
  806. echo "start to build lldb..."
  807. mkdir -p wamr-lldb
  808. cmake -S ./llvm -B build \
  809. -G Ninja \
  810. -DCMAKE_INSTALL_PREFIX=../wamr-lldb \
  811. -DCMAKE_BUILD_TYPE:STRING="Release" \
  812. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
  813. -DLLVM_ENABLE_PROJECTS="clang;lldb" \
  814. -DLLVM_TARGETS_TO_BUILD:STRING="X86;WebAssembly" \
  815. -DLLVM_BUILD_BENCHMARKS:BOOL=OFF \
  816. -DLLVM_BUILD_DOCS:BOOL=OFF \
  817. -DLLVM_BUILD_EXAMPLES:BOOL=OFF \
  818. -DLLVM_BUILD_LLVM_DYLIB:BOOL=OFF \
  819. -DLLVM_BUILD_TESTS:BOOL=OFF \
  820. -DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF \
  821. -DLLVM_INCLUDE_DOCS:BOOL=OFF \
  822. -DLLVM_INCLUDE_EXAMPLES:BOOL=OFF \
  823. -DLLVM_INCLUDE_TESTS:BOOL=OFF \
  824. -DLLVM_ENABLE_BINDINGS:BOOL=OFF \
  825. -DLLVM_ENABLE_LIBXML2:BOOL=ON \
  826. -DLLVM_ENABLE_LLD:BOOL=ON \
  827. -DLLDB_ENABLE_PYTHON:BOOL=ON \
  828. -DLLDB_EMBED_PYTHON_HOME=ON \
  829. -DLLDB_PYTHON_HOME=.. \
  830. -DLLDB_PYTHON_RELATIVE_PATH=lib/lldb-python \
  831. -DPython3_EXECUTABLE="$(pwd)/../python/bin/python${{ env.PYTHON_VERSION }}"
  832. cmake --build build --target lldb install --parallel $(nproc)
  833. working-directory: core/deps/llvm-project
  834. - if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }}
  835. name: copy lldb to extension folder
  836. run: |
  837. mkdir -p bin
  838. mkdir -p lib
  839. cp ../../../../../../core/deps/llvm-project/lldb/tools/lldb-vscode/package.json ./
  840. cp -r ../../../../../../core/deps/llvm-project/lldb/tools/lldb-vscode/syntaxes/ ./
  841. cp ../../../../../../core/deps/llvm-project/build/bin/lldb* bin
  842. cp ../../../../../../core/deps/llvm-project/build/lib/liblldb*.so lib
  843. cp ../../../../../../core/deps/llvm-project/build/lib/liblldb*.so.* lib
  844. cp -R ../../../../../../core/deps/llvm-project/build/lib/lldb-python lib
  845. cp -R ../../../../../../core/deps/python/lib/python* lib
  846. cp ../../../../../../core/deps/python/lib/libpython${{ env.PYTHON_VERSION }}.so.1.0 lib
  847. working-directory: test-tools/wamr-ide/VSCode-Extension/resource/debug/linux
  848. - name: run tests
  849. timeout-minutes: 5
  850. run: xvfb-run npm run test
  851. working-directory: test-tools/wamr-ide/VSCode-Extension