compilation_on_sgx.yml 14 KB

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