swiftwasm / swift

WebAssembly support for the Swift programming language

Home Page:https://swiftwasm.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WASM files are quite large?

KevinVitale opened this issue · comments

Description

Long-time Swift dev here, dipping into this WASM project for the first time. This Swift file prints "Hello, WASM":

> main.swift:
print("Hello, WASM!")

The file generated is 6MB+:

$ ls -al main.wasm
$ 6.35M 03.Nov'23 13:50  main.wasm

Questions

  • Is this typical of WASM files? Or something more specific to the details of this project?
  • How can I reduce the file size? An ancillary task I'm working on limits WASM files to 128k.

Unfortunately it's a typical size of wasm binary produced from Swift today. There are several known inefficiencies in the toolchain due and we are hardly working on improving it. You might be able to find some useful resources in #7

The upcoming Embedded Swift features will allow much of the overhead (reflection, unused code, etc.) to be stripped out of WASM builds, but that is still in early development.