summaryrefslogtreecommitdiffstats
path: root/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/.github/workflows/compilation_on_sgx.yml
blob: f17261118fe93788064d89c75aac9ab8f99f15ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
# Copyright (C) 2019 Intel Corporation.  All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

name: compilation on SGX

on:
  # will be triggered on PR events
  pull_request:
    types:
      - opened
      - synchronize
    paths:
      - ".github/workflows/build_llvm_libraries.yml"
      - ".github/workflows/compilation_on_sgx.yml"
      - "build-scripts/**"
      - "core/**"
      - "!core/deps/**"
      - "product-mini/**"
      - "samples/**"
      - "!samples/workload/**"
      - "tests/wamr-test-suites/**"
      - "wamr-compiler/**"
      - "wamr-sdk/**"
  # will be triggered on push events
  push:
    branches:
      - main
      - "dev/**"
    paths:
      - ".github/workflows/build_llvm_libraries.yml"
      - ".github/workflows/compilation_on_sgx.yml"
      - "build-scripts/**"
      - "core/**"
      - "!core/deps/**"
      - "product-mini/**"
      - "samples/**"
      - "!samples/workload/**"
      - "tests/wamr-test-suites/**"
      - "wamr-compiler/**"
      - "wamr-sdk/**"
  # allow to be triggered manually
  workflow_dispatch:

# Cancel any in-flight jobs for the same PR/branch so there's only one active
# at a time
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

env:
  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"
  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"
  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"
  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"
  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"

