compilation_on_sgx.yml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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. # MINI_LOADER only on INTERP mode
  99. - make_options_run_mode: $AOT_BUILD_OPTIONS
  100. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  101. steps:
  102. - name: install SGX SDK and necessary libraries
  103. run: |
  104. mkdir -p /opt/intel
  105. cd /opt/intel
  106. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
  107. chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
  108. echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
  109. 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
  110. wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
  111. sudo apt update
  112. sudo apt install -y libsgx-launch libsgx-urts
  113. source /opt/intel/sgxsdk/environment
  114. - name: checkout
  115. uses: actions/checkout@v4
  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-20.04]
  140. wasi_sdk_release:
  141. [
  142. "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz",
  143. ]
  144. wabt_release:
  145. [
  146. "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz",
  147. ]
  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-20.04
  155. llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }}
  156. steps:
  157. - name: checkout
  158. uses: actions/checkout@v4
  159. - name: download and install wasi-sdk
  160. run: |
  161. cd /opt
  162. sudo wget ${{ matrix.wasi_sdk_release }}
  163. sudo tar -xzf wasi-sdk-*.tar.gz
  164. sudo mv wasi-sdk-19.0 wasi-sdk
  165. - name: download and install wabt
  166. run: |
  167. cd /opt
  168. sudo wget ${{ matrix.wabt_release }}
  169. sudo tar -xzf wabt-1.0.31-*.tar.gz
  170. sudo mv wabt-1.0.31 wabt
  171. - name: build wasi-libc (needed for wasi-threads)
  172. run: |
  173. mkdir wasi-libc
  174. cd wasi-libc
  175. git init
  176. # "Fix a_store operation in atomic.h" commit on main branch
  177. git fetch https://github.com/WebAssembly/wasi-libc \
  178. 1dfe5c302d1c5ab621f7abf04620fae92700fd22
  179. git checkout FETCH_HEAD
  180. make \
  181. AR=/opt/wasi-sdk/bin/llvm-ar \
  182. NM=/opt/wasi-sdk/bin/llvm-nm \
  183. CC=/opt/wasi-sdk/bin/clang \
  184. THREAD_MODEL=posix
  185. working-directory: core/deps
  186. - name: install SGX SDK and necessary libraries
  187. run: |
  188. mkdir -p /opt/intel
  189. cd /opt/intel
  190. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
  191. chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
  192. echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
  193. 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
  194. wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
  195. sudo apt update
  196. sudo apt install -y libsgx-launch libsgx-urts
  197. - name: Build iwasm for testing samples
  198. run: |
  199. mkdir build && cd build
  200. cmake .. ${{ matrix.iwasm_make_options_run_mode }} ${{ matrix.iwasm_make_options_feature }}
  201. cmake --build . --config Release --parallel 4
  202. cd ../enclave-sample
  203. make
  204. working-directory: product-mini/platforms/${{ matrix.platform }}
  205. - name: Get LLVM libraries
  206. if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
  207. id: retrieve_llvm_libs
  208. uses: actions/cache@v4
  209. with:
  210. path: |
  211. ./core/deps/llvm/build/bin
  212. ./core/deps/llvm/build/include
  213. ./core/deps/llvm/build/lib
  214. ./core/deps/llvm/build/libexec
  215. ./core/deps/llvm/build/share
  216. key: ${{ matrix.llvm_cache_key }}
  217. fail-on-cache-miss: true
  218. - name: Build wamrc only for testing samples in aot mode
  219. if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
  220. run: |
  221. mkdir build && cd build
  222. cmake ..
  223. cmake --build . --config Release --parallel 4
  224. cp wamrc `pwd`/../../product-mini/platforms/${{ matrix.platform }}/enclave-sample
  225. working-directory: wamr-compiler
  226. - name: Build Sample [file]
  227. run: |
  228. cd samples/file
  229. mkdir build && cd build
  230. cmake ..
  231. cmake --build . --config Debug --parallel 4
  232. cp wasm-app/file.wasm `pwd`/../../../product-mini/platforms/${{ matrix.platform }}/enclave-sample
  233. - name: Test Sample [file] in non-aot mode
  234. if: matrix.iwasm_make_options_run_mode != '$AOT_BUILD_OPTIONS'
  235. run: |
  236. source /opt/intel/sgxsdk/environment
  237. ./iwasm --dir=. file.wasm
  238. working-directory: product-mini/platforms/${{ matrix.platform }}/enclave-sample
  239. - name: Test Sample [file] in aot mode
  240. if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
  241. run: |
  242. source /opt/intel/sgxsdk/environment
  243. ./wamrc -sgx -o file.aot file.wasm
  244. ./iwasm --dir=. file.aot
  245. working-directory: product-mini/platforms/${{ matrix.platform }}/enclave-sample
  246. spec_test_default:
  247. needs: [build_iwasm, build_llvm_libraries]
  248. runs-on: ubuntu-20.04
  249. strategy:
  250. matrix:
  251. running_mode: ["classic-interp", "fast-interp", "aot", "fast-jit"]
  252. test_option: ["-x -p -s spec -b -P", "-x -p -s spec -S -b -P", "-x -p -s spec -X -b -P"]
  253. llvm_cache_key: ["${{ needs.build_llvm_libraries.outputs.cache_key }}"]
  254. exclude:
  255. # classic-interp, fast-interp and fast-jit don't support simd
  256. - running_mode: "classic-interp"
  257. test_option: "-x -p -s spec -S -b -P"
  258. - running_mode: "fast-interp"
  259. test_option: "-x -p -s spec -S -b -P"
  260. - running_mode: "fast-jit"
  261. test_option: "-x -p -s spec -S -b -P"
  262. # classic-interp, fast-interp and fast jit don't support XIP
  263. - running_mode: "classic-interp"
  264. test_option: "-x -p -s spec -X -b -P"
  265. - running_mode: "fast-interp"
  266. test_option: "-x -p -s spec -X -b -P"
  267. - running_mode: "fast-jit"
  268. test_option: "-x -p -s spec -X -b -P"
  269. steps:
  270. - name: checkout
  271. uses: actions/checkout@v4
  272. - name: Get LLVM libraries
  273. if: matrix.running_mode == 'aot'
  274. id: retrieve_llvm_libs
  275. uses: actions/cache@v4
  276. with:
  277. path: |
  278. ./core/deps/llvm/build/bin
  279. ./core/deps/llvm/build/include
  280. ./core/deps/llvm/build/lib
  281. ./core/deps/llvm/build/libexec
  282. ./core/deps/llvm/build/share
  283. key: ${{ matrix.llvm_cache_key }}
  284. - name: Quit if cache miss
  285. if: matrix.running_mode == 'aot' && steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
  286. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  287. - name: install SGX SDK and necessary libraries
  288. run: |
  289. mkdir -p /opt/intel
  290. cd /opt/intel
  291. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
  292. chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
  293. echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
  294. 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
  295. wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
  296. sudo apt update
  297. sudo apt install -y libsgx-launch libsgx-urts
  298. - name: run spec tests
  299. run: |
  300. source /opt/intel/sgxsdk/environment
  301. ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  302. working-directory: ./tests/wamr-test-suites