Skip to content

support emiting custom sections on wasm targets #5494

@zigazeljko

Description

@zigazeljko

There should be a way to emit custom wasm sections from Zig code.

LLVM already has support for this (landed in https://reviews.llvm.org/D45297), using the wasm.custom_sections named metadata:

!0 = !{ !"red", !"foo" }
!1 = !{ !"green", !"bar" }
!2 = !{ !"green", !"qux" }
!wasm.custom_sections = !{ !0, !1, !2 }

The code above compiles into:

.section  .custom_section.red,"",@
.ascii  "foo"

.section  .custom_section.green,"",@
.ascii  "bar"

.section  .custom_section.green,"",@
.ascii  "qux"

From the code above it seems like this should work, but it does not:

export const foo linksection(".custom_section.red") = [_]u8{ 'f', 'o', 'o' };

Should we special-case the linksection(...) syntax on wasm targets to generate the named metadata shown above, or should we use some other syntax for this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-wasm32-bit and 64-bit WebAssemblybugObserved behavior contradicts documented or intended behaviorcontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions