Skip to content

Commit 145524a

Browse files
committed
Enhance build configuration to support optional gc
There will be two sets of binaries for iwasm and wamrc. One set without a suffix indicates there is no GC support. Another set with the suffixes "-gc" and "-gc-eh" includes GC support. Users cannot disable GC through command line options; they need to choose the appropriate set to use.
1 parent 6b51c61 commit 145524a

File tree

3 files changed

+35
-17
lines changed

3 files changed

+35
-17
lines changed

.github/workflows/build_wamrc.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ permissions:
3737
jobs:
3838
build:
3939
runs-on: ${{ inputs.runner }}
40+
strategy:
41+
matrix:
42+
include:
43+
- build_options: ""
44+
suffix: "-gc"
45+
- build_options: "-DWAMR_BUILD_GC=0"
46+
suffix: ""
47+
4048
permissions:
4149
contents: write # for uploading release artifacts
4250

@@ -58,7 +66,7 @@ jobs:
5866

5967
- name: generate wamrc binary release
6068
run: |
61-
cmake -S . -B build
69+
cmake -S . -B build ${{ matrix.build_options }}
6270
cmake --build build --config Release --parallel 4
6371
working-directory: wamr-compiler
6472

@@ -89,17 +97,17 @@ jobs:
8997
- name: Compress the binary on Windows
9098
if: inputs.runner == 'windows-latest' && inputs.release
9199
run: |
92-
tar -czf wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc.exe
93-
Compress-Archive -Path wamrc.exe -DestinationPath wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
94-
mv wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.* ../
100+
tar -czf wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc.exe
101+
Compress-Archive -Path wamrc.exe -DestinationPath wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
102+
mv wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.* ../
95103
working-directory: wamr-compiler/build/Release
96104

97105
- name: compress the binary on non-Windows
98106
if: inputs.runner != 'windows-latest' && inputs.release
99107
run: |
100108
# Follow the symlink to the actual binary file
101-
tar --dereference -czf wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc
102-
zip wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip wamrc
109+
tar --dereference -czf wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc
110+
zip wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.zip wamrc
103111
working-directory: wamr-compiler/build
104112

105113
- name: upload release tar.gz
@@ -109,8 +117,8 @@ jobs:
109117
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
110118
with:
111119
upload_url: ${{ inputs.upload_url }}
112-
asset_path: wamr-compiler/build/wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz
113-
asset_name: wamrc-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.tar.gz
120+
asset_path: wamr-compiler/build/wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz
121+
asset_name: wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.tar.gz
114122
asset_content_type: application/x-gzip
115123

116124
- name: upload release zip
@@ -120,6 +128,6 @@ jobs:
120128
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
121129
with:
122130
upload_url: ${{ inputs.upload_url }}
123-
asset_path: wamr-compiler/build/wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
124-
asset_name: wamrc-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.zip
131+
asset_path: wamr-compiler/build/wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
132+
asset_name: wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.zip
125133
asset_content_type: application/zip

wamr-compiler/CMakeLists.txt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,14 @@ add_definitions(-DWASM_ENABLE_MODULE_INST_CONTEXT=1)
5555
add_definitions(-DWASM_ENABLE_MEMORY64=1)
5656
add_definitions(-DWASM_ENABLE_EXTENDED_CONST_EXPR=1)
5757

58-
add_definitions(-DWASM_ENABLE_GC=1)
58+
# Turn on GC by default, can be turned off by setting WAMR_BUILD_GC to 0
59+
if (NOT DEFINED WAMR_BUILD_GC)
60+
set(WAMR_BUILD_GC 1)
61+
add_definitions(-DWASM_ENABLE_GC=1)
62+
else ()
63+
set(WAMR_BUILD_GC 0)
64+
add_definitions(-DWASM_ENABLE_GC=${WAMR_BUILD_GC})
65+
endif ()
5966

6067
set (WAMR_BUILD_STRINGREF 1)
6168
set (WAMR_STRINGREF_IMPL_SOURCE "STUB")
@@ -285,7 +292,11 @@ include (${SHARED_DIR}/utils/shared_utils.cmake)
285292
include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
286293
include (${IWASM_DIR}/libraries/thread-mgr/thread_mgr.cmake)
287294
include (${IWASM_DIR}/common/iwasm_common.cmake)
288-
include (${IWASM_DIR}/common/gc/iwasm_gc.cmake)
295+
if (WAMR_BUILD_GC EQUAL 1)
296+
include (${IWASM_DIR}/common/gc/iwasm_gc.cmake)
297+
else ()
298+
message (STATUS "WAMR GC is disabled")
299+
endif ()
289300
include (${IWASM_DIR}/interpreter/iwasm_interp.cmake)
290301
include (${IWASM_DIR}/aot/iwasm_aot.cmake)
291302
include (${IWASM_DIR}/compilation/iwasm_compl.cmake)

wamr-compiler/main.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ print_help()
178178
printf(" --enable-memory-profiling Enable memory usage profiling\n");
179179
printf(" --xip A shorthand of --enable-indirect-mode --disable-llvm-intrinsics\n");
180180
printf(" --enable-indirect-mode Enable call function through symbol table but not direct call\n");
181-
printf(" --enable-gc Enable GC (Garbage Collection) feature\n");
182181
printf(" --disable-llvm-intrinsics Disable the LLVM built-in intrinsics\n");
183182
printf(" --enable-builtin-intrinsics=<flags>\n");
184183
printf(" Enable the specified built-in intrinsics, it will override the default\n");
@@ -422,7 +421,11 @@ main(int argc, char *argv[])
422421
option.enable_aux_stack_check = true;
423422
option.enable_bulk_memory = true;
424423
option.enable_ref_types = true;
424+
#if WASM_ENABLE_GC != 0
425+
option.enable_gc = true;
426+
#else
425427
option.enable_gc = false;
428+
#endif
426429
option.enable_extended_const = false;
427430
aot_call_stack_features_init_default(&option.call_stack_features);
428431

@@ -571,10 +574,6 @@ main(int argc, char *argv[])
571574
else if (!strcmp(argv[0], "--enable-indirect-mode")) {
572575
option.is_indirect_mode = true;
573576
}
574-
else if (!strcmp(argv[0], "--enable-gc")) {
575-
option.aux_stack_frame_type = AOT_STACK_FRAME_TYPE_STANDARD;
576-
option.enable_gc = true;
577-
}
578577
else if (!strcmp(argv[0], "--disable-llvm-intrinsics")) {
579578
option.disable_llvm_intrinsics = true;
580579
}

0 commit comments

Comments
 (0)