compilation_on_sgx.yml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  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/**"
  12. - "build-scripts/**"
  13. - "core/**"
  14. - "!core/deps/**"
  15. - "product-mini/**"
  16. - "samples/**"
  17. - "!samples/workload/**"
  18. - "tests/wamr-test-suites/**"
  19. - "wamr-compiler/**"
  20. - "wamr-sdk/**"
  21. # will be triggered on push events
  22. push:
  23. branches:
  24. - main
  25. - "dev/**"
  26. paths:
  27. - ".github/**"
  28. - "build-scripts/**"
  29. - "core/**"
  30. - "!core/deps/**"
  31. - "product-mini/**"
  32. - "samples/**"
  33. - "!samples/workload/**"
  34. - "tests/wamr-test-suites/**"
  35. - "wamr-compiler/**"
  36. - "wamr-sdk/**"
  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. 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"
  46. 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"
  47. 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"
  48. 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"
  49. 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"
  50. jobs:
  51. build_llvm_libraries:
  52. uses: ./.github/workflows/build_llvm_libraries.yml
  53. with:
  54. os: "ubuntu-20.04"
  55. arch: "X86"
  56. build_iwasm:
  57. runs-on: ${{ matrix.os }}
  58. strategy:
  59. matrix:
  60. make_options_run_mode: [
  61. # Running modes supported
  62. $AOT_BUILD_OPTIONS,
  63. $CLASSIC_INTERP_BUILD_OPTIONS,
  64. $FAST_INTERP_BUILD_OPTIONS,
  65. # Running modes unsupported
  66. #$LLVM_LAZY_JIT_BUILD_OPTIONS,
  67. #$LLVM_EAGER_JIT_BUILD_OPTIONS,
  68. ]
  69. make_options_feature: [
  70. # Features
  71. "-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
  72. # doesn't support
  73. # "-DWAMR_BUILD_DEBUG_AOT=1",
  74. # "-DWAMR_BUILD_DEBUG_INTERP=1",
  75. "-DWAMR_BUILD_DUMP_CALL_STACK=1",
  76. "-DWAMR_BUILD_LIB_PTHREAD=1",
  77. "-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1",
  78. "-DWAMR_BUILD_MINI_LOADER=1",
  79. "-DWAMR_BUILD_MEMORY_PROFILING=1",
  80. "-DWAMR_BUILD_MULTI_MODULE=1",
  81. "-DWAMR_BUILD_PERF_PROFILING=1",
  82. "-DWAMR_BUILD_REF_TYPES=1",
  83. # doesn't support
  84. # "-DWAMR_BUILD_SIMD=1",
  85. "-DWAMR_BUILD_TAIL_CALL=1",
  86. "-DWAMR_DISABLE_HW_BOUND_CHECK=1",
  87. "-DWAMR_BUILD_SGX_IPFS=1",
  88. ]
  89. os: [ubuntu-20.04]
  90. platform: [linux-sgx]
  91. exclude:
  92. # uncompatiable mode and feature
  93. # MULTI_MODULE only on INTERP mode
  94. - make_options_run_mode: $AOT_BUILD_OPTIONS
  95. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  96. # MINI_LOADER only on INTERP mode
  97. - make_options_run_mode: $AOT_BUILD_OPTIONS
  98. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  99. steps:
  100. - name: install SGX SDK and necessary libraries
  101. run: |
  102. mkdir -p /opt/intel
  103. cd /opt/intel
  104. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
  105. chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
  106. echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
  107. 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
  108. wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
  109. sudo apt update
  110. sudo apt install -y libsgx-launch libsgx-urts
  111. source /opt/intel/sgxsdk/environment
  112. - name: checkout
  113. uses: actions/checkout@v3
  114. - name: Build iwasm
  115. run: |
  116. mkdir build && cd build
  117. cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
  118. cmake --build . --config Release --parallel 4
  119. working-directory: product-mini/platforms/${{ matrix.platform }}
  120. build_wamrc:
  121. needs: [build_llvm_libraries]
  122. runs-on: ${{ matrix.os }}
  123. strategy:
  124. matrix:
  125. include:
  126. - os: ubuntu-20.04
  127. llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }}
  128. steps:
  129. - name: install SGX SDK and necessary libraries
  130. run: |
  131. mkdir -p /opt/intel
  132. cd /opt/intel
  133. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
  134. chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
  135. echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
  136. 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
  137. wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
  138. sudo apt update
  139. sudo apt install -y libsgx-launch libsgx-urts
  140. source /opt/intel/sgxsdk/environment
  141. - name: checkout
  142. uses: actions/checkout@v3
  143. - name: Get LLVM libraries
  144. id: retrieve_llvm_libs
  145. uses: actions/cache@v3
  146. with:
  147. path: |
  148. ./core/deps/llvm/build/bin
  149. ./core/deps/llvm/build/include
  150. ./core/deps/llvm/build/lib
  151. ./core/deps/llvm/build/libexec
  152. ./core/deps/llvm/build/share
  153. key: ${{ matrix.llvm_cache_key }}
  154. - name: Quit if cache miss
  155. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
  156. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  157. - name: Build wamrc
  158. run: |
  159. mkdir build && cd build
  160. cmake ..
  161. cmake --build . --config Release --parallel 4
  162. working-directory: wamr-compiler
  163. build_samples_wasm_c_api:
  164. needs: [build_iwasm]
  165. runs-on: ${{ matrix.os }}
  166. strategy:
  167. matrix:
  168. make_options: [
  169. # Running modes supported
  170. $CLASSIC_INTERP_BUILD_OPTIONS,
  171. $FAST_INTERP_BUILD_OPTIONS,
  172. # Running modes unsupported
  173. #$LLVM_EAGER_JIT_BUILD_OPTIONS,
  174. #$LLVM_LAZY_JIT_BUILD_OPTIONS,
  175. #$AOT_BUILD_OPTIONS,
  176. ]
  177. os: [ubuntu-20.04]
  178. wasi_sdk_release:
  179. [
  180. "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz",
  181. ]
  182. wabt_release:
  183. [
  184. "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz",
  185. ]
  186. steps:
  187. - name: checkout
  188. uses: actions/checkout@v3
  189. - name: download and install wabt
  190. run: |
  191. cd /opt
  192. sudo wget ${{ matrix.wabt_release }}
  193. sudo tar -xzf wabt-1.0.31-*.tar.gz
  194. sudo mv wabt-1.0.31 wabt
  195. - name: install SGX SDK and necessary libraries
  196. run: |
  197. mkdir -p /opt/intel
  198. cd /opt/intel
  199. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
  200. chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
  201. echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
  202. 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
  203. wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
  204. sudo apt update
  205. sudo apt install -y libsgx-launch libsgx-urts
  206. source /opt/intel/sgxsdk/environment
  207. - name: Build Sample [wasm-c-api]
  208. run: |
  209. cmake -S . -B build ${{ matrix.make_options }}
  210. cmake --build build --config Release --parallel 4
  211. ctest --test-dir build
  212. working-directory: samples/wasm-c-api
  213. build_samples_others:
  214. needs: [build_iwasm]
  215. runs-on: ${{ matrix.os }}
  216. strategy:
  217. matrix:
  218. os: [ubuntu-20.04]
  219. wasi_sdk_release:
  220. [
  221. "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz",
  222. ]
  223. wabt_release:
  224. [
  225. "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz",
  226. ]
  227. steps:
  228. - name: checkout
  229. uses: actions/checkout@v3
  230. - name: download and install wasi-sdk
  231. run: |
  232. cd /opt
  233. sudo wget ${{ matrix.wasi_sdk_release }}
  234. sudo tar -xzf wasi-sdk-*.tar.gz
  235. sudo mv wasi-sdk-19.0 wasi-sdk
  236. - name: download and install wabt
  237. run: |
  238. cd /opt
  239. sudo wget ${{ matrix.wabt_release }}
  240. sudo tar -xzf wabt-1.0.31-*.tar.gz
  241. sudo mv wabt-1.0.31 wabt
  242. - name: build wasi-libc (needed for wasi-threads)
  243. run: |
  244. mkdir wasi-libc
  245. cd wasi-libc
  246. git init
  247. # "Fix a_store operation in atomic.h" commit on main branch
  248. git fetch https://github.com/WebAssembly/wasi-libc \
  249. 1dfe5c302d1c5ab621f7abf04620fae92700fd22
  250. git checkout FETCH_HEAD
  251. make \
  252. AR=/opt/wasi-sdk/bin/llvm-ar \
  253. NM=/opt/wasi-sdk/bin/llvm-nm \
  254. CC=/opt/wasi-sdk/bin/clang \
  255. THREAD_MODEL=posix
  256. working-directory: core/deps
  257. - name: install SGX SDK and necessary libraries
  258. run: |
  259. mkdir -p /opt/intel
  260. cd /opt/intel
  261. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
  262. chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
  263. echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
  264. 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
  265. wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
  266. sudo apt update
  267. sudo apt install -y libsgx-launch libsgx-urts
  268. source /opt/intel/sgxsdk/environment
  269. - name: Build Sample [basic]
  270. run: |
  271. cd samples/basic
  272. ./build.sh
  273. ./run.sh
  274. - name: Build Sample [file]
  275. run: |
  276. cd samples/file
  277. mkdir build && cd build
  278. cmake ..
  279. cmake --build . --config Release --parallel 4
  280. ./src/iwasm -f wasm-app/file.wasm -d .
  281. - name: Build Sample [multi-thread]
  282. run: |
  283. cd samples/multi-thread
  284. mkdir build && cd build
  285. cmake ..
  286. cmake --build . --config Release --parallel 4
  287. ./iwasm wasm-apps/test.wasm
  288. - name: Build Sample [multi-module]
  289. run: |
  290. cd samples/multi-module
  291. mkdir build && cd build
  292. cmake ..
  293. cmake --build . --config Release --parallel 4
  294. ./multi_module
  295. - name: Build Sample [spawn-thread]
  296. run: |
  297. cd samples/spawn-thread
  298. mkdir build && cd build
  299. cmake ..
  300. cmake --build . --config Release --parallel 4
  301. ./spawn_thread
  302. - name: Build Sample [ref-types]
  303. run: |
  304. cd samples/ref-types
  305. mkdir build && cd build
  306. cmake ..
  307. cmake --build . --config Release --parallel 4
  308. ./hello
  309. - name: Build Sample [wasi-threads]
  310. run: |
  311. cd samples/wasi-threads
  312. mkdir build && cd build
  313. cmake -DWASI_SYSROOT=`pwd`/../../../core/deps/wasi-libc/sysroot ..
  314. cmake --build . --config Release --parallel 4
  315. ./iwasm wasm-apps/no_pthread.wasm
  316. spec_test_default:
  317. needs: [build_iwasm, build_llvm_libraries, build_wamrc]
  318. runs-on: ubuntu-20.04
  319. strategy:
  320. matrix:
  321. running_mode: ["classic-interp", "fast-interp", "aot"]
  322. test_option: ["-x -p -s spec -b -P", "-x -p -s spec -S -b -P"]
  323. llvm_cache_key: ["${{ needs.build_llvm_libraries.outputs.cache_key }}"]
  324. # classic-interp and fast-interp don't support simd
  325. exclude:
  326. - running_mode: "classic-interp"
  327. test_option: "-x -p -s spec -S -b -P"
  328. - running_mode: "fast-interp"
  329. test_option: "-x -p -s spec -S -b -P"
  330. steps:
  331. - name: checkout
  332. uses: actions/checkout@v3
  333. - name: Get LLVM libraries
  334. if: matrix.running_mode == 'aot'
  335. id: retrieve_llvm_libs
  336. uses: actions/cache@v3
  337. with:
  338. path: |
  339. ./core/deps/llvm/build/bin
  340. ./core/deps/llvm/build/include
  341. ./core/deps/llvm/build/lib
  342. ./core/deps/llvm/build/libexec
  343. ./core/deps/llvm/build/share
  344. key: ${{ matrix.llvm_cache_key }}
  345. - name: Quit if cache miss
  346. if: matrix.running_mode == 'aot' && steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
  347. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  348. - name: install SGX SDK and necessary libraries
  349. run: |
  350. mkdir -p /opt/intel
  351. cd /opt/intel
  352. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
  353. chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
  354. echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
  355. 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
  356. wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
  357. sudo apt update
  358. sudo apt install -y libsgx-launch libsgx-urts
  359. - name: run spec tests
  360. run: |
  361. source /opt/intel/sgxsdk/environment
  362. ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  363. working-directory: ./tests/wamr-test-suites