compilation_on_sgx.yml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. name: CI on SGX
  4. on:
  5. # will be triggered on PR events
  6. pull_request:
  7. paths-ignore:
  8. - "assembly-script/**"
  9. - "ci/**"
  10. - "doc/**"
  11. - "test-tools/**"
  12. - ".github/workflows/compilation_on_sgx.yml"
  13. # will be triggered on push events
  14. push:
  15. paths-ignore:
  16. - "assembly-script/**"
  17. - "ci/**"
  18. - "doc/**"
  19. - "test-tools/**"
  20. - ".github/workflows/compilation_on_sgx.yml"
  21. # allow to be triggered manually
  22. workflow_dispatch:
  23. # Cancel any in-flight jobs for the same PR/branch so there's only one active
  24. # at a time
  25. concurrency:
  26. group: ${{ github.workflow }}-${{ github.ref }}
  27. cancel-in-progress: true
  28. env:
  29. 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"
  30. 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"
  31. 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"
  32. 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"
  33. MC_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"
  34. LLVM_CACHE_SUFFIX: "build-llvm_libraries_ex"
  35. jobs:
  36. # Cancel any in-flight jobs for the same PR/branch so there's only one active
  37. # at a time
  38. cancel_previous:
  39. runs-on: ${{ matrix.os }}
  40. strategy:
  41. matrix:
  42. os: [ubuntu-20.04]
  43. steps:
  44. - name: Cancel Workflow Action
  45. uses: styfle/cancel-workflow-action@0.6.0
  46. with:
  47. access_token: ${{ github.token }}
  48. # set different traffic lights based on the current repo and the running OS.
  49. # according to light colors, the workflow will run different jobs
  50. check_repo:
  51. needs: cancel_previous
  52. runs-on: ${{ matrix.os }}
  53. strategy:
  54. matrix:
  55. os: [ubuntu-20.04]
  56. outputs:
  57. traffic_light_on_ubuntu_2004: ${{ steps.do_check_on_ubuntu_2004.outputs.light }}
  58. steps:
  59. - name: do_check_on_ubuntu_2004
  60. id: do_check_on_ubuntu_2004
  61. if: ${{ matrix.os == 'ubuntu-20.04' }}
  62. run: |
  63. if [[ ${{ github.repository }} == */wasm-micro-runtime ]]; then
  64. echo "::set-output name=light::green"
  65. else
  66. echo "::set-output name=light::green"
  67. fi
  68. build_llvm_libraries:
  69. needs: check_repo
  70. runs-on: ${{ matrix.os }}
  71. strategy:
  72. matrix:
  73. os: [ubuntu-20.04]
  74. include:
  75. - os: ubuntu-20.04
  76. light: ${{ needs.check_repo.outputs.traffic_light_on_ubuntu_2004 }}
  77. steps:
  78. - name: light status
  79. run: echo "matrix.os=${{ matrix.os }}, light=${{ matrix.light }}"
  80. - name: checkout
  81. if: ${{ matrix.light == 'green' }}
  82. uses: actions/checkout@v2
  83. - name: Cache LLVM libraries
  84. id: cache_llvm
  85. if: ${{ matrix.light == 'green' }}
  86. uses: actions/cache@v2
  87. with:
  88. path: |
  89. ./core/deps/llvm/build/bin
  90. ./core/deps/llvm/build/include
  91. ./core/deps/llvm/build/lib
  92. ./core/deps/llvm/build/libexec
  93. ./core/deps/llvm/build/share
  94. key: ${{ matrix.os }}-${{ env.LLVM_CACHE_SUFFIX }}
  95. - name: Build llvm and clang from source
  96. id: build_llvm_ubuntu
  97. if: ${{ matrix.light == 'green' && steps.cache_llvm.outputs.cache-hit != 'true' }}
  98. run: /usr/bin/env python3 ./build_llvm.py --arch X86 WebAssembly --project clang lldb
  99. working-directory: build-scripts
  100. build_iwasm:
  101. needs: [build_llvm_libraries, check_repo]
  102. runs-on: ${{ matrix.os }}
  103. strategy:
  104. matrix:
  105. make_options_run_mode: [
  106. # Running mode
  107. $CLASSIC_INTERP_BUILD_OPTIONS,
  108. $FAST_INTERP_BUILD_OPTIONS,
  109. # doesn't support
  110. # $LAZY_JIT_BUILD_OPTIONS,
  111. # $MC_JIT_BUILD_OPTIONS,
  112. $AOT_BUILD_OPTIONS,
  113. ]
  114. make_options_feature: [
  115. # Features
  116. "-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
  117. # doesn't support
  118. # "-DWAMR_BUILD_DEBUG_AOT=1",
  119. # "-DWAMR_BUILD_DEBUG_INTERP=1",
  120. "-DWAMR_BUILD_DUMP_CALL_STACK=1",
  121. "-DWAMR_BUILD_LIB_PTHREAD=1",
  122. "-DWAMR_BUILD_MINI_LOADER=1",
  123. "-DWAMR_BUILD_MEMORY_PROFILING=1",
  124. "-DWAMR_BUILD_MULTI_MODULE=1",
  125. "-DWAMR_BUILD_PERF_PROFILING=1",
  126. "-DWAMR_BUILD_REF_TYPES=1",
  127. # doesn't support
  128. # "-DWAMR_BUILD_SIMD=1",
  129. "-DWAMR_BUILD_TAIL_CALL=1",
  130. "-DWAMR_DISABLE_HW_BOUND_CHECK=1",
  131. ]
  132. os: [ubuntu-20.04]
  133. platform: [linux-sgx]
  134. exclude:
  135. # uncompatiable mode and feature
  136. # MULTI_MODULE only on INTERP mode
  137. - make_options_run_mode: $AOT_BUILD_OPTIONS
  138. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  139. # MINI_LOADER only on INTERP mode
  140. - make_options_run_mode: $AOT_BUILD_OPTIONS
  141. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  142. include:
  143. - os: ubuntu-20.04
  144. light: ${{ needs.check_repo.outputs.traffic_light_on_ubuntu_2004 }}
  145. steps:
  146. - name: light status
  147. run: echo "matrix.os=${{ matrix.os }}, light=${{ matrix.light }}"
  148. - name: install SGX SDK and necessary libraries
  149. if: ${{ matrix.light == 'green' }}
  150. run: |
  151. mkdir -p /opt/intel
  152. cd /opt/intel
  153. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
  154. chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
  155. echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
  156. 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
  157. wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
  158. sudo apt update
  159. sudo apt install -y libsgx-launch libsgx-urts
  160. source /opt/intel/sgxsdk/environment
  161. - name: checkout
  162. if: ${{ matrix.light == 'green' }}
  163. uses: actions/checkout@v2
  164. - name: Get LLVM libraries
  165. id: cache_llvm
  166. if: ${{ matrix.light == 'green' }}
  167. uses: actions/cache@v2
  168. with:
  169. path: |
  170. ./core/deps/llvm/build/bin
  171. ./core/deps/llvm/build/include
  172. ./core/deps/llvm/build/lib
  173. ./core/deps/llvm/build/libexec
  174. ./core/deps/llvm/build/share
  175. key: ${{ matrix.os }}-${{ env.LLVM_CACHE_SUFFIX }}
  176. - name: Quit if cache miss
  177. if: ${{ matrix.light == 'green' && steps.cache_llvm.outputs.cache-hit != 'true' }}
  178. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  179. - name: Build iwasm
  180. if: ${{ matrix.light == 'green' }}
  181. run: |
  182. mkdir build && cd build
  183. cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
  184. cmake --build . --config Release --parallel 4
  185. working-directory: product-mini/platforms/${{ matrix.platform }}
  186. build_samples_wasm_c_api:
  187. needs: [build_iwasm, build_llvm_libraries, check_repo]
  188. runs-on: ${{ matrix.os }}
  189. strategy:
  190. matrix:
  191. make_options: [
  192. # Running mode
  193. $CLASSIC_INTERP_BUILD_OPTIONS,
  194. $FAST_INTERP_BUILD_OPTIONS,
  195. # doesn't support
  196. #$LAZY_JIT_BUILD_OPTIONS,
  197. #$MC_JIT_BUILD_OPTIONS,
  198. #$AOT_BUILD_OPTIONS,
  199. ]
  200. os: [ubuntu-20.04]
  201. include:
  202. - os: ubuntu-20.04
  203. light: ${{ needs.check_repo.outputs.traffic_light_on_ubuntu_2004 }}
  204. wasi_sdk_release: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz
  205. wabt_release: https://github.com/WebAssembly/wabt/releases/download/1.0.24/wabt-1.0.24-ubuntu.tar.gz
  206. steps:
  207. - name: light status
  208. run: echo "matrix.os=${{ matrix.os }}, light=${{ matrix.light }}"
  209. - name: checkout
  210. if: ${{ matrix.light == 'green' }}
  211. uses: actions/checkout@v2
  212. - name: Get LLVM libraries
  213. id: cache_llvm
  214. if: ${{ matrix.light == 'green' }}
  215. uses: actions/cache@v2
  216. with:
  217. path: |
  218. ./core/deps/llvm/build/bin
  219. ./core/deps/llvm/build/include
  220. ./core/deps/llvm/build/lib
  221. ./core/deps/llvm/build/libexec
  222. ./core/deps/llvm/build/share
  223. key: ${{ matrix.os }}-${{ env.LLVM_CACHE_SUFFIX }}
  224. - name: Quit if cache miss
  225. if: ${{ matrix.light == 'green' && steps.cache_llvm.outputs.cache-hit != 'true' }}
  226. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  227. - name: download and install wabt
  228. if: ${{ matrix.light == 'green' }}
  229. run: |
  230. cd /opt
  231. sudo wget ${{ matrix.wabt_release }}
  232. sudo tar -xzf wabt-1.0.24-*.tar.gz
  233. sudo mv wabt-1.0.24 wabt
  234. - name: install SGX SDK and necessary libraries
  235. if: ${{ matrix.light == 'green' }}
  236. run: |
  237. mkdir -p /opt/intel
  238. cd /opt/intel
  239. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
  240. chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
  241. echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
  242. 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
  243. wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
  244. sudo apt update
  245. sudo apt install -y libsgx-launch libsgx-urts
  246. source /opt/intel/sgxsdk/environment
  247. - name: Build wamrc
  248. if: ${{ matrix.light == 'green' }}
  249. run: |
  250. mkdir build && cd build
  251. cmake ..
  252. cmake --build . --config Release --parallel 4
  253. working-directory: wamr-compiler
  254. - name: Build Sample [wasm-c-api]
  255. if: ${{ matrix.light == 'green' }}
  256. run: |
  257. mkdir build && cd build
  258. cmake .. ${{ matrix.make_options }}
  259. cmake --build . --config Release --parallel 4
  260. ./callback
  261. ./callback_chain
  262. ./empty_imports
  263. ./global
  264. ./hello
  265. ./hostref
  266. ./memory
  267. ./reflect
  268. ./table
  269. ./trap
  270. working-directory: samples/wasm-c-api
  271. build_samples_others:
  272. needs: [build_iwasm, build_llvm_libraries, check_repo]
  273. runs-on: ${{ matrix.os }}
  274. strategy:
  275. matrix:
  276. include:
  277. - os: ubuntu-20.04
  278. light: ${{ needs.check_repo.outputs.traffic_light_on_ubuntu_2004 }}
  279. wasi_sdk_release: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz
  280. wabt_release: https://github.com/WebAssembly/wabt/releases/download/1.0.24/wabt-1.0.24-ubuntu.tar.gz
  281. steps:
  282. - name: light status
  283. run: echo "matrix.os=${{ matrix.os }}, light=${{ matrix.light }}"
  284. - name: checkout
  285. if: ${{ matrix.light == 'green' }}
  286. uses: actions/checkout@v2
  287. - name: Get LLVM libraries
  288. id: cache_llvm
  289. if: ${{ matrix.light == 'green' }}
  290. uses: actions/cache@v2
  291. with:
  292. path: |
  293. ./core/deps/llvm/build/bin
  294. ./core/deps/llvm/build/include
  295. ./core/deps/llvm/build/lib
  296. ./core/deps/llvm/build/libexec
  297. ./core/deps/llvm/build/share
  298. key: ${{ matrix.os }}-${{ env.LLVM_CACHE_SUFFIX }}
  299. - name: Quit if cache miss
  300. if: ${{ matrix.light == 'green' && steps.cache_llvm.outputs.cache-hit != 'true' }}
  301. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  302. - name: download and install wasi-sdk
  303. if: ${{ matrix.light == 'green' }}
  304. run: |
  305. cd /opt
  306. sudo wget ${{ matrix.wasi_sdk_release }}
  307. sudo tar -xzf wasi-sdk-12.0-*.tar.gz
  308. sudo mv wasi-sdk-12.0 wasi-sdk
  309. - name: download and install wabt
  310. if: ${{ matrix.light == 'green' }}
  311. run: |
  312. cd /opt
  313. sudo wget ${{ matrix.wabt_release }}
  314. sudo tar -xzf wabt-1.0.24-*.tar.gz
  315. sudo mv wabt-1.0.24 wabt
  316. - name: install SGX SDK and necessary libraries
  317. if: ${{ matrix.light == 'green' }}
  318. run: |
  319. mkdir -p /opt/intel
  320. cd /opt/intel
  321. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
  322. chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
  323. echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
  324. 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
  325. wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
  326. sudo apt update
  327. sudo apt install -y libsgx-launch libsgx-urts
  328. source /opt/intel/sgxsdk/environment
  329. - name: Build wamrc
  330. if: ${{ matrix.light == 'green' }}
  331. run: |
  332. mkdir build && cd build
  333. cmake ..
  334. cmake --build . --config Release --parallel 4
  335. working-directory: wamr-compiler
  336. - name: Build Sample [basic]
  337. if: ${{ matrix.light == 'green' }}
  338. run: |
  339. cd samples/basic
  340. ./build.sh
  341. ./run.sh
  342. - name: Build Sample [multi-thread]
  343. if: ${{ matrix.light == 'green' }}
  344. run: |
  345. cd samples/multi-thread
  346. mkdir build && cd build
  347. cmake ..
  348. cmake --build . --config Release --parallel 4
  349. ./iwasm wasm-apps/test.wasm
  350. - name: Build Sample [multi-module]
  351. if: ${{ matrix.light == 'green' }}
  352. run: |
  353. cd samples/multi-module
  354. mkdir build && cd build
  355. cmake ..
  356. cmake --build . --config Release --parallel 4
  357. ./multi_module
  358. - name: Build Sample [spawn-thread]
  359. if: ${{ matrix.light == 'green' }}
  360. run: |
  361. cd samples/spawn-thread
  362. mkdir build && cd build
  363. cmake ..
  364. cmake --build . --config Release --parallel 4
  365. ./spawn_thread
  366. - name: Build Sample [ref-types]
  367. if: ${{ matrix.light == 'green' }}
  368. run: |
  369. cd samples/ref-types
  370. mkdir build && cd build
  371. cmake ..
  372. cmake --build . --config Release --parallel 4
  373. ./hello
  374. spec_test_default:
  375. needs: [build_iwasm, build_llvm_libraries, check_repo]
  376. runs-on: ubuntu-20.04
  377. strategy:
  378. matrix:
  379. running_mode: ["classic-interp", "fast-interp", "aot"]
  380. test_option: ["-x -p -s spec -P", "-x -p -s spec -S -P"]
  381. include:
  382. - os: ubuntu-20.04
  383. light: ${{ needs.check_repo.outputs.traffic_light_on_ubuntu_2004 }}
  384. steps:
  385. - name: checkout
  386. if: ${{ matrix.light == 'green' }}
  387. uses: actions/checkout@v2
  388. - name: Get LLVM libraries
  389. if: ${{ matrix.light == 'green' }}
  390. id: cache_llvm
  391. uses: actions/cache@v2
  392. with:
  393. path: |
  394. ./core/deps/llvm/build/bin
  395. ./core/deps/llvm/build/include
  396. ./core/deps/llvm/build/lib
  397. ./core/deps/llvm/build/libexec
  398. ./core/deps/llvm/build/share
  399. key: ubuntu-20.04-${{ env.LLVM_CACHE_SUFFIX }}
  400. - name: install Ninja
  401. if: ${{ matrix.light == 'green' }}
  402. run: sudo apt install -y ninja-build
  403. - name: install SGX SDK and necessary libraries
  404. if: ${{ matrix.light == 'green' }}
  405. run: |
  406. mkdir -p /opt/intel
  407. cd /opt/intel
  408. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
  409. chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
  410. echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
  411. 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
  412. wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
  413. sudo apt update
  414. sudo apt install -y libsgx-launch libsgx-urts
  415. - name: run spec tests
  416. if: ${{ matrix.light == 'green' }}
  417. run: |
  418. source /opt/intel/sgxsdk/environment
  419. ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  420. working-directory: ./tests/wamr-test-suites