Possible to use Amazon Linux 2023 T4 Graviton with Swift?

an AWS savings plan we had purchased a while back runs out this month, which gives us an opportunity to upgrade our T2 fleet to the newer T4 Graviton instances which are about a third cheaper than the previous generation of T2 instances.

T4 Graviton is an Arm64 architecture, which necessitates cross-architecture compilation. i played around with a T4 instance running Ubuntu 22.04 earlier this year, which i managed to deploy a small Swift server to and wrote up a guide here.

however, our actual fleet runs Amazon Linux 2023, which is, well, a famous weak spot for Swift as it has no official platform support. i got around this earlier this year by building our own Swift toolchains locally from source (!!!) but i anticipate that getting the infrastructure in place to run both an unsupported platform and use cross-architecture compilation at the same time will be significantly more complicated. for one, i imagine we somehow need to build or obtain a custom Arm64 Swift toolchain for Amazon Linux 2023, and building the Swift compiler even in its vanilla configuration is not for the faint of heart.

in light of that, i am reaching out for advice on how to use Swift in production with T4 Graviton, as the roadmap i am imagining right now looks quite daunting to say the least.

You will always be able to put the Swift app in a container and run it through that on anything that can host a container runtime.

would that lose a lot of the benefits of running Amazon Linux 2023 as opposed to something like Ubuntu 24.04? i still remember this famous benchmark which commentators have mostly attributed to the Amazon-optimized system libraries (which i guess includes the Glibc that a Swift app would use) installed with the OS.

If there is no AL 2023 toolchain forthcoming from @sebsto or someone else, I suggest that you put together an SDK bundle for AL 2023 AArch64, which you could then use to cross-compile from Macs or any other platform that has a Swift toolchain already.

The swift-sdk-generator might be a useful tool for this purpose, though you will have to modify it a little to work for AL 2023 instead.

According to a later update of that post, that was mostly down to the Ubuntu package of ImageMagick not being well-optimized, and that subsequent benchmarking only showed a 4% gain for Amazon Linux.

In that case, you can probably run on Ubuntu images for AWS instead.

Using the SDK generator is a possibility, as is using the Static SDK for Linux (that supports ARM64, FWIW), but if you want native Amazon Linux 2023 support, @etcwilde is probably the best person to talk to.