compilation_on_sgx.yml 17 KB

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