# Bootstrapping Swift Compiler

**URL:** <https://forums.swift.org/t/bootstrapping-swift-compiler/51122>\
**Category:** Compiler\
**Created:** [August 11, 2021, 3:35pm UTC](https://forums.swift.org/t/bootstrapping-swift-compiler/51122 "2021-08-11T15:35:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hggz](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/hggz/32/6065_2.png) [@hggz](https://forums.swift.org/u/hggz)\
**Post date:** [August 11, 2021, 3:35pm UTC](https://forums.swift.org/t/bootstrapping-swift-compiler/51122/1 "2021-08-11T15:35:49Z")

</div>

Out of curiosity, is the ability for the Swift compiler to build itself eventually and be written primarily in Swift, something that's envisioned for the future? Or would such an undertaking be unlikely because of the current dependencies?

Has this topic been discussed before?

---

<div class="post-metadata">

**Author:** ![Karl](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@Karl](https://forums.swift.org/u/Karl)\
**Post date:** [August 11, 2021, 4:08pm UTC](https://forums.swift.org/t/bootstrapping-swift-compiler/51122/2 "2021-08-11T16:08:35Z")

</div>

I think it's clear that it is the goal. For instance, see the README for [`swift-driver`](https://github.com/apple/swift-driver) (emphasis added):

> The `swift-driver` project is a new implementation of the Swift compiler driver that is **intended to replace the existing driver** with a more extensible, maintainable, and robust code base.

So unless you want a compiler without a driver, at some point you'll need a Swift compiler in order to build a Swift compiler.

---

<div class="post-metadata">

**Author:** ![stevapple](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/stevapple/32/31979_2.png) [@stevapple](https://forums.swift.org/u/stevapple)\
**Post date:** [August 11, 2021, 4:58pm UTC](https://forums.swift.org/t/bootstrapping-swift-compiler/51122/3 "2021-08-11T16:58:49Z")

</div>

Of course, and the community is actually moving toward that goal.

> [@Libswift is enabled](https://forums.swift.org/t/libswift-is-enabled/49687):
>
> With libswift it is possible to add SIL optimization passes written in Swift. It allows to gradually migrate the SIL optimizer from C++ to Swift. For details see [libswift/README.md](https://github.com/apple/swift/blob/main/libswift/README.md) and the [PR](https://github.com/apple/swift/pull/37058), which introduced the initial version. libswift is now [enabled in the CI](https://github.com/apple/swift/pull/37921), which means it's now possible to contribute to libswift. If you have any questions, just let me know.

[`libswift`](https://github.com/apple/swift/tree/main/libswift) is the first piece of Swift codes in the actual Swift compiler (frontend).
