Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce wasm file size by not static link libs like swiftCore #2

Closed
didi11641 opened this issue Sep 15, 2020 · 3 comments
Closed

Reduce wasm file size by not static link libs like swiftCore #2

didi11641 opened this issue Sep 15, 2020 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@didi11641
Copy link

didi11641 commented Sep 15, 2020

I have compiled a 'hello world' demo under the instruction of swiftwasm-book. And I found the hello.wasm is very big ( >10MB )。
I think the main reason is that print will be linked to libswiftCore, which size is 9MB。
AFAK, wasi in wasm is just stubs, it is dynamicly linked at runtime. So I'm trying to exclude these at linkage, by using --allow-undefined / --allow-undefined-file=undefined-symbols.txt after wasm-ld. But it doesn't work, error is:

wasm-ld: error: /tmp/hello-fcefd1.o: undefined symbol: $sSSN

I don't know how to resolve this, anyone help?

@MaxDesiatov
Copy link
Contributor

MaxDesiatov commented Sep 15, 2020

Hi @didi11641, thanks for reporting the issue. As far as I know, neither WebAssembly, nor WASI support dynamic linking, and we don't do any dynamic linking at runtime. Both libswiftCore and WASI are linked statically and are required for SwiftWasm apps to work. libswiftCore contains the standard library and runtime, while WASI and ICU contain basic memory allocation and string manipulation code.

We have more details available about the ongoing effort to reduce the binary size in the related thread in the main SwiftWasm repository. Does that answer your question?

@MaxDesiatov MaxDesiatov added the question Further information is requested label Sep 15, 2020
@didi11641
Copy link
Author

@MaxDesiatov Thanks for your reply. I have looked into print implementation in Print.swift, I guess it will finally call funcs like _swift_stdlib_write in LibcShims.h ,which calls WASI API write。 Thanks for providing the related thread, I will keep track on that issue :)

@MaxDesiatov
Copy link
Contributor

Closing this, as the binary size issues are tracked separately in swiftwasm/swift#7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants