swift icon indicating copy to clipboard operation
swift copied to clipboard

WASM files are quite large?

Open KevinVitale opened this issue 2 years ago • 2 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.

KevinVitale avatar Nov 03 '23 18:11 KevinVitale

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 https://github.com/swiftwasm/swift/issues/7

kateinoigakukun avatar Nov 03 '23 19:11 kateinoigakukun

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.

esummers avatar Nov 24 '23 17:11 esummers