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
[static-linux-sdk] Update "Getting Started with the Static Linux SDK" (#1120)
* [authors] add incertum
Signed-off-by: Melissa Kilby <[email protected]>
* [static-linux-sdk] Update "Getting Started with the Static Linux SDK"
Enhance clarity and transparency by adding more details about dependency management when using the Static Linux SDK, especially regarding the dependencies bundled with it.
Co-authored-by: Alastair Houghton <[email protected]>
Signed-off-by: Melissa Kilby <[email protected]>
* [static-linux-sdk] Update "Getting Started with the Static Linux SDK"
Add a comment contrasting the Linux SDK with Apple platforms.
Co-authored-by: Evan Wilde <[email protected]>
Signed-off-by: Melissa Kilby <[email protected]>
---------
Signed-off-by: Melissa Kilby <[email protected]>
Co-authored-by: Alastair Houghton <[email protected]>
Co-authored-by: Evan Wilde <[email protected]>
Copy file name to clipboardExpand all lines: documentation/articles/static-linux-getting-started.md
+86-2Lines changed: 86 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
layout: page
3
3
date: 2024-06-04 12:00:00
4
4
title: Getting Started with the Static Linux SDK
5
-
author: [al45tair]
5
+
author: [al45tair, incertum, etcwilde]
6
6
---
7
7
8
8
It's well known that Swift can be used to build software for Apple
@@ -24,12 +24,30 @@ with no external dependencies at all (not even the C library), which
24
24
means that it will run on _any_ Linux distribution as the only thing
25
25
it depends on is the Linux system call interface.
26
26
27
+
This portability comes at a cost, namely that everything your program
28
+
depends on must be statically linked. There is no support for dynamic
29
+
linking whatsoever — even the `dlopen()` function will not work.
30
+
31
+
A result of this design choice is that the Static Linux SDK uses a
32
+
“bring your own dependencies” model, similar to that you might be used
33
+
to with the Swift Package Manager. You cannot use system libraries,
34
+
but must either rely on the handful of common libraries supplied with
35
+
the Static SDK (see below), or build any extras yourself.
36
+
27
37
Additionally, the Static Linux SDK can be used from any platform
28
38
supported by the Swift compiler and package manager; this means that
29
39
you can develop and test your program on macOS before building and
30
40
deploying it to a Linux-based server, whether running locally or
31
41
somewhere in the cloud.
32
42
43
+
Finally, for those wondering about an equivalent for Apple platforms,
44
+
no such static SDK exists. Building a fully static executable is not
45
+
possible on Apple's operating systems because, unlike Linux, the
46
+
Darwin kernel's system call table is not part of the ABI. This design
47
+
requires all system calls to be routed through the dynamic library
48
+
`libsystem.dylib`, fundamentally preventing a 100% statically linked
49
+
binary.
50
+
33
51
### Static vs Dynamic Linking
34
52
35
53
_Linking_ is the process of taking different pieces of a computer
@@ -255,7 +273,7 @@ in another, or a pointer type will be imported as `OpaquePointer`
255
273
rather than `UnsafePointer<FOO>`.
256
274
257
275
If you do find yourself needing to make these kinds of adjustments,
258
-
you can make your local copy of the package dependency editable by
276
+
you can make your [local copy](https://developer.apple.com/documentation/xcode/editing-a-package-dependency-as-a-local-package) of the package dependency editable by
259
277
doing
260
278
261
279
```console
@@ -265,3 +283,69 @@ $ swift package edit SomePackage
265
283
and then editing the files in the `Packages` directory that appears in
266
284
your program's source directory. You may wish to consider raising PRs
267
285
upstream with any fixes you may have.
286
+
287
+
If your project makes use of C or C++ language libraries, you may need
288
+
to take additional steps. The Static SDK for Linux includes a small
0 commit comments