compilation_on_sgx.yml 12 KB

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