Add custom section sample and enable CI test#4891
Add custom section sample and enable CI test#4891TianlongLiang wants to merge 2 commits intobytecodealliance:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new custom-section sample demonstrating embedding an external payload into a Wasm custom section and retrieving/printing it from the host via wasm_runtime_get_custom_section, and wires the sample into CI so it’s built and executed (Wasm + AoT).
Changes:
- Add a new
samples/custom-sectionsample (host app + wasm app + build/run scripts) for custom-section payload resolution via handle-based native APIs. - Add documentation entries for the new sample.
- Update multiple GitHub Actions workflows to build/run the sample in CI, including AoT builds that preserve the custom section.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
samples/custom-section/wasm-apps/custom_section_payload.s |
Defines a .custom_section.demo section and includes an external payload via .incbin. |
samples/custom-section/wasm-apps/custom_section_payload.bin |
Sample payload content to embed into the Wasm custom section. |
samples/custom-section/wasm-apps/custom_section.c |
Wasm-side demo entrypoint importing host APIs to resolve and print the custom section. |
samples/custom-section/src/native_impl.c |
Host native implementations to resolve a section name to a handle and print its bytes. |
samples/custom-section/src/main.c |
Host executable wiring runtime init, loading the Wasm module, and calling run_demo. |
samples/custom-section/run.sh |
Helper script to run the sample (Wasm or AoT). |
samples/custom-section/build.sh |
Builds the host app + Wasm module and optionally an AoT artifact preserving custom sections. |
samples/custom-section/README.md |
Sample documentation and usage instructions. |
samples/custom-section/CMakeLists.txt |
CMake project definition enabling WAMR_BUILD_LOAD_CUSTOM_SECTION. |
samples/custom-section/.gitignore |
Ignores the sample’s out/ directory. |
samples/README.md |
Adds the new sample to the samples index. |
.github/workflows/nightly_run.yml |
Builds/runs the new sample (Wasm + AoT) in nightly CI. |
.github/workflows/compilation_on_macos.yml |
Builds/runs the new sample (Wasm + AoT) in macOS CI. |
.github/workflows/compilation_on_android_ubuntu.yml |
Builds/runs the new sample (Wasm + AoT) in Android-on-Ubuntu CI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,2 @@ | |||
| .section .custom_section.demo,"",@ | |||
There was a problem hiding this comment.
The .section directive looks syntactically incomplete: .section .custom_section.demo,"",@ ends with @ but no section type. With clang/LLVM integrated assembler this is likely to error out or create an unexpected section. Specify an explicit section type (and any required flags) so the payload reliably lands in a .custom_section.demo section across toolchains.
| .section .custom_section.demo,"",@ | |
| .section .custom_section.demo,"",@progbits |
There was a problem hiding this comment.
The Wasm assembler requires the three-part .section
name,"flags",@ syntax but doesn't accept any ELF section type after the @.
No description provided.