compilation_on_android_ubuntu.yml 35 KB

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