compilation_on_sgx.yml 13 KB

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