You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: proposals/0482-swiftpm-static-library-binary-target-non-apple-platforms.md
+22-14Lines changed: 22 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,11 +10,10 @@
10
10
11
11
## Introduction
12
12
13
-
Swift continues to grow as a cross-platform language supporting a wide variety of use cases from [programming embedded device](https://www.swift.org/blog/embedded-swift-examples/) to [server-side development](https://www.swift.org/documentation/server/) across a multitude of [operating systems](https://www.swift.org/documentation/articles/static-linux-getting-started.html).
13
+
Swift continues to grow as a cross-platform language supporting a wide variety of use cases from [programming embedded device](https://www.swift.org/blog/embedded-swift-examples/) to [server-side development](https://www.swift.org/documentation/server/) across a multitude of [operating systems](https://www.swift.org/documentation/articles/static-linux-getting-started.html).
14
14
However, currently SwiftPM supports linking against binary dependencies on Apple platforms only.
15
-
This proposal aims to make it possible to provide static library dependencies exposing a C interface on non-Apple platforms.
16
-
17
-
Swift-evolution thread:
15
+
This proposal aims to make it possible to provide static library dependencies exposing a C interface on non-Apple platforms that depend only on the standard C library.
16
+
The scope of this proposal is C libraries only, distributing Swift libraries has additional challenges (see [Future directions](#future-directions).
18
17
19
18
## Motivation
20
19
@@ -41,8 +40,10 @@ The artifact manifest would encode the following information for each variant:
41
40
* Enough information to be able to use the library's API in the packages source code,
42
41
i.e., headers and module maps for libraries exporting a C-based interface.
43
42
44
-
Additionnaly, we propose the addition of an auditing tool that can validate the library artifact is safe to use across the Linux-based platforms supported by the Swift project.
43
+
Additionally, we propose the addition of an auditing tool that can validate the library artifact is safe to use across the Linux-based platforms supported by the Swift project.
45
44
Such a tool would ensure that people do not accidentally distribute artifacts that require dependencies that are not met on the various deployment platforms.
45
+
However when an artifact isn't widely consumed and all dependent packages are known,
46
+
artifact vendors can provide artifacts with dependencies on other C libraries provided that each client target depends explicitly on all required dependencies of the artifact.
46
47
47
48
## Detailed design
48
49
@@ -62,42 +63,49 @@ The artifact manifest JSON format for a static library is described below:
* The `staticLibrary` artifact `type` that indicates this binary artifact is not an executable but rather a static library to link against.
80
84
* The `headerPaths` field specifies directory paths relative to the root of the artifact bundle that contain the header interfaces to the static library.
81
85
These are forwarded along to the swift compiler (or the C compiler) using the usual search path arguments.
82
-
Each of these directories can optionally contain a `module.modulemap` file that will be used for importing the API into Swift code.
83
-
* The optional `moduleMapPath`field specifies a custom module map to use if the header paths do not contain the module definitions or to provide custom overrides.
86
+
* The optional `moduleMapPath` field specifies the path relative to the root of the artifact bundle that contains a custom module map to use if the header paths do not contain the module definitions or to provide custom overrides.
87
+
This field is required if the library's API is to be imported into Swift code.
84
88
85
89
As with executable binary artifacts, the `path` field represents the relative path to the binary from the root of the artifact bundle,
86
90
and the `supportedTriples` field provides information about the target triples supported by this variant.
@@ -123,7 +131,7 @@ The tool would then check that the referenced symbols list is a subset of the se
123
131
This would be sufficient to guarantee that all symbols from the static library would be available at runtime for statically linked executables or for ones running on the build host.
124
132
To ensure maximum runtime compatibility we would also provide a Linux-based Docker image that uses the oldest supported `glibc` for a given Swift version.
125
133
As `glibc` is backwards compatible, a container running the audit on a given static library would ensure that the version of `glibc` on any runtime platform would be compatible with the binary artifact.
126
-
This strategy as been succesfully employed in the Python community with [`manylinux`](https://peps.python.org/pep-0513/).
134
+
This strategy as been successfully employed in the Python community with [`manylinux`](https://peps.python.org/pep-0513/).
0 commit comments