There have been several community requests to add support for older Espressif MCUs based on the Xtensa architecture—specifically, the ESP32-S3, ESP32-S2, and the original ESP32. While newer MCUs are based on RISC-V and are supported by the upstream compiler, those using Xtensa require a custom compiler build.
I’ve prepared a repository containing a build script that should generate a compatible version of the compiler: GitHub - georgik/swift-xtensa: ESP32 - Xtensa support build of Swift
The build process requires two additional forked repositories (the script downloads them automatically):
This work is derived from efforts made for the Rust compiler. LLVM patches from Espressif’s LLVM version have been applied to the Swift fork of LLVM. Additionally, Xtensa-related targets have been registered in the Swift fork. In theory, this approach should work.
However, the test build is currently failing with the following error:
Error details:
<unknown>:0: error: embedded swift cannot be enabled in a compiler built without Swift sources
Installed Swift libraries:
swift-xtensa/install/lib/swift/shims/EmbeddedShims.h
swift-xtensa/install/lib/swift/macosx/libswiftCore.dylib
swift-xtensa/install/lib/swift/macosx/libswiftCompatibilitySpan.dylib
swift-xtensa/install/lib/swift/macosx/libswiftSwiftOnoneSupport.dylib
It seems that stdlib is not properly built.
I would appreciate any insights into what might be missing.