compilation_on_sgx.yml 11 KB

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