compilation_on_android_ubuntu.yml 35 KB

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