A precompiled swift-syntax
and optimized macro plugins won't fix the issues you've quoted, just make them somewhat less visible, as the macros would execute more quickly. We'd still pay the cost of a slow emit modules step that waits for all of the macro expansions to finish, among other things.
If it's swift-syntax building, then yeah. But even then, they shouldn't be building incrementally. This is probably worth its own Issue report.
Hi folks, looks like there was some work on this issue. @dschaefer2 thank you so much for looking into this. Could you please tell us if there are any updates? Did your solution work or what is the plan here?
Yup, working on a solution now. Essentially the plan is to prebuild the swift-syntax modules needed for macros for all our supported host platforms for the last two major releases of swift-syntax and for the last two releases of the swift compiler. Swift Package Manager will resolve the dependencies for macros and if the required version of swift-syntax has binaries available it'll download them into the cache and extract them into the scratch directory so we can build against them. If it's in the cache, we of course skip the download. And if binaries are not available, we build from source as we currently do. As such, there's no changes needed to your packages for this to work.
One interesting advantage we get from this is that for macros to be performant we really need swift-syntax to be built in release mode. And that can take at least 3 minutes of build time. So this should be good all around.
I'll post again once I start pushing PRs up to swift-package-manager so you can follow along. That should probably be right after the US thanksgiving holiday next week. Being in Canada, that'll give me a nice quiet week to get some code done :).
@dschaefer2 it’s great to hear that these longstanding compile-time issues are being tackled.
Curious about the following:
-
Is this a swift-syntax specific optimization (i.e. hardcoded for swift-syntax usage with macros)?
-
Would I be correct in understanding that these SwiftPM improvements wouldn’t be usable in Xcode until the Xcode team updates the version of SwiftPM being shipped? Last I recall selecting a custom toolchain made no difference to the version of SwiftPM being used in Xcode.
It’s great that these issues are being tackled, and I’d love to get an understanding of when iOS developers (a majority of them tied to Xcode) will be able to take advantage of these improvements.
This is actually macro specific and specific to swift-syntax. Basically that's being done to keep things simple for now since the place I'm adding this doesn't know what target platform you're building for. With macros, they're always the host platform so I can cheat a little. I do think we need a more general strategy for build caching but that's a much bigger architectural change.
Being an open source forum we don't talk about futures of commercial product. But let's say I know where said team sits.
@dschaefer2 got it, thanks for clarifying!
I'm personally in favor of anything that makes it simple to improve the situation right now, really looking forward to this being shipped with Xcode.