Bläddra i källkod

release CI: Add another iwasm binary that supports Garbage Collection and Exception Handling (#3866)

As suggested in #3829, in release CI, we add zip/tar.gz artifacts named
iwasm-gc-eh-{version}-{platform} for `iwasm` which supports features
garbage collection and exception handling(classic interpreter only).

Also, add a command line option to control GC heap size for `iwasm` on
the Windows platform.
TianlongLiang 1 år sedan
förälder
incheckning
bb3f8d9198
2 ändrade filer med 91 tillägg och 35 borttagningar
  1. 73 35
      .github/workflows/build_iwasm_release.yml
  2. 18 0
      product-mini/platforms/windows/main.c

+ 73 - 35
.github/workflows/build_iwasm_release.yml

@@ -31,9 +31,72 @@ on:
         type: string
         required: false
 
+env:
+  DEFAULT_BUILD_OPTIONS: 
+    "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 \
+     -DWAMR_BUILD_CUSTOM_NAME_SECTION=0 \
+     -DWAMR_BUILD_DEBUG_INTERP=0 \
+     -DWAMR_BUILD_DEBUG_AOT=0 \
+     -DWAMR_BUILD_DUMP_CALL_STACK=0 \
+     -DWAMR_BUILD_LIBC_UVWASI=0 \
+     -DWAMR_BUILD_LIBC_EMCC=0 \
+     -DWAMR_BUILD_LIB_RATS=0 \
+     -DWAMR_BUILD_LOAD_CUSTOM_SECTION=0 \
+     -DWAMR_BUILD_MEMORY_PROFILING=0 \
+     -DWAMR_BUILD_MINI_LOADER=0 \
+     -DWAMR_BUILD_MULTI_MODULE=0 \
+     -DWAMR_BUILD_PERF_PROFILING=0 \
+     -DWAMR_BUILD_SPEC_TEST=0 \
+     -DWAMR_BUILD_BULK_MEMORY=1 \
+     -DWAMR_BUILD_LIB_PTHREAD=1 \
+     -DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \
+     -DWAMR_BUILD_LIB_WASI_THREADS=1 \
+     -DWAMR_BUILD_LIBC_BUILTIN=1 \
+     -DWAMR_BUILD_LIBC_WASI=1 \
+     -DWAMR_BUILD_REF_TYPES=1 \
+     -DWAMR_BUILD_SIMD=1 \
+     -DWAMR_BUILD_SHARED_MEMORY=1 \
+     -DWAMR_BUILD_TAIL_CALL=1 \
+     -DWAMR_BUILD_THREAD_MGR=1"
+  GC_EH_BUILD_OPTIONS:
+    "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 \
+     -DWAMR_BUILD_CUSTOM_NAME_SECTION=0 \
+     -DWAMR_BUILD_DEBUG_INTERP=0 \
+     -DWAMR_BUILD_DEBUG_AOT=0 \
+     -DWAMR_BUILD_DUMP_CALL_STACK=0 \
+     -DWAMR_BUILD_LIBC_UVWASI=0 \
+     -DWAMR_BUILD_LIBC_EMCC=0 \
+     -DWAMR_BUILD_LIB_RATS=0 \
+     -DWAMR_BUILD_LOAD_CUSTOM_SECTION=0 \
+     -DWAMR_BUILD_MEMORY_PROFILING=0 \
+     -DWAMR_BUILD_MINI_LOADER=0 \
+     -DWAMR_BUILD_MULTI_MODULE=0 \
+     -DWAMR_BUILD_PERF_PROFILING=0 \
+     -DWAMR_BUILD_SPEC_TEST=0 \
+     -DWAMR_BUILD_BULK_MEMORY=1 \
+     -DWAMR_BUILD_LIB_PTHREAD=1 \
+     -DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \
+     -DWAMR_BUILD_LIB_WASI_THREADS=1 \
+     -DWAMR_BUILD_LIBC_BUILTIN=1 \
+     -DWAMR_BUILD_LIBC_WASI=1 \
+     -DWAMR_BUILD_REF_TYPES=1 \
+     -DWAMR_BUILD_SIMD=1 \
+     -DWAMR_BUILD_SHARED_MEMORY=1 \
+     -DWAMR_BUILD_TAIL_CALL=1 \
+     -DWAMR_BUILD_THREAD_MGR=1 \
+     -DWAMR_BUILD_EXCE_HANDLING=1 \
+     -DWAMR_BUILD_GC=1"
+
 jobs:
   build:
     runs-on: ${{ inputs.runner }}
+    strategy:
+      matrix:
+        include:
+          - build_options: $DEFAULT_BUILD_OPTIONS
+            suffix: ''
+          - build_options: $GC_EH_BUILD_OPTIONS
+            suffix: '-gc-eh'
     steps:
       - uses: actions/checkout@v4
 
@@ -53,48 +116,23 @@ jobs:
       - name: generate iwasm binary release
         shell: bash
         run: |
-          cmake -S . -B build \
-            -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 \
-            -DWAMR_BUILD_CUSTOM_NAME_SECTION=0 \
-            -DWAMR_BUILD_DEBUG_INTERP=0 \
-            -DWAMR_BUILD_DEBUG_AOT=0 \
-            -DWAMR_BUILD_DUMP_CALL_STACK=0 \
-            -DWAMR_BUILD_LIBC_UVWASI=0 \
-            -DWAMR_BUILD_LIBC_EMCC=0 \
-            -DWAMR_BUILD_LIB_RATS=0 \
-            -DWAMR_BUILD_LOAD_CUSTOM_SECTION=0 \
-            -DWAMR_BUILD_MEMORY_PROFILING=0 \
-            -DWAMR_BUILD_MINI_LOADER=0 \
-            -DWAMR_BUILD_MULTI_MODULE=0 \
-            -DWAMR_BUILD_PERF_PROFILING=0 \
-            -DWAMR_BUILD_SPEC_TEST=0 \
-            -DWAMR_BUILD_BULK_MEMORY=1 \
-            -DWAMR_BUILD_LIB_PTHREAD=1 \
-            -DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \
-            -DWAMR_BUILD_LIB_WASI_THREADS=1 \
-            -DWAMR_BUILD_LIBC_BUILTIN=1 \
-            -DWAMR_BUILD_LIBC_WASI=1 \
-            -DWAMR_BUILD_REF_TYPES=1 \
-            -DWAMR_BUILD_SIMD=1 \
-            -DWAMR_BUILD_SHARED_MEMORY=1 \
-            -DWAMR_BUILD_TAIL_CALL=1 \
-            -DWAMR_BUILD_THREAD_MGR=1
+          cmake -S . -B build ${{ matrix.build_options }}
           cmake --build build --config Release --parallel 4
         working-directory: ${{ inputs.cwd }}
 
       - name: Compress the binary on Windows
         if: inputs.runner == 'windows-latest'
         run: |
-          tar -czf iwasm-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz iwasm.exe
-          Compress-Archive -Path iwasm.exe -DestinationPath iwasm-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
-          mv iwasm-${{ inputs.ver_num }}-${{ inputs.runner }}.* ../
+          tar -czf iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz iwasm.exe
+          Compress-Archive -Path iwasm.exe -DestinationPath iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
+          mv iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.* ../
         working-directory: ${{ inputs.cwd }}/build/Release
 
       - name: compress the binary on non-Windows
         if: inputs.runner != 'windows-latest'
         run: |
-          tar czf iwasm-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz iwasm
-          zip iwasm-${{ inputs.ver_num }}-${{ inputs.runner }}.zip iwasm
+          tar czf iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz iwasm
+          zip iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.zip iwasm
         working-directory: ${{ inputs.cwd }}/build
 
       - name: upload release tar.gz
@@ -103,8 +141,8 @@ jobs:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         with:
           upload_url: ${{ inputs.upload_url }}
-          asset_path: ${{ inputs.cwd }}/build/iwasm-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz
-          asset_name: iwasm-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.tar.gz
+          asset_path: ${{ inputs.cwd }}/build/iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz
+          asset_name: iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.tar.gz
           asset_content_type: application/x-gzip
 
       - name: upload release zip
@@ -113,6 +151,6 @@ jobs:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         with:
           upload_url: ${{ inputs.upload_url }}
-          asset_path: ${{ inputs.cwd }}/build/iwasm-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
-          asset_name: iwasm-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.zip
+          asset_path: ${{ inputs.cwd }}/build/iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
+          asset_name: iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.zip
           asset_content_type: application/zip

+ 18 - 0
product-mini/platforms/windows/main.c

@@ -45,6 +45,10 @@ print_help()
 #endif
     printf("  --stack-size=n         Set maximum stack size in bytes, default is 64 KB\n");
     printf("  --heap-size=n          Set maximum heap size in bytes, default is 16 KB\n");
+#if WASM_ENABLE_GC != 0
+    printf("  --gc-heap-size=n         Set maximum gc heap size in bytes,\n");
+    printf("                           default is %u KB\n", GC_HEAP_SIZE_DEFAULT / 1024);
+#endif
 #if WASM_ENABLE_JIT != 0
     printf("  --llvm-jit-size-level=n  Set LLVM JIT size level, default is 3\n");
     printf("  --llvm-jit-opt-level=n   Set LLVM JIT optimization level, default is 3\n");
@@ -271,6 +275,9 @@ main(int argc, char *argv[])
 #else
     uint32 heap_size = 16 * 1024;
 #endif
+#if WASM_ENABLE_GC != 0
+    uint32 gc_heap_size = GC_HEAP_SIZE_DEFAULT;
+#endif
 #if WASM_ENABLE_JIT != 0
     uint32 llvm_jit_size_level = 3;
     uint32 llvm_jit_opt_level = 3;
@@ -346,6 +353,13 @@ main(int argc, char *argv[])
                 return print_help();
             heap_size = atoi(argv[0] + 12);
         }
+#if WASM_ENABLE_GC != 0
+        else if (!strncmp(argv[0], "--gc-heap-size=", 15)) {
+            if (argv[0][15] == '\0')
+                return print_help();
+            gc_heap_size = atoi(argv[0] + 15);
+        }
+#endif
 #if WASM_ENABLE_JIT != 0
         else if (!strncmp(argv[0], "--llvm-jit-size-level=", 22)) {
             if (argv[0][22] == '\0')
@@ -456,6 +470,10 @@ main(int argc, char *argv[])
     init_args.mem_alloc_option.allocator.free_func = free_func;
 #endif
 
+#if WASM_ENABLE_GC != 0
+    init_args.gc_heap_size = gc_heap_size;
+#endif
+
 #if WASM_ENABLE_JIT != 0
     init_args.llvm_jit_size_level = llvm_jit_size_level;
     init_args.llvm_jit_opt_level = llvm_jit_opt_level;