compilation_on_sgx.yml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. name: compilation on SGX
  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_sgx.yml"
  13. - "build-scripts/**"
  14. - "core/**"
  15. - "!core/deps/**"
  16. - "product-mini/**"
  17. - "samples/**"
  18. - "!samples/workload/**"
  19. - "tests/wamr-test-suites/**"
  20. - "wamr-compiler/**"
  21. # will be triggered on push events
  22. push:
  23. branches:
  24. - main
  25. - "dev/**"
  26. paths:
  27. - ".github/workflows/build_llvm_libraries.yml"
  28. - ".github/workflows/compilation_on_sgx.yml"
  29. - "build-scripts/**"
  30. - "core/**"
  31. - "!core/deps/**"
  32. - "product-mini/**"
  33. - "samples/**"
  34. - "!samples/workload/**"
  35. - "tests/wamr-test-suites/**"
  36. - "wamr-compiler/**"
  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. # ref types enabled in wamrc by default, so we need to enable it for iwasm in AOT mode
  46. AOT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0 -DWAMR_BUILD_REF_TYPES=1"
  47. CLASSIC_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -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_JIT=0 -DWAMR_BUILD_LAZY_JIT=0 -DWAMR_BUILD_SIMD=0"
  49. FAST_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=1"
  50. LLVM_LAZY_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=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_JIT=1 -DWAMR_BUILD_LAZY_JIT=0"
  52. # For Spec Test
  53. DEFAULT_TEST_OPTIONS: "-s spec -x -p -b"
  54. SIMD_TEST_OPTIONS: "-s spec -x -p -b -S"
  55. XIP_TEST_OPTIONS: "-s spec -x -p -b -X"
  56. permissions:
  57. contents: read
  58. jobs:
  59. build_llvm_libraries:
  60. permissions:
  61. contents: read
  62. actions: write
  63. uses: ./.github/workflows/build_llvm_libraries.yml
  64. with:
  65. os: ubuntu-22.04
  66. arch: "X86"
  67. build_iwasm:
  68. runs-on: ${{ matrix.os }}
  69. strategy:
  70. matrix:
  71. make_options_run_mode: [
  72. # Running modes supported
  73. $AOT_BUILD_OPTIONS,
  74. $CLASSIC_INTERP_BUILD_OPTIONS,
  75. $FAST_INTERP_BUILD_OPTIONS,
  76. $FAST_JIT_BUILD_OPTIONS,
  77. # Running modes unsupported
  78. #$LLVM_LAZY_JIT_BUILD_OPTIONS,
  79. #$LLVM_EAGER_JIT_BUILD_OPTIONS,
  80. ]
  81. make_options_feature: [
  82. # Features
  83. "-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
  84. # doesn't support
  85. # "-DWAMR_BUILD_DEBUG_AOT=1",
  86. # "-DWAMR_BUILD_DEBUG_INTERP=1",
  87. "-DWAMR_BUILD_DUMP_CALL_STACK=1",
  88. "-DWAMR_BUILD_LIB_PTHREAD=1",
  89. "-DWAMR_BUILD_LIB_WASI_THREADS=1",
  90. "-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1",
  91. "-DWAMR_BUILD_MINI_LOADER=1",
  92. "-DWAMR_BUILD_MEMORY_PROFILING=1",
  93. "-DWAMR_BUILD_MULTI_MODULE=1",
  94. "-DWAMR_BUILD_PERF_PROFILING=1",
  95. "-DWAMR_BUILD_REF_TYPES=1",
  96. "-DWAMR_BUILD_EXTENDED_CONST_EXPR=1",
  97. # doesn't support
  98. "-DWAMR_BUILD_SIMD=0",
  99. "-DWAMR_BUILD_TAIL_CALL=1",
  100. "-DWAMR_DISABLE_HW_BOUND_CHECK=1",
  101. "-DWAMR_BUILD_SGX_IPFS=1",
  102. ]
  103. os: [ubuntu-22.04]
  104. platform: [linux-sgx]
  105. exclude:
  106. # incompatible mode and feature
  107. # MINI_LOADER only on INTERP mode
  108. - make_options_run_mode: $AOT_BUILD_OPTIONS
  109. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  110. steps:
  111. - name: checkout
  112. uses: actions/checkout@v5
  113. - name: install SGX SDK and necessary libraries
  114. uses: ./.github/actions/install-linux-sgx
  115. with:
  116. os: ${{ matrix.os }}
  117. - name: Build iwasm
  118. run: |
  119. mkdir build && cd build
  120. cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
  121. cmake --build . --config Release --parallel 4
  122. cd ../enclave-sample
  123. make
  124. working-directory: product-mini/platforms/${{ matrix.platform }}
  125. run_samples_file:
  126. needs: [build_iwasm, build_llvm_libraries]
  127. runs-on: ${{ matrix.os }}
  128. strategy:
  129. matrix:
  130. iwasm_make_options_run_mode: [
  131. # Running modes supported
  132. $AOT_BUILD_OPTIONS,
  133. $CLASSIC_INTERP_BUILD_OPTIONS,
  134. $FAST_INTERP_BUILD_OPTIONS,
  135. $FAST_JIT_BUILD_OPTIONS,
  136. # Running modes unsupported
  137. #$LLVM_LAZY_JIT_BUILD_OPTIONS,
  138. #$LLVM_EAGER_JIT_BUILD_OPTIONS,
  139. ]
  140. os: [ubuntu-22.04]
  141. iwasm_make_options_feature: [
  142. # Features to be tested: IPFS
  143. "-DWAMR_BUILD_SGX_IPFS=1",
  144. ]
  145. platform: [linux-sgx]
  146. include:
  147. - os: ubuntu-22.04
  148. llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }}
  149. steps:
  150. - name: checkout
  151. uses: actions/checkout@v5
  152. - name: install-wasi-sdk-wabt
  153. uses: ./.github/actions/install-wasi-sdk-wabt
  154. with:
  155. os: ${{ matrix.os }}
  156. - name: install SGX SDK and necessary libraries
  157. uses: ./.github/actions/install-linux-sgx
  158. with:
  159. os: ${{ matrix.os }}
  160. - name: Build iwasm for testing samples
  161. run: |
  162. mkdir build && cd build
  163. cmake .. ${{ matrix.iwasm_make_options_run_mode }} ${{ matrix.iwasm_make_options_feature }}
  164. cmake --build . --config Release --parallel 4
  165. cd ../enclave-sample
  166. make
  167. working-directory: product-mini/platforms/${{ matrix.platform }}
  168. - name: Get LLVM libraries
  169. if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
  170. id: retrieve_llvm_libs
  171. uses: actions/cache@v4
  172. with:
  173. path: |
  174. ./core/deps/llvm/build/bin
  175. ./core/deps/llvm/build/include
  176. ./core/deps/llvm/build/lib
  177. ./core/deps/llvm/build/libexec
  178. ./core/deps/llvm/build/share
  179. key: ${{ matrix.llvm_cache_key }}
  180. fail-on-cache-miss: true
  181. - name: Build wamrc only for testing samples in aot mode
  182. if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
  183. run: |
  184. cmake -S . -B build
  185. cmake --build build --config Release --parallel 4
  186. cp build/wamrc ../product-mini/platforms/${{ matrix.platform }}/enclave-sample
  187. working-directory: wamr-compiler
  188. - name: Build Sample [file]
  189. run: |
  190. cmake -S . -B build
  191. cmake --build build --config Debug --parallel 4
  192. cp build/wasm-app/file.wasm ../../product-mini/platforms/${{ matrix.platform }}/enclave-sample
  193. working-directory: samples/file
  194. - name: Test Sample [file] in non-aot mode
  195. if: matrix.iwasm_make_options_run_mode != '$AOT_BUILD_OPTIONS'
  196. run: |
  197. source /opt/intel/sgxsdk/environment
  198. ./iwasm --dir=. ./file.wasm
  199. working-directory: product-mini/platforms/${{ matrix.platform }}/enclave-sample
  200. - name: Test Sample [file] in aot mode
  201. if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
  202. run: |
  203. source /opt/intel/sgxsdk/environment
  204. ./wamrc -sgx -o ./file.aot ./file.wasm
  205. ./iwasm --dir=. ./file.aot
  206. working-directory: product-mini/platforms/${{ matrix.platform }}/enclave-sample
  207. spec_test_default:
  208. needs: [build_iwasm, build_llvm_libraries]
  209. runs-on: ${{ matrix.os }}
  210. strategy:
  211. matrix:
  212. #(workaround) disable "fast-interp" because of SIMDE
  213. running_mode: ["classic-interp", "aot", "fast-jit"]
  214. test_option:
  215. [$DEFAULT_TEST_OPTIONS, $SIMD_TEST_OPTIONS, $XIP_TEST_OPTIONS]
  216. os: [ubuntu-22.04]
  217. exclude:
  218. # classic-interp, fast-interp and fast-jit don't support simd
  219. - running_mode: "classic-interp"
  220. test_option: $SIMD_TEST_OPTIONS
  221. - running_mode: "fast-interp"
  222. test_option: $SIMD_TEST_OPTIONS
  223. - running_mode: "fast-jit"
  224. test_option: $SIMD_TEST_OPTIONS
  225. # classic-interp, fast-interp and fast jit don't support XIP
  226. - running_mode: "classic-interp"
  227. test_option: $XIP_TEST_OPTIONS
  228. - running_mode: "fast-interp"
  229. test_option: $XIP_TEST_OPTIONS
  230. - running_mode: "fast-jit"
  231. test_option: $XIP_TEST_OPTIONS
  232. include:
  233. - os: ubuntu-22.04
  234. llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }}
  235. steps:
  236. - name: checkout
  237. uses: actions/checkout@v5
  238. - name: Get LLVM libraries
  239. if: matrix.running_mode == 'aot'
  240. id: retrieve_llvm_libs
  241. uses: actions/cache@v4
  242. with:
  243. path: |
  244. ./core/deps/llvm/build/bin
  245. ./core/deps/llvm/build/include
  246. ./core/deps/llvm/build/lib
  247. ./core/deps/llvm/build/libexec
  248. ./core/deps/llvm/build/share
  249. key: ${{ matrix.llvm_cache_key }}
  250. - name: Quit if cache miss
  251. if: matrix.running_mode == 'aot' && steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
  252. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  253. - name: install SGX SDK and necessary libraries
  254. uses: ./.github/actions/install-linux-sgx
  255. with:
  256. os: ${{ matrix.os }}
  257. #workaround about a https://github.com/actions/runner-images/issues/6680#issuecomment-2640923706
  258. - name: Increase swapfile
  259. run: |
  260. sudo swapoff -a
  261. sudo fallocate -l 15G /swapfile
  262. sudo chmod 600 /swapfile
  263. sudo mkswap /swapfile
  264. sudo swapon /swapfile
  265. sudo swapon --show
  266. - name: run spec tests
  267. run: |
  268. source /opt/intel/sgxsdk/environment
  269. ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  270. working-directory: ./tests/wamr-test-suites