Skip to content

Enhance wamrc build configuration to support optional gc #4547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions .github/workflows/build_wamrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ permissions:
jobs:
build:
runs-on: ${{ inputs.runner }}
strategy:
matrix:
include:
- build_options: ""
suffix: "-gc"
- build_options: "-DWAMR_BUILD_GC=0"
suffix: ""

permissions:
contents: write # for uploading release artifacts

Expand All @@ -58,7 +66,7 @@ jobs:

- name: generate wamrc binary release
run: |
cmake -S . -B build
cmake -S . -B build ${{ matrix.build_options }}
cmake --build build --config Release --parallel 4
working-directory: wamr-compiler

Expand Down Expand Up @@ -89,17 +97,17 @@ jobs:
- name: Compress the binary on Windows
if: inputs.runner == 'windows-latest' && inputs.release
run: |
tar -czf wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc.exe
Compress-Archive -Path wamrc.exe -DestinationPath wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
mv wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.* ../
tar -czf wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc.exe
Compress-Archive -Path wamrc.exe -DestinationPath wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
mv wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.* ../
working-directory: wamr-compiler/build/Release

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

- name: upload release tar.gz
Expand All @@ -109,8 +117,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.upload_url }}
asset_path: wamr-compiler/build/wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz
asset_name: wamrc-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.tar.gz
asset_path: wamr-compiler/build/wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz
asset_name: wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.tar.gz
asset_content_type: application/x-gzip

- name: upload release zip
Expand All @@ -120,6 +128,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.upload_url }}
asset_path: wamr-compiler/build/wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
asset_name: wamrc-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.zip
asset_path: wamr-compiler/build/wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
asset_name: wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.zip
asset_content_type: application/zip
16 changes: 14 additions & 2 deletions wamr-compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,15 @@ add_definitions(-DWASM_ENABLE_MODULE_INST_CONTEXT=1)
add_definitions(-DWASM_ENABLE_MEMORY64=1)
add_definitions(-DWASM_ENABLE_EXTENDED_CONST_EXPR=1)

add_definitions(-DWASM_ENABLE_GC=1)
# Sync with iwasm in config_common.cmake. Turn off GC by default.
# can be turned on by setting WAMR_BUILD_GC to 1
if (NOT DEFINED WAMR_BUILD_GC)
set(WAMR_BUILD_GC 0)
add_definitions(-DWASM_ENABLE_GC=0)
else ()
set(WAMR_BUILD_GC 1)
add_definitions(-DWASM_ENABLE_GC=${WAMR_BUILD_GC})
endif ()

set (WAMR_BUILD_STRINGREF 1)
set (WAMR_STRINGREF_IMPL_SOURCE "STUB")
Expand Down Expand Up @@ -285,7 +293,11 @@ include (${SHARED_DIR}/utils/shared_utils.cmake)
include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
include (${IWASM_DIR}/libraries/thread-mgr/thread_mgr.cmake)
include (${IWASM_DIR}/common/iwasm_common.cmake)
include (${IWASM_DIR}/common/gc/iwasm_gc.cmake)
if (WAMR_BUILD_GC EQUAL 1)
include (${IWASM_DIR}/common/gc/iwasm_gc.cmake)
else ()
message (STATUS "WAMR GC is disabled")
endif ()
include (${IWASM_DIR}/interpreter/iwasm_interp.cmake)
include (${IWASM_DIR}/aot/iwasm_aot.cmake)
include (${IWASM_DIR}/compilation/iwasm_compl.cmake)
Expand Down
9 changes: 4 additions & 5 deletions wamr-compiler/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ print_help()
printf(" --enable-memory-profiling Enable memory usage profiling\n");
printf(" --xip A shorthand of --enable-indirect-mode --disable-llvm-intrinsics\n");
printf(" --enable-indirect-mode Enable call function through symbol table but not direct call\n");
printf(" --enable-gc Enable GC (Garbage Collection) feature\n");
printf(" --disable-llvm-intrinsics Disable the LLVM built-in intrinsics\n");
printf(" --enable-builtin-intrinsics=<flags>\n");
printf(" Enable the specified built-in intrinsics, it will override the default\n");
Expand Down Expand Up @@ -424,7 +423,11 @@ main(int argc, char *argv[])
option.enable_aux_stack_check = true;
option.enable_bulk_memory = true;
option.enable_ref_types = true;
#if WASM_ENABLE_GC != 0
option.enable_gc = true;
#else
option.enable_gc = false;
#endif
option.enable_extended_const = false;
aot_call_stack_features_init_default(&option.call_stack_features);

Expand Down Expand Up @@ -573,10 +576,6 @@ main(int argc, char *argv[])
else if (!strcmp(argv[0], "--enable-indirect-mode")) {
option.is_indirect_mode = true;
}
else if (!strcmp(argv[0], "--enable-gc")) {
option.aux_stack_frame_type = AOT_STACK_FRAME_TYPE_STANDARD;
option.enable_gc = true;
}
else if (!strcmp(argv[0], "--disable-llvm-intrinsics")) {
option.disable_llvm_intrinsics = true;
}
Expand Down
Loading