That flag is only required for Android, a way to use their patched clang when linking, so it shouldn't be needed on linux.
The glibc sysroot for AArch64 should be automatically installed with that gcc-aarch64 package, else you would not be able to use it, so it's probably one of its dependencies.
Your JSON config file looks fine, with the exception of the sdk
. The Swift compiler expects that path to have two directories, <sdk>/usr/include/
, containing the glibc headers, and <sdk>/usr/lib/
, containing the glibc library and object files.
Ubuntu probably uses the same headers in /usr/include/
across all arches it supports, so you want the sdk
to be /
, then it depends where your gcc-aarch toolchain places the AArch64 libc.so
.
Try cross-compiling hello world
in C using that gcc-aarch64 toolchain with the -v
verbose flag, then look for which libc.so
it links against. If it's linking against one in /usr/lib64/aarch64-linux-gnu/
instead, add "-L", "/usr/lib64/aarch64-linux-gnu/"
to your extra-swiftc-flags
, just as I do for Android with a similar non-standard cross-compilation layout.
That package is a bit more complicated, as it also links against libstdc++, which most Swift packages don't. I suggest you try a package like swift-argument-parser
instead, as shown in my Android doc, and only try a more complicated package like NIO SSL once that is working.
Don't forget to add the right symlink in the Swift resource directory, as mentioned in my linked post. The four -Xlinker -rpath
flags should not be necessary if you are then running the resulting binary in a linux AArch64 environment.
I suggest you add the --build-tests
flag to build the Swift package's test runner, then copy it over to linux AArch and run it, exactly as I document doing so for Android AArch64 in my doc.
That issue was closed this week, so the next trunk snapshot toolchain may work for this.
T4g.large instances appear to be available for $20/month: that may be your only option to build Swift for linux AArch64 now, if you don't have your own local AArch64 hardware.