Skip to content

port(wasm): Deduplicate the output type section#2187

Merged
lapla-cogito merged 1 commit into
wild-linker:mainfrom
lapla-cogito:wasm_typededup
Jul 7, 2026
Merged

port(wasm): Deduplicate the output type section#2187
lapla-cogito merged 1 commit into
wild-linker:mainfrom
lapla-cogito:wasm_typededup

Conversation

@lapla-cogito

@lapla-cogito lapla-cogito commented Jul 7, 2026

Copy link
Copy Markdown
Member

wasm-ld deduplicates type sections with the same signature. You can observe this in existing multi-object test:

(▰╹◡╹)❯  wasm-tools print wild/tests/build/wasm/wasm32/multi-object/default/multi-object.wat.wild
(module
  (type (;0;) (func (result i32)))
  (type (;1;) (func))
  (type (;2;) (func (result i32)))
  (export "_start" (func 0))
...
)

(▰╹◡╹)❯  wasm-tools print wild/tests/build/wasm/wasm32/multi-object/default/multi-object.wat.wasm-ld
(module $multi-object.wat.wasm-ld
  (type (;0;) (func))
  (type (;1;) (func (result i32)))
  (memory (;0;) 2)
...
)

Part of #1431

@lapla-cogito

Copy link
Copy Markdown
Member Author

With this patch, Wild no longer emits a simple concatenation of each object's type section and identical function types are collapsed and type indices are rewritten:

(▰╹◡╹)❯  wasm-tools print wild/tests/build/wasm/wasm32/multi-object/default/multi-object.wat.wild
(module
  (type (;0;) (func (result i32)))
  (type (;1;) (func))
  (export "_start" (func 0))
  (export "helper" (func 1))
  (func (;0;) (type 1)
    call 1
    i32.const 42
    i32.ne
    if ;; label = @1
      unreachable
    end
  )
  (func (;1;) (type 0) (result i32)
    i32.const 42
  )
)

@lapla-cogito lapla-cogito merged commit ae69068 into wild-linker:main Jul 7, 2026
22 checks passed
@lapla-cogito lapla-cogito deleted the wasm_typededup branch July 7, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants