compilation_on_android_ubuntu.yml 34 KB

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