Migration Plan: swift-corelibs-foundation to swift-foundation

I expect to have to re-add the CMake files to swift-corelibs-foundation (and its dependencies, I suppose). In the short term I think it's important to use this opportunity to find where swiftpm's build system needs improvements to build a project like this, and see if we can make those improvements.

I think the simplest thing would require completely rearchitecting llbuild/SPM because the build model doesn't allow for n-parallel builds (with different flags) of each target, and the SPM manifest as well as that does not explicitly state the type of linkage per target. The object files must be separated so the contents of .build need to be restructured as well. That is to say, we need to change to a model as the following:

.target("a", type: .dynamic_library, dependencies: [
  .target("b", linkage: .static),
  .target("c", linkage: .dynamic),
]),
.target("b", type: .dynamic_library),
.target("c", type: .static_library),
.target("d", type: .static_executable),
.target("e", type: .dynamic_executable),

Note that the target linkage and types are mismatched, and that this builds at least 8 targets (with only 5 targets defined).

Perhaps @bnbarham and @Max_Desiatov can chime in if that is feasible to do in the short term.

3 Likes

Hi everyone,

It's time for an update on this plan. We've made a lot of progress, including landing URL support in swift-foundation, @compnerd's many fixes for Windows, and much more.

One area that has been challenging is sorting out the details on how to move from toolchain development to package development, given the co-dependencies between projects like swift-syntax, swift-testing, and swift-foundation. swiftpm has received some major upgrades in this area, but there is more work to do.

When reviewing our priorities for this new implementation, the most important goal is to get these new implementations of swift-foundation into as many hands as possible as quickly as possible. Therefore, we have decided to focus on shipping swift-foundation in the Swift toolchain in the short term.

Instead of asking clients to modify their Package.swift files, we will install FoundationEssentials and FoundationInternationalization in the toolchain, and they will be available for any package to import. swift-corelibs-foundation will still be based on these implementations. That work is continuing in this branch of swift-corelibs-foundation.

swift-foundation (and its dependencies) will build with both cmake and swiftpm for all supported Swift platforms.

swift-corelibs-foundation will build with cmake and swiftpm, for non-Darwin platforms only. This helps clarify its role as a compatibility layer where Foundation.framework is not present and reduces the amount of non portable cross-platform C code we need to maintain.

Thanks, and I'm happy to answer questions in this thread.

34 Likes

While auditing some new sendability errors in Linux/Wasm related to Locale and TimeZone and I was curious to the status of this work. Will it land in a toolchain soon?

Yes, please stay tuned. I have an update soon which I will post in a new thread.

10 Likes