swift
swift copied to clipboard
Incremental building?
I realized that even if I change one tiny letter somewhere in some string variable in my project it rebuilds completely, I mean that it seems that it never builds incrementally.
I use this command to build my project
swift build -c debug --product Run --enable-test-discovery --triple wasm32-unknown-wasi
My project is big so building takes ~40 seconds everytime... and it is kinda long time for development experiments.
Is there maybe some magic keyword to enable incremental building or it is just impossible with --triple wasm32-unknown-wasi?
If you pass a -v flag to your swift build invocation, it will print exact commands for the build. Would you be able to infer which one takes the most time from that in your project? I guess that would be linking for big projects, but I'm curious what's actually taking so long in your case?
Additionally, do you see similar build times for other triples?
I guess that would be linking for big projects, but I'm curious what's actually taking so long in your case?
Yeah it seems that linking takes that long time cause it shows all the commands in first 3 seconds, and then it stays 37 more seconds without showing any additional commands and linking is the last command.
Additionally, do you see similar build times for other triples?
I'd love to, but could you tell how to build for other triples?
I tried to build the project with just swift build -c debug --product Run --enable-test-discovery:
Initial building takes ~50 seconds Incremental ~3 seconds
I'd love to, but could you tell how to build for other triples?
I tried to build the project with just
swift build -c debug --product Run --enable-test-discovery:Initial building takes ~50 seconds Incremental ~3 seconds
Yes, I mean the host platform by "other triples", not passing any triple is perfectly fine for that.
That's interesting, I guess our default Wasm linker could be slow for large binaries, especially considering that we have to link everything statically.
@kateinoigakukun do you know if we could expect static linking when targeting Wasm to be slower than dynamic linking on other platforms?
In my case the most of the code and swift files are inside the library that I wrote and maybe I could mark that library somehow so --triple wasm32-unknown-wasi will not relink it everytime?
With static linking there's no way to avoid relinking, as far as I'm aware. In the end you get a single self-contained binary with everything embedded in it, so every time one of the constituent parts change, we have to embed them again to get a completely new binary. There may be some opportunities for caching, but I'm not aware of those.
Maybe @kateinoigakukun can clarify, as he previously has written a Wasm linker, albeit for slightly different purposes.
I've just checked one theory.
I had 915 files in my lib and I glued most of them into several huge files, so I reduced amount of files to 361 and now incremental build takes only 12 seconds. It is really cool, but now I have few non-maintainable files ~20000 lines each.
This is interesting, but I'm not sure why this takes much less time for non-Wasm builds, if I understand correctly what you posted above. We didn't make any changes to how incremental builds work in our fork, as far as I'm aware. Are you using SwiftWasm 5.3.1 or some development snapshot?
carton says that I use swift-wasm-5.3.1-RELEASE
I checked non-Wasm build again and like no changes here, it is still: 45 seconds for initial build 3 seconds for incremental build
This is with 915 files
This is with 361 files
but amount of code is absolutely the same in both cases
I think it's already fixed. Feel free to re-open if not.