Hello,
Is there any release date for Linux cross-compilation from macOS
with swift 6.1 ?
Regards,
David
Hello,
Is there any release date for Linux cross-compilation from macOS
with swift 6.1 ?
Regards,
David
Putting together all of Apple's announcements, it seems like they're targeting early April for the related OS releases, so Swift 6.1 (and Xcode 16.3) should ship then as well.
The current macOS install page has a static linux SDK for Swift 6.0. Is there anything in particular you're looking forward to working differently in 6.1?
Static linking does not address the same issue : static linking address static linking on linux an requires dependencies to use Musl instead of Glibc : many packages does not support this.
Cross compilation means ability to build Linux binary on macOS plateform and/or build linux aarch64 on amd64 plateform, etc...allowing to prepare docker image on any platform for any other plateform.
Not quite, you only asked about linux cross-compilation above, which the static linux SDK does address, as it can be used from macOS to target either linux x86_64 or AArch64.
Sure, that is the one drawback, but porting those packages is pretty easy most of the time, usually just requiring adding #if canImport(Musl); import Musl
to the appropriate files.
Yep, the static linux SDK does all that, provided you add the few Musl imports as needed.
If you prefer dynamically linking to glibc, take a look at the swift-sdk-generator, which allows you to generate such a linux SDK yourself.
This is easy if you are owner of all of the packages you are using...My project depends on 43 packages....
I did know this tool : will try to use it.
Thanks.
David
I just tested and it does not work for Swift 6.0.3 and Bookworms :
%> swift run swift-sdk-generator make-linux-sdk --with-docker --from-container-image dlta-swift-docker-amd64:latest --sdk-name 6.0.3-bookworm-amd64
warning: failed to retrieve search paths with pkg-config; maybe pkg-config is not installed
warning: couldn't find pc file for sqlite3
Building for debugging...
[1/1] Write swift-version--58304C5D6DBC2206.txt
Build of product 'swift-sdk-generator' complete! (2.06s)
2025-02-25T16:18:15+0100 info org.swift.swift-sdk-generator : [SwiftSDKGenerator] Downloading required toolchain packages...
2025-02-25T16:18:15+0100 info org.swift.swift-sdk-generator : [SwiftSDKGenerator] Using downloaded artifacts from cache
2025-02-25T16:18:15+0100 info org.swift.swift-sdk-generator : [SwiftSDKGenerator] Launching a container to extract the Swift SDK for the target triple...
Error: process exited non-zero: exit(125)
What is target triple ?
I'm in a similar situation as @David_Screve , for the moment I fixed my pipeline having a github runner with arm, and a github runner with amd, to build the docker images.
I invested a lot of time, trying to build an sdk already, and I never get it working, read some blog posts, etc.
Are you referring to the Swift SDK Generator? If so, do you have your issue tracked on GitHub?
mmm... no (I didn't create, neither look if there was a ticket already for that), I tried to build it some time ago, I don't remember what was the problem, but I think was not pretty clear to be able to create a ticket in github.
If the issue is still reproducible, I'd appreciate if you used the usual GitHub issues form.
I have created issue #189 : creating SDK for bookworm not working.
And when giving image name, we cannot give the running architecture : how do you know if I want to build an SDK for amd64 or arm64 ?
And how can we set to use glibc instead of musl ?
David
Swift SDK Generator currently doesn't support Musl or Musl-based distribution, so there's no need to specify glibc as it'll be used by default for appropriate Linux distributions.