compilation_on_sgx.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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. - "wamr-sdk/**"
  22. # will be triggered on push events
  23. push:
  24. branches:
  25. - main
  26. - "dev/**"
  27. paths:
  28. - ".github/workflows/build_llvm_libraries.yml"
  29. - ".github/workflows/compilation_on_sgx.yml"
  30. - "build-scripts/**"
  31. - "core/**"
  32. - "!core/deps/**"
  33. - "product-mini/**"
  34. - "samples/**"
  35. - "!samples/workload/**"
  36. - "tests/wamr-test-suites/**"
  37. - "wamr-compiler/**"
  38. - "wamr-sdk/**"
  39. # allow to be triggered manually
  40. workflow_dispatch:
  41. # Cancel any in-flight jobs for the same PR/branch so there's only one active
  42. # at a time
  43. concurrency:
  44. group: ${{ github.workflow }}-${{ github.ref }}
  45. cancel-in-progress: true
  46. env:
  47. # ref types enabled in wamrc by default, so we need to enable it for iwasm in AOT mode
  48. 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"
  49. 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"
  50. 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"
  51. 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"
  52. 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"
  53. 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"
  54. jobs:
  55. build_llvm_libraries:
  56. uses: ./.github/workflows/build_llvm_libraries.yml
  57. with:
  58. os: "ubuntu-20.04"
  59. arch: "X86"
  60. build_iwasm:
  61. runs-on: ${{ matrix.os }}
  62. strategy:
  63. matrix:
  64. make_options_run_mode: [
  65. # Running modes supported
  66. $AOT_BUILD_OPTIONS,
  67. $CLASSIC_INTERP_BUILD_OPTIONS,
  68. $FAST_INTERP_BUILD_OPTIONS,
  69. $FAST_JIT_BUILD_OPTIONS,
  70. # Running modes unsupported
  71. #$LLVM_LAZY_JIT_BUILD_OPTIONS,
  72. #$LLVM_EAGER_JIT_BUILD_OPTIONS,
  73. ]
  74. make_options_feature: [
  75. # Features
  76. "-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
  77. # doesn't support
  78. # "-DWAMR_BUILD_DEBUG_AOT=1",
  79. # "-DWAMR_BUILD_DEBUG_INTERP=1",
  80. "-DWAMR_BUILD_DUMP_CALL_STACK=1",
  81. "-DWAMR_BUILD_LIB_PTHREAD=1",
  82. "-DWAMR_BUILD_LIB_WASI_THREADS=1",
  83. "-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1",
  84. "-DWAMR_BUILD_MINI_LOADER=1",
  85. "-DWAMR_BUILD_MEMORY_PROFILING=1",
  86. "-DWAMR_BUILD_MULTI_MODULE=1",
  87. "-DWAMR_BUILD_PERF_PROFILING=1",
  88. "-DWAMR_BUILD_REF_TYPES=1",
  89. # doesn't support
  90. # "-DWAMR_BUILD_SIMD=1",
  91. "-DWAMR_BUILD_TAIL_CALL=1",
  92. "-DWAMR_DISABLE_HW_BOUND_CHECK=1",
  93. "-DWAMR_BUILD_SGX_IPFS=1",
  94. ]
  95. os: [ubuntu-20.04]
  96. platform: [linux-sgx]
  97. exclude:
  98. # uncompatiable mode and feature
  99. # MINI_LOADER only on INTERP mode
  100. - make_options_run_mode: $AOT_BUILD_OPTIONS
  101. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  102. steps:
  103. - name: install SGX SDK and necessary libraries
  104. run: |
  105. mkdir -p /opt/intel
  106. cd /opt/intel
  107. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
  108. chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
  109. echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
  110. 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
  111. wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
  112. sudo apt update
  113. sudo apt install -y libsgx-launch libsgx-urts
  114. source /opt/intel/sgxsdk/environment
  115. - name: checkout
  116. uses: actions/checkout@v3
  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-20.04]
  141. wasi_sdk_release:
  142. [
  143. "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz",
  144. ]
  145. wabt_release:
  146. [
  147. "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz",
  148. ]
  149. iwasm_make_options_feature: [
  150. # Features to be tested: IPFS
  151. "-DWAMR_BUILD_SGX_IPFS=1",
  152. ]
  153. platform: [linux-sgx]
  154. include:
  155. - os: ubuntu-20.04
  156. llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }}
  157. steps:
  158. - name: checkout
  159. uses: actions/checkout@v3
  160. - name: download and install wasi-sdk
  161. run: |
  162. cd /opt
  163. sudo wget ${{ matrix.wasi_sdk_release }}
  164. sudo tar -xzf wasi-sdk-*.tar.gz
  165. sudo mv wasi-sdk-19.0 wasi-sdk
  166. - name: download and install wabt
  167. run: |
  168. cd /opt
  169. sudo wget ${{ matrix.wabt_release }}
  170. sudo tar -xzf wabt-1.0.31-*.tar.gz
  171. sudo mv wabt-1.0.31 wabt
  172. - name: build wasi-libc (needed for wasi-threads)
  173. run: |
  174. mkdir wasi-libc
  175. cd wasi-libc
  176. git init
  177. # "Fix a_store operation in atomic.h" commit on main branch
  178. git fetch https://github.com/WebAssembly/wasi-libc \
  179. 1dfe5c302d1c5ab621f7abf04620fae92700fd22
  180. git checkout FETCH_HEAD
  181. make \
  182. AR=/opt/wasi-sdk/bin/llvm-ar \
  183. NM=/opt/wasi-sdk/bin/llvm-nm \
  184. CC=/opt/wasi-sdk/bin/clang \
  185. THREAD_MODEL=posix
  186. working-directory: core/deps
  187. - name: install SGX SDK and necessary libraries
  188. run: |
  189. mkdir -p /opt/intel
  190. cd /opt/intel
  191. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
  192. chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
  193. echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
  194. 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
  195. wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
  196. sudo apt update
  197. sudo apt install -y libsgx-launch libsgx-urts
  198. - name: Build iwasm for testing samples
  199. run: |
  200. mkdir build && cd build
  201. cmake .. ${{ matrix.iwasm_make_options_run_mode }} ${{ matrix.iwasm_make_options_feature }}
  202. cmake --build . --config Release --parallel 4
  203. cd ../enclave-sample
  204. make
  205. working-directory: product-mini/platforms/${{ matrix.platform }}
  206. - name: Get LLVM libraries
  207. if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
  208. id: retrieve_llvm_libs
  209. uses: actions/cache@v3
  210. with:
  211. path: |
  212. ./core/deps/llvm/build/bin
  213. ./core/deps/llvm/build/include
  214. ./core/deps/llvm/build/lib
  215. ./core/deps/llvm/build/libexec
  216. ./core/deps/llvm/build/share
  217. key: ${{ matrix.llvm_cache_key }}
  218. fail-on-cache-miss: true
  219. - name: Build wamrc only for testing samples in aot mode
  220. if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
  221. run: |
  222. mkdir build && cd build
  223. cmake ..
  224. cmake --build . --config Release --parallel 4
  225. cp wamrc `pwd`/../../product-mini/platforms/${{ matrix.platform }}/enclave-sample
  226. working-directory: wamr-compiler
  227. - name: Build Sample [file]
  228. run: |
  229. cd samples/file
  230. mkdir build && cd build
  231. cmake ..
  232. cmake --build . --config Release --parallel 4
  233. cp wasm-app/file.wasm `pwd`/../../../product-mini/platforms/${{ matrix.platform }}/enclave-sample
  234. - name: Test Sample [file] in non-aot mode
  235. if: matrix.iwasm_make_options_run_mode != '$AOT_BUILD_OPTIONS'
  236. run: |
  237. source /opt/intel/sgxsdk/environment
  238. ./iwasm --dir=. file.wasm
  239. working-directory: product-mini/platforms/${{ matrix.platform }}/enclave-sample
  240. - name: Test Sample [file] in aot mode
  241. if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
  242. run: |
  243. source /opt/intel/sgxsdk/environment
  244. ./wamrc -sgx -o file.aot file.wasm
  245. ./iwasm --dir=. file.aot
  246. working-directory: product-mini/platforms/${{ matrix.platform }}/enclave-sample
  247. spec_test_default:
  248. needs: [build_iwasm, build_llvm_libraries]
  249. runs-on: ubuntu-20.04
  250. strategy:
  251. matrix:
  252. running_mode: ["classic-interp", "fast-interp", "aot", "fast-jit"]
  253. test_option: ["-x -p -s spec -b -P", "-x -p -s spec -S -b -P", "-x -p -s spec -X -b -P"]
  254. llvm_cache_key: ["${{ needs.build_llvm_libraries.outputs.cache_key }}"]
  255. exclude:
  256. # classic-interp, fast-interp and fast-jit don't support simd
  257. - running_mode: "classic-interp"
  258. test_option: "-x -p -s spec -S -b -P"
  259. - running_mode: "fast-interp"
  260. test_option: "-x -p -s spec -S -b -P"
  261. - running_mode: "fast-jit"
  262. test_option: "-x -p -s spec -S -b -P"
  263. # classic-interp, fast-interp and fast jit don't support XIP
  264. - running_mode: "classic-interp"
  265. test_option: "-x -p -s spec -X -b -P"
  266. - running_mode: "fast-interp"
  267. test_option: "-x -p -s spec -X -b -P"
  268. - running_mode: "fast-jit"
  269. test_option: "-x -p -s spec -X -b -P"
  270. steps:
  271. - name: checkout
  272. uses: actions/checkout@v3
  273. - name: Get LLVM libraries
  274. if: matrix.running_mode == 'aot'
  275. id: retrieve_llvm_libs
  276. uses: actions/cache@v3
  277. with:
  278. path: |
  279. ./core/deps/llvm/build/bin
  280. ./core/deps/llvm/build/include
  281. ./core/deps/llvm/build/lib
  282. ./core/deps/llvm/build/libexec
  283. ./core/deps/llvm/build/share
  284. key: ${{ matrix.llvm_cache_key }}
  285. - name: Quit if cache miss
  286. if: matrix.running_mode == 'aot' && steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
  287. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  288. - name: install SGX SDK and necessary libraries
  289. run: |
  290. mkdir -p /opt/intel
  291. cd /opt/intel
  292. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
  293. chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
  294. echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
  295. 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
  296. wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
  297. sudo apt update
  298. sudo apt install -y libsgx-launch libsgx-urts
  299. - name: run spec tests
  300. run: |
  301. source /opt/intel/sgxsdk/environment
  302. ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  303. working-directory: ./tests/wamr-test-suites