compilation_on_sgx.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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"
  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. permissions:
  53. contents: read
  54. jobs:
  55. build_llvm_libraries:
  56. permissions:
  57. contents: read
  58. actions: write
  59. uses: ./.github/workflows/build_llvm_libraries.yml
  60. with:
  61. os: "ubuntu-20.04"
  62. arch: "X86"
  63. build_iwasm:
  64. runs-on: ${{ matrix.os }}
  65. strategy:
  66. matrix:
  67. make_options_run_mode: [
  68. # Running modes supported
  69. $AOT_BUILD_OPTIONS,
  70. $CLASSIC_INTERP_BUILD_OPTIONS,
  71. $FAST_INTERP_BUILD_OPTIONS,
  72. $FAST_JIT_BUILD_OPTIONS,
  73. # Running modes unsupported
  74. #$LLVM_LAZY_JIT_BUILD_OPTIONS,
  75. #$LLVM_EAGER_JIT_BUILD_OPTIONS,
  76. ]
  77. make_options_feature: [
  78. # Features
  79. "-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
  80. # doesn't support
  81. # "-DWAMR_BUILD_DEBUG_AOT=1",
  82. # "-DWAMR_BUILD_DEBUG_INTERP=1",
  83. "-DWAMR_BUILD_DUMP_CALL_STACK=1",
  84. "-DWAMR_BUILD_LIB_PTHREAD=1",
  85. "-DWAMR_BUILD_LIB_WASI_THREADS=1",
  86. "-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1",
  87. "-DWAMR_BUILD_MINI_LOADER=1",
  88. "-DWAMR_BUILD_MEMORY_PROFILING=1",
  89. "-DWAMR_BUILD_MULTI_MODULE=1",
  90. "-DWAMR_BUILD_PERF_PROFILING=1",
  91. "-DWAMR_BUILD_REF_TYPES=1",
  92. # doesn't support
  93. # "-DWAMR_BUILD_SIMD=1",
  94. "-DWAMR_BUILD_TAIL_CALL=1",
  95. "-DWAMR_DISABLE_HW_BOUND_CHECK=1",
  96. "-DWAMR_BUILD_SGX_IPFS=1",
  97. ]
  98. os: [ubuntu-20.04]
  99. platform: [linux-sgx]
  100. exclude:
  101. # incompatible mode and feature
  102. # MINI_LOADER only on INTERP mode
  103. - make_options_run_mode: $AOT_BUILD_OPTIONS
  104. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  105. steps:
  106. - name: install SGX SDK and necessary libraries
  107. run: |
  108. mkdir -p /opt/intel
  109. cd /opt/intel
  110. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
  111. chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
  112. echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
  113. echo 'deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu focal main' | sudo tee /etc/apt/sources.list.d/intel-sgx.list
  114. wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
  115. sudo apt update
  116. sudo apt install -y libsgx-launch libsgx-urts
  117. source /opt/intel/sgxsdk/environment
  118. - name: checkout
  119. uses: actions/checkout@v4
  120. - name: Build iwasm
  121. run: |
  122. mkdir build && cd build
  123. cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
  124. cmake --build . --config Release --parallel 4
  125. cd ../enclave-sample
  126. make
  127. working-directory: product-mini/platforms/${{ matrix.platform }}
  128. run_samples_file:
  129. needs: [build_iwasm, build_llvm_libraries]
  130. runs-on: ${{ matrix.os }}
  131. strategy:
  132. matrix:
  133. iwasm_make_options_run_mode: [
  134. # Running modes supported
  135. $AOT_BUILD_OPTIONS,
  136. $CLASSIC_INTERP_BUILD_OPTIONS,
  137. $FAST_INTERP_BUILD_OPTIONS,
  138. $FAST_JIT_BUILD_OPTIONS,
  139. # Running modes unsupported
  140. #$LLVM_LAZY_JIT_BUILD_OPTIONS,
  141. #$LLVM_EAGER_JIT_BUILD_OPTIONS,
  142. ]
  143. os: [ubuntu-20.04]
  144. wasi_sdk_release:
  145. [
  146. "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz",
  147. ]
  148. wabt_release:
  149. [
  150. "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz",
  151. ]
  152. iwasm_make_options_feature: [
  153. # Features to be tested: IPFS
  154. "-DWAMR_BUILD_SGX_IPFS=1",
  155. ]
  156. platform: [linux-sgx]
  157. include:
  158. - os: ubuntu-20.04
  159. llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }}
  160. steps:
  161. - name: checkout
  162. uses: actions/checkout@v4
  163. - name: download and install wasi-sdk
  164. run: |
  165. cd /opt
  166. sudo wget ${{ matrix.wasi_sdk_release }}
  167. sudo tar -xzf wasi-sdk-*.tar.gz
  168. sudo mv wasi-sdk-19.0 wasi-sdk
  169. - name: download and install wabt
  170. run: |
  171. cd /opt
  172. sudo wget ${{ matrix.wabt_release }}
  173. sudo tar -xzf wabt-1.0.31-*.tar.gz
  174. sudo mv wabt-1.0.31 wabt
  175. - name: build wasi-libc (needed for wasi-threads)
  176. run: |
  177. mkdir wasi-libc
  178. cd wasi-libc
  179. git init
  180. # "Fix a_store operation in atomic.h" commit on main branch
  181. git fetch https://github.com/WebAssembly/wasi-libc \
  182. 1dfe5c302d1c5ab621f7abf04620fae92700fd22
  183. git checkout FETCH_HEAD
  184. make \
  185. AR=/opt/wasi-sdk/bin/llvm-ar \
  186. NM=/opt/wasi-sdk/bin/llvm-nm \
  187. CC=/opt/wasi-sdk/bin/clang \
  188. THREAD_MODEL=posix
  189. working-directory: core/deps
  190. - name: install SGX SDK and necessary libraries
  191. run: |
  192. mkdir -p /opt/intel
  193. cd /opt/intel
  194. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
  195. chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
  196. echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
  197. echo 'deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu focal main' | sudo tee /etc/apt/sources.list.d/intel-sgx.list
  198. wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
  199. sudo apt update
  200. sudo apt install -y libsgx-launch libsgx-urts
  201. - name: Build iwasm for testing samples
  202. run: |
  203. mkdir build && cd build
  204. cmake .. ${{ matrix.iwasm_make_options_run_mode }} ${{ matrix.iwasm_make_options_feature }}
  205. cmake --build . --config Release --parallel 4
  206. cd ../enclave-sample
  207. make
  208. working-directory: product-mini/platforms/${{ matrix.platform }}
  209. - name: Get LLVM libraries
  210. if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
  211. id: retrieve_llvm_libs
  212. uses: actions/cache@v4
  213. with:
  214. path: |
  215. ./core/deps/llvm/build/bin
  216. ./core/deps/llvm/build/include
  217. ./core/deps/llvm/build/lib
  218. ./core/deps/llvm/build/libexec
  219. ./core/deps/llvm/build/share
  220. key: ${{ matrix.llvm_cache_key }}
  221. fail-on-cache-miss: true
  222. - name: Build wamrc only for testing samples in aot mode
  223. if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
  224. run: |
  225. mkdir build && cd build
  226. cmake ..
  227. cmake --build . --config Release --parallel 4
  228. cp wamrc `pwd`/../../product-mini/platforms/${{ matrix.platform }}/enclave-sample
  229. working-directory: wamr-compiler
  230. - name: Build Sample [file]
  231. run: |
  232. cd samples/file
  233. mkdir build && cd build
  234. cmake ..
  235. cmake --build . --config Debug --parallel 4
  236. cp wasm-app/file.wasm `pwd`/../../../product-mini/platforms/${{ matrix.platform }}/enclave-sample
  237. - name: Test Sample [file] in non-aot mode
  238. if: matrix.iwasm_make_options_run_mode != '$AOT_BUILD_OPTIONS'
  239. run: |
  240. source /opt/intel/sgxsdk/environment
  241. ./iwasm --dir=. file.wasm
  242. working-directory: product-mini/platforms/${{ matrix.platform }}/enclave-sample
  243. - name: Test Sample [file] in aot mode
  244. if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
  245. run: |
  246. source /opt/intel/sgxsdk/environment
  247. ./wamrc -sgx -o file.aot file.wasm
  248. ./iwasm --dir=. file.aot
  249. working-directory: product-mini/platforms/${{ matrix.platform }}/enclave-sample
  250. spec_test_default:
  251. needs: [build_iwasm, build_llvm_libraries]
  252. runs-on: ubuntu-20.04
  253. strategy:
  254. matrix:
  255. running_mode: ["classic-interp", "fast-interp", "aot", "fast-jit"]
  256. # FIXME: use binary release(adding -b) instead of building from source after upgrading to 22.04
  257. test_option: ["-x -p -s spec -P", "-x -p -s spec -S -P", "-x -p -s spec -X -P"]
  258. llvm_cache_key: ["${{ needs.build_llvm_libraries.outputs.cache_key }}"]
  259. exclude:
  260. # classic-interp, fast-interp and fast-jit don't support simd
  261. - running_mode: "classic-interp"
  262. test_option: "-x -p -s spec -S -P"
  263. - running_mode: "fast-interp"
  264. test_option: "-x -p -s spec -S -P"
  265. - running_mode: "fast-jit"
  266. test_option: "-x -p -s spec -S -P"
  267. # classic-interp, fast-interp and fast jit don't support XIP
  268. - running_mode: "classic-interp"
  269. test_option: "-x -p -s spec -X -P"
  270. - running_mode: "fast-interp"
  271. test_option: "-x -p -s spec -X -P"
  272. - running_mode: "fast-jit"
  273. test_option: "-x -p -s spec -X -P"
  274. steps:
  275. - name: checkout
  276. uses: actions/checkout@v4
  277. - name: Get LLVM libraries
  278. if: matrix.running_mode == 'aot'
  279. id: retrieve_llvm_libs
  280. uses: actions/cache@v4
  281. with:
  282. path: |
  283. ./core/deps/llvm/build/bin
  284. ./core/deps/llvm/build/include
  285. ./core/deps/llvm/build/lib
  286. ./core/deps/llvm/build/libexec
  287. ./core/deps/llvm/build/share
  288. key: ${{ matrix.llvm_cache_key }}
  289. - name: Quit if cache miss
  290. if: matrix.running_mode == 'aot' && steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
  291. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  292. - name: install SGX SDK and necessary libraries
  293. run: |
  294. mkdir -p /opt/intel
  295. cd /opt/intel
  296. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
  297. chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
  298. echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
  299. echo 'deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu focal main' | sudo tee /etc/apt/sources.list.d/intel-sgx.list
  300. wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
  301. sudo apt update
  302. sudo apt install -y libsgx-launch libsgx-urts
  303. - name: install for wabt compilation
  304. run: sudo apt update && sudo apt install -y ninja-build
  305. - name: run spec tests
  306. run: |
  307. source /opt/intel/sgxsdk/environment
  308. ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  309. working-directory: ./tests/wamr-test-suites