Skip to content

Commit e9c0078

Browse files
authored
GSoC 2024: Building Swift Macros with WebAssembly (#538)
1 parent fa151c0 commit e9c0078

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

gsoc2024/index.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,32 @@ This project is aimed at simplifying the alignement with an ever-evolving SAM te
240240

241241
**Potential mentors**
242242

243-
- [Sebastien Stormacq](mailto:[email protected]) | ([GitHub](https://github.com/sebsto)
243+
- [Sebastien Stormacq](mailto:[email protected]) | ([GitHub](https://github.com/sebsto))
244+
245+
### Building Swift Macros with WebAssembly
246+
247+
**Project size**: 350 hours
248+
249+
**Difficulty**: Intermediate
250+
251+
**Recommended skills**
252+
253+
- Basic proficiency in Swift, C++
254+
- Interest in compilers and WebAssembly
255+
256+
**Description**
257+
258+
Swift [macros](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/macros) are built as host programs that make use of the [swift-syntax](https://github.com/apple/swift-syntax) package to process Swift syntax and produce new syntax. One of the downsides of this approach is that the build process for each macro can take a significant amount of time, and pre-building macro binaries is complicated by the fact that the binaries need to be built for multiple host platforms (e.g., Linux, Windows, and macOS) and architectures (e.g., x86 and ARM). Moreover, macros are aggressively sandboxed to prevent errors in macros from affecting the Swift compiler itself.
259+
260+
[WebAssembly](https://webassembly.org/) provides a portable compilation target that can be executed on any platform and architecture. [SwiftWasm](https://swiftwasm.org/) can compile Swift to WebAsssembly, and [WasmKit](https://github.com/swiftwasm/WasmKit) provides a runtime that can execute WebAssembly programs. WebAssembly could provide a way to build Swift macros into binaries that can be distributed and run anywhere, eliminating the need to rebuild them continually. This project involves getting swift-syntax and macros implemented on top of it building to WebAssembly, teach the Swift compiler to communicate with these macro implementations, and extending the [Swift Package Manager](https://github.com/apple/swift-package-manager) with support for building and using macros with WebAssembly.
261+
262+
**Expected outcomes/benefits/deliverables**
263+
264+
The ideal outcome of this project would be for Swift macros to be able to opt in to being built with WebAssembly, and have the Swift Package Manager do so without further intervention from the user.
265+
266+
**Potential mentors**
267+
268+
- [Doug Gregor](https://github.com/DougGregor)
244269

245270

246271
### Project topic proposal template

0 commit comments

Comments
 (0)