jobs:
  build_llvm_libraries:
    uses: ./.github/workflows/build_llvm_libraries.yml
    with:
      os: "ubuntu-20.04"
      arch: "X86"

  build_iwasm:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        make_options_run_mode: [
            # Running modes supported
            $AOT_BUILD_OPTIONS,
            $CLASSIC_INTERP_BUILD_OPTIONS,
            $FAST_INTERP_BUILD_OPTIONS,
            # Running modes unsupported
            #$LLVM_LAZY_JIT_BUILD_OPTIONS,
            #$LLVM_EAGER_JIT_BUILD_OPTIONS,
          ]
        make_options_feature: [
            # Features
            "-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
            # doesn't support
            # "-DWAMR_BUILD_DEBUG_AOT=1",
            # "-DWAMR_BUILD_DEBUG_INTERP=1",
            "-DWAMR_BUILD_DUMP_CALL_STACK=1",
            "-DWAMR_BUILD_LIB_PTHREAD=1",
            "-DWAMR_BUILD_LIB_WASI_THREADS=1",
            "-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1",
            "-DWAMR_BUILD_MINI_LOADER=1",
            "-DWAMR_BUILD_MEMORY_PROFILING=1",
            "-DWAMR_BUILD_MULTI_MODULE=1",
            "-DWAMR_BUILD_PERF_PROFILING=1",
            "-DWAMR_BUILD_REF_TYPES=1",
            # doesn't support
            # "-DWAMR_BUILD_SIMD=1",
            "-DWAMR_BUILD_TAIL_CALL=1",
            "-DWAMR_DISABLE_HW_BOUND_CHECK=1",
            "-DWAMR_BUILD_SGX_IPFS=1",
          ]
        os: [ubuntu-20.04]
        platform: [linux-sgx]
        exclude:
          # uncompatiable mode and feature
          # MULTI_MODULE only on INTERP mode
          - make_options_run_mode: $AOT_BUILD_OPTIONS
            make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
          # MINI_LOADER only on INTERP mode
          - make_options_run_mode: $AOT_BUILD_OPTIONS
            make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
    steps:
      - name: install SGX SDK and necessary libraries
        run: |
          mkdir -p /opt/intel
          cd /opt/intel
          wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
          chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
          echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
          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
          wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
          sudo apt update
          sudo apt install -y libsgx-launch libsgx-urts
          source /opt/intel/sgxsdk/environment

      - name: checkout
        uses: actions/checkout@v3

      - name: Build iwasm
        run: |
          mkdir build && cd build
          cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
          cmake --build . --config Release --parallel 4
        working-directory: product-mini/platforms/${{ matrix.platform }}

  build_wamrc:
    needs: [build_llvm_libraries]
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-20.04
            llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }}
    steps:
      - name: install SGX SDK and necessary libraries
        run: |
          mkdir -p /opt/intel
          cd /opt/intel
          wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
          chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
          echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
          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
          wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
          sudo apt update
          sudo apt install -y libsgx-launch libsgx-urts
          source /opt/intel/sgxsdk/environment

      - name: checkout
        uses: actions/checkout@v3

      - name: Get LLVM libraries
        id: retrieve_llvm_libs
        uses: actions/cache@v3
        with:
          path: |
            ./core/deps/llvm/build/bin
            ./core/deps/llvm/build/include
            ./core/deps/llvm/build/lib
            ./core/deps/llvm/build/libexec
            ./core/deps/llvm/build/share
          key: ${{ matrix.llvm_cache_key }}

      - name: Quit if cache miss
        if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
        run: echo "::error::can not get prebuilt llvm libraries" && exit 1

      - name: Build wamrc
        run: |
          mkdir build && cd build
          cmake ..
          cmake --build . --config Release --parallel 4
        working-directory: wamr-compiler

  build_samples_wasm_c_api:
    needs: [build_iwasm]
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        make_options: [
            # Running modes supported
            $CLASSIC_INTERP_BUILD_OPTIONS,
            $FAST_INTERP_BUILD_OPTIONS,
            # Running modes unsupported
            #$LLVM_EAGER_JIT_BUILD_OPTIONS,
            #$LLVM_LAZY_JIT_BUILD_OPTIONS,
            #$AOT_BUILD_OPTIONS,
          ]
        os: [ubuntu-20.04]
        wasi_sdk_release:
          [
            "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz",
          ]
        wabt_release:
          [
            "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz",
          ]
    steps:
      - name: checkout
        uses: actions/checkout@v3

      - name: download and install wabt
        run: |
          cd /opt
          sudo wget ${{ matrix.wabt_release }}
          sudo tar -xzf wabt-1.0.31-*.tar.gz
          sudo mv wabt-1.0.31 wabt

      - name: install SGX SDK and necessary libraries
        run: |
          mkdir -p /opt/intel
          cd /opt/intel
          wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
          chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
          echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
          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
          wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
          sudo apt update
          sudo apt install -y libsgx-launch libsgx-urts
          source /opt/intel/sgxsdk/environment

      - name: Build Sample [wasm-c-api]
        run: |
          cmake -S . -B build ${{ matrix.make_options }}
          cmake --build build --config Release --parallel 4
          ctest --test-dir build
        working-directory: samples/wasm-c-api

  build_samples_others:
    needs: [build_iwasm]
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-20.04]
        wasi_sdk_release:
          [
            "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz",
          ]
        wabt_release:
          [
            "https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz",
          ]
    steps:
      - name: checkout
        uses: actions/checkout@v3

      - name: download and install wasi-sdk
        run: |
          cd /opt
          sudo wget ${{ matrix.wasi_sdk_release }}
          sudo tar -xzf wasi-sdk-*.tar.gz
          sudo mv wasi-sdk-19.0 wasi-sdk

      - name: download and install wabt
        run: |
          cd /opt
          sudo wget ${{ matrix.wabt_release }}
          sudo tar -xzf wabt-1.0.31-*.tar.gz
          sudo mv wabt-1.0.31 wabt

      - name: build wasi-libc (needed for wasi-threads)
        run: |
          mkdir wasi-libc
          cd wasi-libc
          git init
          # "Fix a_store operation in atomic.h" commit on main branch
          git fetch https://github.com/WebAssembly/wasi-libc \
            1dfe5c302d1c5ab621f7abf04620fae92700fd22
          git checkout FETCH_HEAD
          make \
            AR=/opt/wasi-sdk/bin/llvm-ar \
            NM=/opt/wasi-sdk/bin/llvm-nm \
            CC=/opt/wasi-sdk/bin/clang \
            THREAD_MODEL=posix
        working-directory: core/deps

      - name: install SGX SDK and necessary libraries
        run: |
          mkdir -p /opt/intel
          cd /opt/intel
          wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
          chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
          echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
          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
          wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
          sudo apt update
          sudo apt install -y libsgx-launch libsgx-urts
          source /opt/intel/sgxsdk/environment

      - name: Build Sample [basic]
        run: |
          cd samples/basic
          ./build.sh
          ./run.sh

      - name: Build Sample [file]
        run: |
          cd samples/file
          mkdir build && cd build
          cmake ..
          cmake --build . --config Release --parallel 4
          ./src/iwasm -f wasm-app/file.wasm -d .

      - name: Build Sample [multi-thread]
        run: |
          cd samples/multi-thread
          mkdir build && cd build
          cmake ..
          cmake --build . --config Release --parallel 4
          ./iwasm wasm-apps/test.wasm

      - name: Build Sample [multi-module]
        run: |
          cd samples/multi-module
          mkdir build && cd build
          cmake ..
          cmake --build . --config Release --parallel 4
          ./multi_module

      - name: Build Sample [spawn-thread]
        run: |
          cd samples/spawn-thread
          mkdir build && cd build
          cmake ..
          cmake --build . --config Release --parallel 4
          ./spawn_thread

      - name: Build Sample [ref-types]
        run: |
          cd samples/ref-types
          mkdir build && cd build
          cmake ..
          cmake --build . --config Release --parallel 4
          ./hello

      - name: Build Sample [wasi-threads]
        run: |
          cd samples/wasi-threads
          mkdir build && cd build
          cmake -DWASI_SYSROOT=`pwd`/../../../core/deps/wasi-libc/sysroot ..
          cmake --build . --config Release --parallel 4
          ./iwasm wasm-apps/no_pthread.wasm

  spec_test_default:
    needs: [build_iwasm, build_llvm_libraries, build_wamrc]
    runs-on: ubuntu-20.04
    strategy:
      matrix:
        running_mode: ["classic-interp", "fast-interp", "aot"]
        test_option: ["-x -p -s spec -b -P", "-x -p -s spec -S -b -P"]
        llvm_cache_key: ["${{ needs.build_llvm_libraries.outputs.cache_key }}"]
        # classic-interp and fast-interp don't support simd
        exclude:
          - running_mode: "classic-interp"
            test_option: "-x -p -s spec -S -b -P"
          - running_mode: "fast-interp"
            test_option: "-x -p -s spec -S -b -P"

    steps:
      - name: checkout
        uses: actions/checkout@v3

      - name: Get LLVM libraries
        if: matrix.running_mode == 'aot'
        id: retrieve_llvm_libs
        uses: actions/cache@v3
        with:
          path: |
            ./core/deps/llvm/build/bin
            ./core/deps/llvm/build/include
            ./core/deps/llvm/build/lib
            ./core/deps/llvm/build/libexec
            ./core/deps/llvm/build/share
          key: ${{ matrix.llvm_cache_key }}

      - name: Quit if cache miss
        if: matrix.running_mode == 'aot' && steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
        run: echo "::error::can not get prebuilt llvm libraries" && exit 1

      - name: install SGX SDK and necessary libraries
        run: |
          mkdir -p /opt/intel
          cd /opt/intel
          wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
          chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
          echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
          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
          wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
          sudo apt update
          sudo apt install -y libsgx-launch libsgx-urts

      - name: run spec tests
        run: |
          source /opt/intel/sgxsdk/environment
          ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
        working-directory: ./tests/wamr-test-suites