i am trying to cross-compile a Swift application on Linux from an x86_64 host to an AArch64 target, using the Swift 6.0.2 toolchain.
the build works when using the default dynamically linked standard library, but it fails due to missing static-stdlib-args.lnk when i use the --static-swift-stdlib option.
SwiftDriver/GenericUnixToolchain+LinkerSupport.swift:266:
Fatal error: /home/ubuntu/aarch64/swift/usr/lib/swift/linux/static-stdlib-args.lnk not found
i am interested in statically linking the Swift runtime because it is very logistically challenging when using Swift on the server to keep the runtime in sync with the application.
We'd need more info on the config you're using, but there's an obvious reason this is failing: you're not using the static resource directory. Cross-compilation depends on three core compiler flags: -target to choose the triple, -sdk to choose the sysroot for the platform's C/C++ headers and libraries, and -resource-dir to choose the Swift runtime libraries for your platform.
Swift toolchains and SDKs come with two separate resource directories for static versus dynamic linking: usr/lib/swift/linux/ in the linux toolchain contains the runtime and corelibs as shared libraries, whereas usr/lib/swift_static/linux/ contains them as static archives.
The compiler driver will choose the latter for static linking if you allow it, but the error you're seeing usually happens if you choose static linking but forcibly pass in the incorrect shared resource directory with -resource-dir usr/lib/swift.
That's my best guess without ever having seen your config.
if anyone’s interested, i set up a GitHub Actions task in this repo that builds a cross-compilation environment as a Docker image and pushes it to DockerHub:
Cool deal! I can see this as being useful. I'm working on my side to create some cross compilation SDKs for aarch64 and armv7 that can be installed using swift sdk install (or swift experiemental-sdk install for 5.10). The idea is so that you don't have to use the generator for the SDK, you can just download it from the GitHub page and run with it.
But awesome stuff, I see that this cross compilation Docker would be great for cross compiling from GitHub actions or from a CI!