compilation_on_sgx.yml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  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. 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.9.1
  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@v3
  83. - name: Cache LLVM libraries
  84. id: cache_llvm
  85. if: ${{ matrix.light == 'green' }}
  86. uses: actions/cache@v3
  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
  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: [check_repo]
  102. runs-on: ${{ matrix.os }}
  103. strategy:
  104. matrix:
  105. make_options_run_mode: [
  106. # Running mode
  107. $AOT_BUILD_OPTIONS,
  108. $CLASSIC_INTERP_BUILD_OPTIONS,
  109. $FAST_INTERP_BUILD_OPTIONS,
  110. # doesn't support
  111. # $LAZY_JIT_BUILD_OPTIONS,
  112. # $MC_JIT_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_LOAD_CUSTOM_SECTION=1",
  123. "-DWAMR_BUILD_MINI_LOADER=1",
  124. "-DWAMR_BUILD_MEMORY_PROFILING=1",
  125. "-DWAMR_BUILD_MULTI_MODULE=1",
  126. "-DWAMR_BUILD_PERF_PROFILING=1",
  127. "-DWAMR_BUILD_REF_TYPES=1",
  128. # doesn't support
  129. # "-DWAMR_BUILD_SIMD=1",
  130. "-DWAMR_BUILD_TAIL_CALL=1",
  131. "-DWAMR_DISABLE_HW_BOUND_CHECK=1",
  132. "-DWAMR_BUILD_SGX_IPFS=1",
  133. ]
  134. os: [ubuntu-20.04]
  135. platform: [linux-sgx]
  136. exclude:
  137. # uncompatiable mode and feature
  138. # MULTI_MODULE only on INTERP mode
  139. - make_options_run_mode: $AOT_BUILD_OPTIONS
  140. make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
  141. # MINI_LOADER only on INTERP mode
  142. - make_options_run_mode: $AOT_BUILD_OPTIONS
  143. make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
  144. include:
  145. - os: ubuntu-20.04
  146. light: ${{ needs.check_repo.outputs.traffic_light_on_ubuntu_2004 }}
  147. steps:
  148. - name: light status
  149. run: echo "matrix.os=${{ matrix.os }}, light=${{ matrix.light }}"
  150. - name: install SGX SDK and necessary libraries
  151. if: ${{ matrix.light == 'green' }}
  152. run: |
  153. mkdir -p /opt/intel
  154. cd /opt/intel
  155. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
  156. chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
  157. echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
  158. 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
  159. wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
  160. sudo apt update
  161. sudo apt install -y libsgx-launch libsgx-urts
  162. source /opt/intel/sgxsdk/environment
  163. - name: checkout
  164. if: ${{ matrix.light == 'green' }}
  165. uses: actions/checkout@v3
  166. - name: Build iwasm
  167. if: ${{ matrix.light == 'green' }}
  168. run: |
  169. mkdir build && cd build
  170. cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
  171. cmake --build . --config Release --parallel 4
  172. working-directory: product-mini/platforms/${{ matrix.platform }}
  173. build_wamrc:
  174. needs: [build_llvm_libraries, check_repo]
  175. runs-on: ${{ matrix.os }}
  176. strategy:
  177. matrix:
  178. os: [ubuntu-20.04]
  179. include:
  180. - os: ubuntu-20.04
  181. light: ${{ needs.check_repo.outputs.traffic_light_on_ubuntu_2004 }}
  182. steps:
  183. - name: light status
  184. run: echo "matrix.os=${{ matrix.os }}, light=${{ matrix.light }}"
  185. - name: install SGX SDK and necessary libraries
  186. if: ${{ matrix.light == 'green' }}
  187. run: |
  188. mkdir -p /opt/intel
  189. cd /opt/intel
  190. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
  191. chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
  192. echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
  193. 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
  194. wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
  195. sudo apt update
  196. sudo apt install -y libsgx-launch libsgx-urts
  197. source /opt/intel/sgxsdk/environment
  198. - name: checkout
  199. if: ${{ matrix.light == 'green' }}
  200. uses: actions/checkout@v3
  201. - name: Get LLVM libraries
  202. id: cache_llvm
  203. if: ${{ matrix.light == 'green' }}
  204. uses: actions/cache@v3
  205. with:
  206. path: |
  207. ./core/deps/llvm/build/bin
  208. ./core/deps/llvm/build/include
  209. ./core/deps/llvm/build/lib
  210. ./core/deps/llvm/build/libexec
  211. ./core/deps/llvm/build/share
  212. key: ${{ matrix.os }}-${{ env.LLVM_CACHE_SUFFIX }}
  213. - name: Quit if cache miss
  214. if: ${{ matrix.light == 'green' && steps.cache_llvm.outputs.cache-hit != 'true' }}
  215. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  216. - name: Build wamrc
  217. if: ${{ matrix.light == 'green' }}
  218. run: |
  219. mkdir build && cd build
  220. cmake ..
  221. cmake --build . --config Release --parallel 4
  222. working-directory: wamr-compiler
  223. build_samples_wasm_c_api:
  224. needs: [build_iwasm, check_repo]
  225. runs-on: ${{ matrix.os }}
  226. strategy:
  227. matrix:
  228. make_options: [
  229. # Running mode
  230. $CLASSIC_INTERP_BUILD_OPTIONS,
  231. $FAST_INTERP_BUILD_OPTIONS,
  232. # doesn't support
  233. #$LAZY_JIT_BUILD_OPTIONS,
  234. #$MC_JIT_BUILD_OPTIONS,
  235. #$AOT_BUILD_OPTIONS,
  236. ]
  237. os: [ubuntu-20.04]
  238. include:
  239. - os: ubuntu-20.04
  240. light: ${{ needs.check_repo.outputs.traffic_light_on_ubuntu_2004 }}
  241. wasi_sdk_release: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz
  242. wabt_release: https://github.com/WebAssembly/wabt/releases/download/1.0.24/wabt-1.0.24-ubuntu.tar.gz
  243. steps:
  244. - name: light status
  245. run: echo "matrix.os=${{ matrix.os }}, light=${{ matrix.light }}"
  246. - name: checkout
  247. if: ${{ matrix.light == 'green' }}
  248. uses: actions/checkout@v3
  249. - name: download and install wabt
  250. if: ${{ matrix.light == 'green' }}
  251. run: |
  252. cd /opt
  253. sudo wget ${{ matrix.wabt_release }}
  254. sudo tar -xzf wabt-1.0.24-*.tar.gz
  255. sudo mv wabt-1.0.24 wabt
  256. - name: install SGX SDK and necessary libraries
  257. if: ${{ matrix.light == 'green' }}
  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 [wasm-c-api]
  270. if: ${{ matrix.light == 'green' }}
  271. run: |
  272. mkdir build && cd build
  273. cmake .. ${{ matrix.make_options }}
  274. cmake --build . --config Release --parallel 4
  275. ./callback
  276. ./callback_chain
  277. ./empty_imports
  278. ./global
  279. ./hello
  280. ./hostref
  281. ./memory
  282. ./reflect
  283. ./table
  284. ./trap
  285. working-directory: samples/wasm-c-api
  286. build_samples_others:
  287. needs: [build_iwasm, check_repo]
  288. runs-on: ${{ matrix.os }}
  289. strategy:
  290. matrix:
  291. include:
  292. - os: ubuntu-20.04
  293. light: ${{ needs.check_repo.outputs.traffic_light_on_ubuntu_2004 }}
  294. wasi_sdk_release: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz
  295. wabt_release: https://github.com/WebAssembly/wabt/releases/download/1.0.24/wabt-1.0.24-ubuntu.tar.gz
  296. steps:
  297. - name: light status
  298. run: echo "matrix.os=${{ matrix.os }}, light=${{ matrix.light }}"
  299. - name: checkout
  300. if: ${{ matrix.light == 'green' }}
  301. uses: actions/checkout@v3
  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 Sample [basic]
  330. if: ${{ matrix.light == 'green' }}
  331. run: |
  332. cd samples/basic
  333. ./build.sh
  334. ./run.sh
  335. - name: Build Sample [file]
  336. if: ${{ matrix.light == 'green' }}
  337. run: |
  338. cd samples/file
  339. mkdir build && cd build
  340. cmake ..
  341. cmake --build . --config Release --parallel 4
  342. ./src/iwasm -f wasm-app/file.wasm -d .
  343. - name: Build Sample [multi-thread]
  344. if: ${{ matrix.light == 'green' }}
  345. run: |
  346. cd samples/multi-thread
  347. mkdir build && cd build
  348. cmake ..
  349. cmake --build . --config Release --parallel 4
  350. ./iwasm wasm-apps/test.wasm
  351. - name: Build Sample [multi-module]
  352. if: ${{ matrix.light == 'green' }}
  353. run: |
  354. cd samples/multi-module
  355. mkdir build && cd build
  356. cmake ..
  357. cmake --build . --config Release --parallel 4
  358. ./multi_module
  359. - name: Build Sample [spawn-thread]
  360. if: ${{ matrix.light == 'green' }}
  361. run: |
  362. cd samples/spawn-thread
  363. mkdir build && cd build
  364. cmake ..
  365. cmake --build . --config Release --parallel 4
  366. ./spawn_thread
  367. - name: Build Sample [ref-types]
  368. if: ${{ matrix.light == 'green' }}
  369. run: |
  370. cd samples/ref-types
  371. mkdir build && cd build
  372. cmake ..
  373. cmake --build . --config Release --parallel 4
  374. ./hello
  375. spec_test_default:
  376. needs: [build_iwasm, build_llvm_libraries, build_wamrc, check_repo]
  377. runs-on: ubuntu-20.04
  378. strategy:
  379. matrix:
  380. running_mode: ["classic-interp", "fast-interp", "aot"]
  381. test_option: ["-x -p -s spec -P", "-x -p -s spec -S -P"]
  382. include:
  383. - os: ubuntu-20.04
  384. light: ${{ needs.check_repo.outputs.traffic_light_on_ubuntu_2004 }}
  385. steps:
  386. - name: checkout
  387. if: ${{ matrix.light == 'green' }}
  388. uses: actions/checkout@v3
  389. - name: Get LLVM libraries
  390. if: ${{ matrix.light == 'green' }}
  391. id: cache_llvm
  392. uses: actions/cache@v3
  393. with:
  394. path: |
  395. ./core/deps/llvm/build/bin
  396. ./core/deps/llvm/build/include
  397. ./core/deps/llvm/build/lib
  398. ./core/deps/llvm/build/libexec
  399. ./core/deps/llvm/build/share
  400. key: ubuntu-20.04-${{ env.LLVM_CACHE_SUFFIX }}
  401. - name: Quit if cache miss
  402. if: ${{ matrix.light == 'green' && steps.cache_llvm.outputs.cache-hit != 'true' }}
  403. run: echo "::error::can not get prebuilt llvm libraries" && exit 1
  404. - name: install Ninja
  405. if: ${{ matrix.light == 'green' }}
  406. run: sudo apt install -y ninja-build
  407. - name: install SGX SDK and necessary libraries
  408. if: ${{ matrix.light == 'green' }}
  409. run: |
  410. mkdir -p /opt/intel
  411. cd /opt/intel
  412. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
  413. chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
  414. echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
  415. 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
  416. wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
  417. sudo apt update
  418. sudo apt install -y libsgx-launch libsgx-urts
  419. - name: run spec tests
  420. if: ${{ matrix.light == 'green' }}
  421. run: |
  422. source /opt/intel/sgxsdk/environment
  423. ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
  424. working-directory: ./tests/wamr-test-suites