{"id":36716,"date":"2022-08-09T11:12:39","date_gmt":"2022-08-09T15:12:39","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=36716"},"modified":"2022-08-10T13:38:04","modified_gmt":"2022-08-10T17:38:04","slug":"implementing-parts-of-the-swift-compiler-in-swift","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2022\/08\/09\/implementing-parts-of-the-swift-compiler-in-swift\/","title":{"rendered":"Implementing Parts of the Swift Compiler in Swift"},"content":{"rendered":"<p><a href=\"https:\/\/forums.swift.org\/t\/implementing-parts-of-the-swift-compiler-in-swift\/59524\">Douglas Gregor<\/a>:<\/p>\n<blockquote cite=\"https:\/\/forums.swift.org\/t\/implementing-parts-of-the-swift-compiler-in-swift\/59524\">\n<p>Here&rsquo;s a proposed build process for the Swift compiler with Swift code in it:<\/p>\n<ol>\n<li>Build C++ bits with the host C++ compiler<\/li>\n<li>Build <em>mandatory<\/em> Swift bits with the host Swift compiler<\/li>\n<li>Link a &ldquo;minimal stage 1\" Swift compiler<\/li>\n<li>Build <em>optional<\/em> Swift bits with the minimal stage 1 compiler. Note that these bits may not be fully optimized because the stage 1 compiler may lack some optimizer passes.<\/li>\n<li>Link a &ldquo;full stage 2&rdquo; Swift compiler<\/li>\n<li>Rebuild <em>optional<\/em> Swift bits with the stage 2 compiler.<\/li>\n<li>Link a &ldquo;final stage 3&rdquo; Swift compiler<\/li>\n<\/ol>\n<p>[&#8230;]<\/p>\n<p>Personally, I&rsquo;m excited to open the door to having more Swift code in the compiler, but I want to make sure we&rsquo;re doing so in a way that doesn&rsquo;t make it unduly complicated to develop the Swift compiler or port to other host architectures.<\/p>\n<\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2022\/06\/10\/swift-regex\/\">Swift Regex<\/a><\/li>\n<\/ul>\n\n<p id=\"implementing-parts-of-the-swift-compiler-in-swift-update-2022-08-10\">Update (2022-08-10): See also: <a href=\"https:\/\/news.ycombinator.com\/item?id=32399663\">Hacker News<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Douglas Gregor: Here&rsquo;s a proposed build process for the Swift compiler with Swift code in it: Build C++ bits with the host C++ compiler Build mandatory Swift bits with the host Swift compiler Link a &ldquo;minimal stage 1\" Swift compiler Build optional Swift bits with the minimal stage 1 compiler. Note that these bits may [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2022-08-09T15:12:42Z","apple_news_api_id":"65e79844-4250-4b95-8788-b724dcca1dfd","apple_news_api_modified_at":"2022-08-10T17:38:08Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAA==","apple_news_api_share_url":"https:\/\/apple.news\/AZeeYREJQS5WHiLck3Mod_Q","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[255,46,71,901],"class_list":["post-36716","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-compiler","tag-languagedesign","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/36716","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=36716"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/36716\/revisions"}],"predecessor-version":[{"id":36723,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/36716\/revisions\/36723"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=36716"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=36716"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=36716"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}