I was also looking in to this too. The swift runtime is quite memory heavy, sadly. It would probably fit in memory, but idk about creating anything useful.
As for the runtime's size itself, that depends. Since the runtime relies on other libraries, such as stdlib & unicode data it could shape up to be around 16-28mb, without any sort of optimization/cleaning of unused functions. Since Lua doesn't support unicode (right?) and if we want to keep Lua bindable in swift then you could compile the stdlib without unicode support and get an extremely small binary. You'd still have some issue with the stdlib not really being optimized for this CPU and some parts of it might not work outright- so you would need to patch this. Some included data structures like array may be unwieldy too. I know that the memory overhead is also noticeably different depending on how you program too. Not to mention that if included with firmware, there is now a fork of the swift compiler AND stdlib that must be maintained. So the way to go would be including it alongside the app, this also allows for any ABI changes (which do still happen!). Given a lean version of the runtime and stdlib you could probably fit it in a few megabytes, which is not wholly unwieldy.
The rust project linked above actually specifically addresses this problem too by building against an extremely lean version of the rust runtime.
I'd guess that the easiest thing to try would be fork the compiler and add ARM cortex-m support, which I don't think would be too much trouble, given that there is an existing LLVM backend for it. Then compile without the stdlib and see what happens. You could probably reference bits of the rust project to figure out bootstrapping and all that since it should be similar.
Tangentially related: while swift can automagically wrap C code, you do end up needing to create an actual idiomatic swift wrapper / library, which is additional overhead. No one wants to use swift like its C
Edit: upon searching a bit, this fork seems highly related: https://github.com/madmachineio/swift.
Edit 2: also interesting: https://dspace.cvut.cz/bitstream/handle/10467/82498/F8-DP-2019-Dragomirecky-Alan-thesis.pdf?sequence=-1
okay, I might explore this over the weekend.
Edit 3: A quick investigation of the first link mentioned by @gregc points to it being the most viable approach as well as the simplest. The repo has fallen a bit behind though and if you are Xcode 13 based you likely won't be able to get cross
to build. cross
is based on old tooling, which has since been moved to swift-tools-support-core
and swift-package-manager
respectively. I will take a crack at resolving this so we can at least compile bins to inspect. It appears the program size is actually quite small too. So this might actually work!
Edit 4: updated cross
here: GitHub - ericlewis/cross: Utility for easy cross compilation of projects to bare metal
don't think it will work still, since spm is tied to swift version too (I think). toolchain has not been updated to 5.6, nor do I think it will be. Going through all the commits to try and rebase will be a bear of a task.