compilation_on_android_ubuntu.yml 34 KB

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