compilation_on_android_ubuntu.yml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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-20.04, 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/**"
  12. - "build-scripts/**"
  13. - "core/**"
  14. - "!core/deps/**"
  15. - "product-mini/**"
  16. - "samples/**"
  17. - "!samples/workload/**"
  18. - "tests/wamr-test-suites/**"
  19. - "wamr-compiler/**"
  20. - "wamr-sdk/**"
  21. # will be triggered on push events
  22. push:
  23. branches:
  24. - main
  25. - "dev/**"
  26. paths:
  27. - ".github/**"
  28. - "build-scripts/**"
  29. - "core/**"
  30. - "!core/deps/**"
  31. - "product-mini/**"
  32. - "samples/**"
  33. - "!samples/workload/**"
  34. - "tests/wamr-test-suites/**"
  35. - "wamr-compiler/**"
  36. - "wamr-sdk/**"
  37. # allow to be triggered manually
  38. workflow_dispatch:
  39. # Cancel any in-flight jobs for the same PR/branch so there's only one active
  40. # at a time
  41. concurrency:
  42. group: ${{ github.workflow }}-${{ github.ref }}
  43. cancel-in-progress: true
  44. env:
  45. # For BUILD
  46. 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"
  47. 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"
  48. 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"
  49. 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"
  50. 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"
  51. 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"
  52. # LLVM
  53. LLVM_CACHE_SUFFIX: "build-llvm_libraries_ex"
  54. # For Spec Test
  55. DEFAULT_TEST_OPTIONS: "-s spec -b -P"
  56. MULTI_MODULES_TEST_OPTIONS: "-s spec -b -M -P"
  57. SIMD_TEST_OPTIONS: "-s spec -b -S -P"
  58. THREADS_TEST_OPTIONS: "-s spec -b -p -P"
  59. X86_32_TARGET_TEST_OPTIONS: "-m x86_32 -P"
  60. jobs:
  61. build_llvm_libraries:
  62. uses: ./.github/workflows/build_llvm_libraries.yml
  63. with:
  64. runs-on: "['ubuntu-20.04', 'ubuntu-22.04']"
  65. build_wamrc:
  66. needs: [build_llvm_libraries]
  67. runs-on: ${{ matrix.os }}
  68. strategy:
  69. matrix:
  70. os: [ubuntu-20.04, ubuntu-22.04]
  71. steps:
  72. - name: checkout
  73. uses: actions/checkout@v3
  74. - name: Get LLVM libraries
  75. id: cache_llvm
  76. uses: actions/cache@v3
  77. with:
  78. path: |
  79. ./core/deps/llvm/build/bin
  80. ./core/deps/llvm/build/include
  81. ./core/deps/llvm/build/lib
  82. ./core/deps/llvm/build/libexec
  83. ./core/deps/llvm/build/share
  84. key: ${{ matrix.os }}-${{ env.LLVM_CACHE_SUFFIX }}
  85. - name: Quit if cache miss
  86. if: steps.cache_llvm.outputs.cache-hit != 'true'
  87. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  88. - name: Build wamrc
  89. run: |
  90. mkdir build && cd build
  91. cmake ..
  92. cmake --build . --config Release --parallel 4
  93. working-directory: wamr-compiler
  94. build_iwasm:
  95. needs: [build_llvm_libraries]
  96. runs-on: ${{ matrix.os }}
  97. strategy:
  98. matrix:
  99. make_options_run_mode: [
  100. # Running mode
  101. $AOT_BUILD_OPTIONS,
  102. $CLASSIC_INTERP_BUILD_OPTIONS,
  103. $FAST_INTERP_BUILD_OPTIONS,
  104. $FAST_JIT_BUILD_OPTIONS,
  105. $LLVM_LAZY_JIT_BUILD_OPTIONS,
  106. $LLVM_EAGER_JIT_BUILD_OPTIONS,
  107. ]
  108. make_options_feature: [
  109. # Features
  110. "-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
  111. "-DWAMR_BUILD_DEBUG_AOT=1",
  112. "-DWAMR_BUILD_DEBUG_INTERP=1",
  113. "-DWAMR_BUILD_DUMP_CALL_STACK=1",
  114. "-DWAMR_BUILD_LIB_PTHREAD=1",
  115. "-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1",
  116. "-DWAMR_BUILD_MINI_LOADER=1",
  117. "-DWAMR_BUILD_MEMORY_PROFILING=1",
  118. "-DWAMR_BUILD_MULTI_MODULE=1",
  119. "-DWAMR_BUILD_PERF_PROFILING=1",
  120. "-DWAMR_BUILD_REF_TYPES=1",
  121. "-DWAMR_BUILD_SIMD=1",
  122. "-DWAMR_BUILD_TAIL_CALL=1",
  123. "-DWAMR_DISABLE_HW_BOUND_CHECK=1",
  124. ]
  125. os: [ubuntu-20.04, ubuntu-22.04]
  126. platform: [android, linux]
  127. exclude:
  128. # uncompatiable feature and platform
  129. # uncompatiable mode and feature
  130. # MULTI_MODULE only on INTERP mode
  131. - make_options_run_mode: $AOT_BUILD_OPTIONS
  132. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  133. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  134. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  135. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  136. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  137. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  138. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  139. # SIMD only on JIT/AOT mode
  140. - make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
  141. make_options_feature: "-DWAMR_BUILD_SIMD=1"
  142. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  143. make_options_feature: "-DWAMR_BUILD_SIMD=1"
  144. # DEBUG_INTERP only on CLASSIC INTERP mode
  145. - make_options_run_mode: $AOT_BUILD_OPTIONS
  146. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  147. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  148. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  149. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  150. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  151. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  152. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  153. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  154. make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
  155. # DEBUG_AOT only on JIT/AOT mode
  156. - make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
  157. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  158. - make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
  159. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  160. # TODO: DEBUG_AOT on JIT
  161. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  162. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  163. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  164. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  165. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  166. make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
  167. # MINI_LOADER only on INTERP mode
  168. - make_options_run_mode: $AOT_BUILD_OPTIONS
  169. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  170. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  171. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  172. - make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
  173. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  174. - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
  175. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  176. # Fast-JIT mode doesn't support android(X86-32)
  177. - make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
  178. platform: android
  179. steps:
  180. - name: checkout
  181. uses: actions/checkout@v3
  182. # only download llvm cache when needed
  183. - name: Get LLVM libraries
  184. id: cache_llvm
  185. if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS')
  186. uses: actions/cache@v3
  187. with:
  188. path: |
  189. ./core/deps/llvm/build/bin
  190. ./core/deps/llvm/build/include
  191. ./core/deps/llvm/build/lib
  192. ./core/deps/llvm/build/libexec
  193. ./core/deps/llvm/build/share
  194. key: ${{ matrix.os }}-${{ env.LLVM_CACHE_SUFFIX }}
  195. - name: Quit if cache miss
  196. if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS') && (steps.cache_llvm.outputs.cache-hit != 'true')
  197. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  198. - name: Build iwasm
  199. run: |
  200. mkdir build && cd build
  201. cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
  202. cmake --build . --config Release --parallel 4
  203. working-directory: product-mini/platforms/${{ matrix.platform }}
  204. build_samples_wasm_c_api:
  205. needs: [build_iwasm, build_llvm_libraries, build_wamrc]
  206. runs-on: ${{ matrix.os }}
  207. strategy:
  208. matrix:
  209. make_options: [
  210. # Running mode
  211. $AOT_BUILD_OPTIONS,
  212. $CLASSIC_INTERP_BUILD_OPTIONS,
  213. $FAST_INTERP_BUILD_OPTIONS,
  214. $FAST_JIT_BUILD_OPTIONS,
  215. $LLVM_LAZY_JIT_BUILD_OPTIONS,
  216. $LLVM_EAGER_JIT_BUILD_OPTIONS,
  217. ]
  218. os: [ubuntu-20.04, ubuntu-22.04]
  219. wasi_sdk_release:
  220. [
  221. "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz",
  222. ]
  223. wabt_release:
  224. [
  225. "https://github.com/WebAssembly/wabt/releases/download/1.0.24/wabt-1.0.24-ubuntu.tar.gz",
  226. ]
  227. steps:
  228. - name: checkout
  229. uses: actions/checkout@v3
  230. - name: Get LLVM libraries
  231. id: cache_llvm
  232. if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
  233. uses: actions/cache@v3
  234. with:
  235. path: |
  236. ./core/deps/llvm/build/bin
  237. ./core/deps/llvm/build/include
  238. ./core/deps/llvm/build/lib
  239. ./core/deps/llvm/build/libexec
  240. ./core/deps/llvm/build/share
  241. key: ${{ matrix.os }}-${{ env.LLVM_CACHE_SUFFIX }}
  242. - name: Quit if cache miss
  243. if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) && (steps.cache_llvm.outputs.cache-hit != 'true')
  244. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  245. - name: download and install wabt
  246. run: |
  247. cd /opt
  248. sudo wget ${{ matrix.wabt_release }}
  249. sudo tar -xzf wabt-1.0.24-*.tar.gz
  250. sudo mv wabt-1.0.24 wabt
  251. - name: Build wamrc
  252. if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
  253. run: |
  254. mkdir build && cd build
  255. cmake ..
  256. cmake --build . --config Release --parallel 4
  257. working-directory: wamr-compiler
  258. - name: Build Sample [wasm-c-api]
  259. run: |
  260. mkdir build && cd build
  261. cmake .. ${{ matrix.make_options }}
  262. cmake --build . --config Release --parallel 4
  263. ./callback
  264. ./callback_chain
  265. ./empty_imports
  266. ./global
  267. ./hello
  268. ./hostref
  269. ./memory
  270. ./reflect
  271. ./table
  272. ./trap
  273. working-directory: samples/wasm-c-api
  274. build_samples_others:
  275. needs: [build_iwasm]
  276. runs-on: ${{ matrix.os }}
  277. strategy:
  278. matrix:
  279. os: [ubuntu-20.04, ubuntu-22.04]
  280. wasi_sdk_release:
  281. [
  282. "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz",
  283. ]
  284. wabt_release:
  285. [
  286. "https://github.com/WebAssembly/wabt/releases/download/1.0.24/wabt-1.0.24-ubuntu.tar.gz",
  287. ]
  288. steps:
  289. - name: checkout
  290. uses: actions/checkout@v3
  291. - name: download and install wasi-sdk
  292. run: |
  293. cd /opt
  294. sudo wget ${{ matrix.wasi_sdk_release }}
  295. sudo tar -xzf wasi-sdk-12.0-*.tar.gz
  296. sudo mv wasi-sdk-12.0 wasi-sdk
  297. - name: download and install wabt
  298. run: |
  299. cd /opt
  300. sudo wget ${{ matrix.wabt_release }}
  301. sudo tar -xzf wabt-1.0.24-*.tar.gz
  302. sudo mv wabt-1.0.24 wabt
  303. - name: Build Sample [basic]
  304. run: |
  305. cd samples/basic
  306. ./build.sh
  307. ./run.sh
  308. - name: Build Sample [file]
  309. run: |
  310. cd samples/file
  311. mkdir build && cd build
  312. cmake ..
  313. cmake --build . --config Release --parallel 4
  314. ./src/iwasm -f wasm-app/file.wasm -d .
  315. - name: Build Sample [multi-thread]
  316. run: |
  317. cd samples/multi-thread
  318. mkdir build && cd build
  319. cmake ..
  320. cmake --build . --config Release --parallel 4
  321. ./iwasm wasm-apps/test.wasm
  322. - name: Build Sample [multi-module]
  323. run: |
  324. cd samples/multi-module
  325. mkdir build && cd build
  326. cmake ..
  327. cmake --build . --config Release --parallel 4
  328. ./multi_module
  329. - name: Build Sample [spawn-thread]
  330. run: |
  331. cd samples/spawn-thread
  332. mkdir build && cd build
  333. cmake ..
  334. cmake --build . --config Release --parallel 4
  335. ./spawn_thread
  336. - name: Build Sample [ref-types]
  337. run: |
  338. cd samples/ref-types
  339. mkdir build && cd build
  340. cmake ..
  341. cmake --build . --config Release --parallel 4
  342. ./hello
  343. - name: Build Sample [simple]
  344. run: |
  345. ./build.sh -p host-interp
  346. python3 ./sample_test_run.py $(pwd)/out
  347. exit $?
  348. working-directory: ./samples/simple
  349. spec_test:
  350. needs: [build_iwasm, build_llvm_libraries, build_wamrc]
  351. runs-on: ubuntu-20.04
  352. strategy:
  353. matrix:
  354. running_mode:
  355. ["classic-interp", "fast-interp", "jit", "aot", "fast-jit"]
  356. test_option:
  357. [
  358. $DEFAULT_TEST_OPTIONS,
  359. $MULTI_MODULES_TEST_OPTIONS,
  360. $SIMD_TEST_OPTIONS,
  361. $THREADS_TEST_OPTIONS,
  362. ]
  363. exclude:
  364. # uncompatiable modes and features
  365. # classic-interp and fast-interp don't support simd
  366. - running_mode: "classic-interp"
  367. test_option: $SIMD_TEST_OPTIONS
  368. - running_mode: "fast-interp"
  369. test_option: $SIMD_TEST_OPTIONS
  370. # aot and jit don't support multi module
  371. - running_mode: "aot"
  372. test_option: $MULTI_MODULES_TEST_OPTIONS
  373. - running_mode: "jit"
  374. test_option: $MULTI_MODULES_TEST_OPTIONS
  375. # fast-jit is only tested on default mode, exclude other three
  376. - running_mode: "fast-jit"
  377. test_option: $MULTI_MODULES_TEST_OPTIONS
  378. - running_mode: "fast-jit"
  379. test_option: $SIMD_TEST_OPTIONS
  380. - running_mode: "fast-jit"
  381. test_option: $THREADS_TEST_OPTIONS
  382. steps:
  383. - name: checkout
  384. uses: actions/checkout@v3
  385. - name: set env variable(if llvm are used)
  386. if: matrix.running_mode == 'aot' || matrix.running_mode == 'jit'
  387. run: echo "USE_LLVM=true" >> $GITHUB_ENV
  388. - name: set env variable(if x86_32 test needed)
  389. if: >
  390. (matrix.test_option == '$DEFAULT_TEST_OPTIONS' || matrix.test_option == '$THREADS_TEST_OPTIONS')
  391. && matrix.running_mode != 'fast-jit' && matrix.running_mode != 'jit'
  392. run: echo "TEST_ON_X86_32=true" >> $GITHUB_ENV
  393. #only download llvm libraries in jit and aot mode
  394. - name: Get LLVM libraries
  395. if: env.USE_LLVM == 'true'
  396. id: cache_llvm
  397. uses: actions/cache@v3
  398. with:
  399. path: |
  400. ./core/deps/llvm/build/bin
  401. ./core/deps/llvm/build/include
  402. ./core/deps/llvm/build/lib
  403. ./core/deps/llvm/build/libexec
  404. ./core/deps/llvm/build/share
  405. key: ubuntu-20.04-${{ env.LLVM_CACHE_SUFFIX }}
  406. - name: Quit if cache miss
  407. if: env.USE_LLVM == 'true' && steps.cache_llvm.outputs.cache-hit != 'true'
  408. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  409. - name: run spec tests default and extra
  410. run: ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  411. working-directory: ./tests/wamr-test-suites
  412. #only install x32 support libraries when to run x86_32 cases
  413. - name: install x32 support libraries
  414. if: env.TEST_ON_X86_32 == 'true'
  415. run:
  416. # Add another apt repository as some packages cannot
  417. # be downloaded with the github default repository
  418. sudo curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc &&
  419. sudo apt-add-repository https://packages.microsoft.com/ubuntu/20.04/prod &&
  420. sudo apt-get update &&
  421. sudo apt install -y g++-multilib lib32gcc-9-dev
  422. - name: run spec tests x86_32
  423. if: env.TEST_ON_X86_32 == 'true'
  424. run: ./test_wamr.sh ${{ env.X86_32_TARGET_TEST_OPTIONS }} ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  425. working-directory: ./tests/wamr-test-suites