What is your evaluation of the proposal?
I don’t support the proposal in its current form.
Is the problem being addressed significant enough to warrant a change to Swift?
Yes. While the use case may not be especially common, I think it’s a goal of Swift that the build tools should not limit the type of artifacts users can build, even where they provide opinionated defaults.
Does this proposal fit well with the feel and direction of Swift?
I don’t think so. In my opinion, there are a couple areas where it feels in conflict with Swift’s goals.
-
It targets a very specific set of use cases, and introduces restrictions on future evolution which make it difficult to generalize going forward. I agree that narrowly applicable features can be important to unblock important use cases when a fully general solution is much more complex, but I’m not convinced this proposal is the right short/medium term feature and I think it unnecessarily limits future evolution.
-
As currently designed, this feature is difficult to use correctly without fully understanding its limitations, and does not have a mechanism to enforce correct use. The proposal addresses this, arguing that this is an advanced tool not suitable for most users. Nevertheless, I believe it could be designed to introduce guardrails which prevent the most common patterns of misuse without limiting the proposal's potential use cases. In the spirit of progressive disclosure and providing tools with safe and predictable default behaviors, I think the proposal should include these rather than placing the entire burden of correctness on the end user.
My specific concerns are:
swiftmodule layout in artifacts
The current proposal requires the following layout for the new artifact bundle type, with a top-level swiftinterface file:
đź“‚ example.artifactbundle
đź“‚ MyLibrary
⚙️ libMyLibrary.so
📝 MyLibrary.swiftinterface
📝 info.json
The ecosystem has generally standardized on the directory-based swiftmodule layout when distributing swiftinterfaces and/or binary swiftmodules as toolchain/SDK/external content, and I think it would be a mistake to diverge here. The existing directory based layout naturally extends to multi-arch libraries if that is needed in the future, and has existing conventions for distributing supplementary content like ABI baselines, swiftsourceinfo, etc. which may be of interest to higher level tooling. In certain cases, the compiler can also produce better module loading diagnostics for common build config issues like architecture mismatches when modules are laid out in this format.
Naming
The use of “environment” in the feature’s terminology conflicts with the existing use of the “environment" field of target triples, which I think is likely to cause confusion as users of the proposed feature are likely to need an understanding of both concepts.
Choosing an environment
The proposal states:
Users are responsible for computing the correct URL of the Artifact Bundle for the environment they are building for, possibly within the package manifest. Swift tooling will not, on its own, diagnose or prevent the installation of an incompatible ECSL.
And the demo package currently reads this information from the environment: https://github.com/tayloraswift/swift-dynamic-library-example-client/blob/master/Package.swift. I think providing a better mechanism to propagate the selected variant to the build system should be a prerequisite for this feature. Although today techniques like this are necessary to work around limitations of the tools, we shouldn’t rely on them when building new features from scratch or encourage increasing their use. Overreliance on the environment has a significant impact on predictable build behavior and incremental build perf. It also makes it more difficult to setup long-lived or GUI tools like the VSCode Swift extension. Introducing a new flag or config file to provide this information instead would ensure we don’t exacerbate existing problems.
Forbidding use of triples in the artifact bundle
The proposal states:
The artifact must have exactly one variant in the variants list, and the supportedTriples field is forbidden.
While checking for a matching target triple is not sufficient to diagnose all possible configuration mistakes using this feature, it would make it easier to diagnose and prevent a subset of issues where the user introduces a trivial platform/arch/vendor mismatch. This restriction also potentially blocks use of the feature in multi-architecture builds.
Compiler Compatibility
Since non-Darwin platforms aren’t ABI stable, their use of swiftinterfaces has been extremely minimal up to now, and the compiler does not currently reject swiftinterfaces generated by an incompatible compiler. As the first feature encouraging use of textual interfaces on these platforms, I think the scope of this proposal should cover changes to the compiler to reject incompatible interfaces, whether that be by using the swift-compiler-version/-interface-compiler-version embedded in the interface, or some new mechanism. Without such a mechanism, I think there’s a very high risk of accidental miscompiles going initially unnoticed by users and surfacing in production.
How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
I reviewed the proposal and sample packages demonstrating the feature