compilation_on_sgx.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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. # doesn't support
  97. "-DWAMR_BUILD_SIMD=0",
  98. "-DWAMR_BUILD_TAIL_CALL=1",
  99. "-DWAMR_DISABLE_HW_BOUND_CHECK=1",
  100. "-DWAMR_BUILD_SGX_IPFS=1",
  101. ]
  102. os: [ubuntu-22.04]
  103. platform: [linux-sgx]
  104. exclude:
  105. # incompatible mode and feature
  106. # MINI_LOADER only on INTERP mode
  107. - make_options_run_mode: $AOT_BUILD_OPTIONS
  108. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  109. steps:
  110. - name: checkout
  111. uses: actions/checkout@v4
  112. - name: install SGX SDK and necessary libraries
  113. uses: ./.github/actions/install-linux-sgx
  114. with:
  115. os: ${{ matrix.os }}
  116. - name: Build iwasm
  117. run: |
  118. mkdir build && cd build
  119. cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
  120. cmake --build . --config Release --parallel 4
  121. cd ../enclave-sample
  122. make
  123. working-directory: product-mini/platforms/${{ matrix.platform }}
  124. run_samples_file:
  125. needs: [build_iwasm, build_llvm_libraries]
  126. runs-on: ${{ matrix.os }}
  127. strategy:
  128. matrix:
  129. iwasm_make_options_run_mode: [
  130. # Running modes supported
  131. $AOT_BUILD_OPTIONS,
  132. $CLASSIC_INTERP_BUILD_OPTIONS,
  133. $FAST_INTERP_BUILD_OPTIONS,
  134. $FAST_JIT_BUILD_OPTIONS,
  135. # Running modes unsupported
  136. #$LLVM_LAZY_JIT_BUILD_OPTIONS,
  137. #$LLVM_EAGER_JIT_BUILD_OPTIONS,
  138. ]
  139. os: [ubuntu-22.04]
  140. iwasm_make_options_feature: [
  141. # Features to be tested: IPFS
  142. "-DWAMR_BUILD_SGX_IPFS=1",
  143. ]
  144. platform: [linux-sgx]
  145. include:
  146. - os: ubuntu-22.04
  147. llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }}
  148. steps:
  149. - name: checkout
  150. uses: actions/checkout@v4
  151. - name: install-wasi-sdk-wabt
  152. uses: ./.github/actions/install-wasi-sdk-wabt
  153. with:
  154. os: ${{ matrix.os }}
  155. - name: install SGX SDK and necessary libraries
  156. uses: ./.github/actions/install-linux-sgx
  157. with:
  158. os: ${{ matrix.os }}
  159. - name: Build iwasm for testing samples
  160. run: |
  161. mkdir build && cd build
  162. cmake .. ${{ matrix.iwasm_make_options_run_mode }} ${{ matrix.iwasm_make_options_feature }}
  163. cmake --build . --config Release --parallel 4
  164. cd ../enclave-sample
  165. make
  166. working-directory: product-mini/platforms/${{ matrix.platform }}
  167. - name: Get LLVM libraries
  168. if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
  169. id: retrieve_llvm_libs
  170. uses: actions/cache@v4
  171. with:
  172. path: |
  173. ./core/deps/llvm/build/bin
  174. ./core/deps/llvm/build/include
  175. ./core/deps/llvm/build/lib
  176. ./core/deps/llvm/build/libexec
  177. ./core/deps/llvm/build/share
  178. key: ${{ matrix.llvm_cache_key }}
  179. fail-on-cache-miss: true
  180. - name: Build wamrc only for testing samples in aot mode
  181. if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
  182. run: |
  183. cmake -S . -B build
  184. cmake --build build --config Release --parallel 4
  185. cp build/wamrc ../product-mini/platforms/${{ matrix.platform }}/enclave-sample
  186. working-directory: wamr-compiler
  187. - name: Build Sample [file]
  188. run: |
  189. cmake -S . -B build
  190. cmake --build build --config Debug --parallel 4
  191. cp build/wasm-app/file.wasm ../../product-mini/platforms/${{ matrix.platform }}/enclave-sample
  192. working-directory: samples/file
  193. - name: Test Sample [file] in non-aot mode
  194. if: matrix.iwasm_make_options_run_mode != '$AOT_BUILD_OPTIONS'
  195. run: |
  196. source /opt/intel/sgxsdk/environment
  197. ./iwasm --dir=. ./file.wasm
  198. working-directory: product-mini/platforms/${{ matrix.platform }}/enclave-sample
  199. - name: Test Sample [file] in aot mode
  200. if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
  201. run: |
  202. source /opt/intel/sgxsdk/environment
  203. ./wamrc -sgx -o ./file.aot ./file.wasm
  204. ./iwasm --dir=. ./file.aot
  205. working-directory: product-mini/platforms/${{ matrix.platform }}/enclave-sample
  206. spec_test_default:
  207. needs: [build_iwasm, build_llvm_libraries]
  208. runs-on: ${{ matrix.os }}
  209. strategy:
  210. matrix:
  211. #(workaround) disable "fast-interp" because of SIMDE
  212. running_mode: ["classic-interp", "aot", "fast-jit"]
  213. test_option:
  214. [$DEFAULT_TEST_OPTIONS, $SIMD_TEST_OPTIONS, $XIP_TEST_OPTIONS]
  215. os: [ubuntu-22.04]
  216. exclude:
  217. # classic-interp, fast-interp and fast-jit don't support simd
  218. - running_mode: "classic-interp"
  219. test_option: $SIMD_TEST_OPTIONS
  220. - running_mode: "fast-interp"
  221. test_option: $SIMD_TEST_OPTIONS
  222. - running_mode: "fast-jit"
  223. test_option: $SIMD_TEST_OPTIONS
  224. # classic-interp, fast-interp and fast jit don't support XIP
  225. - running_mode: "classic-interp"
  226. test_option: $XIP_TEST_OPTIONS
  227. - running_mode: "fast-interp"
  228. test_option: $XIP_TEST_OPTIONS
  229. - running_mode: "fast-jit"
  230. test_option: $XIP_TEST_OPTIONS
  231. include:
  232. - os: ubuntu-22.04
  233. llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }}
  234. steps:
  235. - name: checkout
  236. uses: actions/checkout@v4
  237. - name: Get LLVM libraries
  238. if: matrix.running_mode == 'aot'
  239. id: retrieve_llvm_libs
  240. uses: actions/cache@v4
  241. with:
  242. path: |
  243. ./core/deps/llvm/build/bin
  244. ./core/deps/llvm/build/include
  245. ./core/deps/llvm/build/lib
  246. ./core/deps/llvm/build/libexec
  247. ./core/deps/llvm/build/share
  248. key: ${{ matrix.llvm_cache_key }}
  249. - name: Quit if cache miss
  250. if: matrix.running_mode == 'aot' && steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
  251. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  252. - name: install SGX SDK and necessary libraries
  253. uses: ./.github/actions/install-linux-sgx
  254. with:
  255. os: ${{ matrix.os }}
  256. #workaround about a https://github.com/actions/runner-images/issues/6680#issuecomment-2640923706
  257. - name: Increase swapfile
  258. run: |
  259. sudo swapoff -a
  260. sudo fallocate -l 15G /swapfile
  261. sudo chmod 600 /swapfile
  262. sudo mkswap /swapfile
  263. sudo swapon /swapfile
  264. sudo swapon --show
  265. - name: run spec tests
  266. run: |
  267. set +e
  268. source /opt/intel/sgxsdk/environment
  269. attempts=0
  270. max_attempts=3
  271. while [ $attempts -lt $max_attempts ]; do
  272. ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  273. exitcode="$?"
  274. if [ $exitcode -eq 0 ]; then
  275. echo "Spec test passed"
  276. exit 0
  277. elif [ $exitcode -ne 143 ]; then
  278. echo "Spec test failed with error code $exitcode"
  279. exit 1
  280. fi
  281. echo "$exitcode is a known GitHub-hosted runner issue"
  282. echo "::notice::Re-running the spec test due to error code 143"
  283. attempts=$((attempts + 1))
  284. done
  285. echo "::notice::Report an error with code 143 in SGX CI after $max_attempts attempts"
  286. exit 143
  287. working-directory: ./tests/wamr-test-suites