Skip to content

Commit 0cde810

Browse files
authored
Merge branch 'swiftlang:main' into swift-templates
2 parents 45337bd + 14bbc2f commit 0cde810

17 files changed

+1576
-253
lines changed

proposal-templates/0000-swiftpm-template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
*During the review process, add the following fields as needed:*
99

10-
* Implementation: [apple/swift-package-manager#NNNNN](https://github.com/apple/swift-package-manager/pull/NNNNN)
10+
* Implementation: [swiftlang/swift-package-manager#NNNNN](https://github.com/swiftlang/swift-package-manager/pull/NNNNN)
1111
* Decision Notes: [Rationale](https://forums.swift.org/), [Additional Commentary](https://forums.swift.org/)
1212
* Bugs: [SR-NNNN](https://bugs.swift.org/browse/SR-NNNN), [SR-MMMM](https://bugs.swift.org/browse/SR-MMMM)
1313
* Previous Revision: [1](https://github.com/swiftlang/swift-evolution/blob/...commit-ID.../proposals/NNNN-filename.md)

proposals/0317-async-let.md

Lines changed: 22 additions & 22 deletions
Large diffs are not rendered by default.

proposals/0450-swiftpm-package-traits.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ let package = Package(
7575
enabledTraits: [ // Other traits that are enabled when this trait is being enabled
7676
"Foo",
7777
]
78-
)
78+
),
7979
.trait(
8080
name: "FooBar",
8181
enabledTraits: [
@@ -92,7 +92,7 @@ let package = Package(
9292
When depending on a package the `default` trait is enabled. However, the enabled
9393
traits can be customized by passing a set of enabled traits when declaring the
9494
dependency. When specifying the enabled traits of the dependencies the
95-
`.default` trait can be passed which will enable the default trait. The below
95+
`.defaults` trait can be passed which will enable the default trait. The below
9696
example enables the default trait and the additional `SomeTrait` of the package.
9797

9898
```swift
@@ -101,7 +101,7 @@ dependencies: [
101101
url: "https://github.com/Org/SomePackage.git",
102102
from: "1.0.0",
103103
traits: [
104-
.default,
104+
.defaults,
105105
"SomeTrait"
106106
]
107107
),
@@ -130,7 +130,7 @@ dependencies: [
130130
url: "https://github.com/Org/SomePackage.git",
131131
from: "1.0.0",
132132
traits:[
133-
.trait("SomeOtherTrait", condition: .when(traits: ["Foo"])),
133+
.trait(name: "SomeOtherTrait", condition: .when(traits: ["Foo"])),
134134
]
135135
),
136136
]

proposals/0461-async-function-isolation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ struct S: Sendable {
337337
```
338338

339339
Only (implicitly or explicitly) `nonisolated` functions can be marked with
340-
`@concurrent`; it is an error to use the these attributes with
340+
`@concurrent`; it is an error to use this attribute with
341341
an isolation other than `nonisolated`, including global actors, isolated
342342
parameters, and `@isolated(any)`:
343343

proposals/0490-environment-constrained-shared-libraries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Proposal: [SE-0490](0490-environment-constrained-shared-libraries.md)
44
* Authors: [tayloraswift](https://github.com/tayloraswift)
55
* Review Manager: [Alastair Houghton](https://github.com/al45tair)
6-
* Status: **Active Review (Sep 5 - Sep 18, 2025)**
6+
* Status: **Active Review (September 5th...September 18th, 2025)**
77
* Implementation: [swiftlang/swift-package-manager#8249](https://github.com/swiftlang/swift-package-manager/pull/8249)
88
* Documentation: [How to use Environment-Constrained Shared Libraries](https://github.com/swiftlang/swift-package-manager/blob/1eaf59d2facc74c88574f38395aa49983b2badcc/Documentation/ECSLs.md)
99
* Bugs: [SR-5714](https://github.com/swiftlang/swift-package-manager/issues/5714)

proposals/0491-module-selectors.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
* Proposal: [SE-0491](0491-module-selectors.md)
44
* Authors: [Becca Royal-Gordon](https://github.com/beccadax)
55
* Review Manager: [Freddy Kellison-Linn](https)
6-
* Status: **Active review (September 13 ... September 30, 2025)**
6+
* Status: **Accepted**
77
* Bug: [swiftlang/swift#53580](https://github.com/swiftlang/swift/issues/53580) (SR-11183)
88
* Implementation: [swiftlang/swift#34556](https://github.com/swiftlang/swift/pull/34556)
9-
* Review: ([pitch](https://forums.swift.org/t/pitch-module-selectors/80835)) ([review](https://forums.swift.org/t/se-0491-module-selectors-for-name-disambiguation/82124))
9+
* Review: ([pitch](https://forums.swift.org/t/pitch-module-selectors/80835)) ([review](https://forums.swift.org/t/se-0491-module-selectors-for-name-disambiguation/82124)) ([acceptance](https://forums.swift.org/t/accepted-se-0491-module-selectors-for-name-disambiguation/82589))
1010

1111
Previously pitched in:
1212

proposals/0492-section-control.md

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
* Proposal: [SE-0492](0492-section-control.md)
44
* Authors: [Kuba Mracek](https://github.com/kubamracek)
5-
* Status: **Active review (September 22 ... October 6, 2025)**
5+
* Status: **Accepted**
66
* Implementation: available in recent `main` snapshots under the experimental feature `SymbolLinkageMarkers` and with undercored attribute names `@_section` and `@_used`.
7-
* Review: [review](https://forums.swift.org/t/se-0492-section-placement-control/82289)
7+
* Review: [review](https://forums.swift.org/t/se-0492-section-placement-control/82289), [acceptance](https://forums.swift.org/t/accepted-with-modifications-se-0492-section-placement-control/82701)
88
* Discussion threads:
99
* Pitch #1: https://forums.swift.org/t/pitch-low-level-linkage-control-attributes-used-and-section/65877
1010
* Pitch #2: https://forums.swift.org/t/pitch-2-low-level-linkage-control/69752
@@ -88,26 +88,19 @@ let myPlugin: PluginData = (
8888

8989
On top of specifying a custom section name with the `@section` attribute, marking a variable as `@used` is needed to prevent otherwise unused symbols from being removed by the compiler. When using section placement to e.g. implement linker sets, such values are typically going to have no usage at compile time, and at the same time they should not be exposed in public interface of libraries (not be made public), therefore we the need the `@used` attribute.
9090

91-
Different object file formats (ELF, Mach-O, COFF) have different restrictions and rules on what are valid section names, and cross-platform code will have to use different names for different file formats. To support that, custom section names can be specified as a string literal. The string will be used directly, without any processing, as the section name for the symbol. A new `#if objectFileFormat(...)` conditional compilation directive will be provided to support conditionalizing based on the file format:
91+
Different object file formats (ELF, Mach-O, COFF) have different restrictions and rules on what are valid section names, and cross-platform code will have to use different names for different file formats. To support that, custom section names can be specified as a string literal. The string will be used directly, without any processing, as the section name for the symbol. A new `#if objectFormat(...)` conditional compilation directive will be provided to support conditionalizing based on the file format:
9292

9393
```swift
94-
#if objectFileFormat(ELF)
94+
#if objectFormat(ELF)
9595
@section("mysection")
96-
#elseif objectFileFormat(MachO)
96+
#elseif objectFormat(MachO)
9797
@section("__DATA,mysection")
9898
#endif
9999
var global = ...
100100
```
101101

102102
For the ELF file format specifically, the compiler will also emit a “section index” into produced object files, containing an entry about each custom section used in the compilation. This is a solution to an ELF specific problem where the behavior of ELF linkers and loaders means that sections are not easily discoverable at runtime.
103103

104-
When placing variables into a custom section, it's also allowed to use the `lazy` keyword to opt out of the mandatory static initialization and mandatory constant expression behavior, while still achieving section placement of the backing store of the data:
105-
106-
```swift
107-
@section("__DATA,colocated") lazy let data1: Int = 42 //
108-
@section("__DATA,colocated") lazy let data2: Int = Int.random(in: 0 ..< 10) //
109-
```
110-
111104
> Note: The intention is that the `@section` and `@used` attributes are to be used rarely and only by specific use cases; high-level application code should not need to use them directly and instead should rely on libraries, macros and other abstractions over the low-level attributes.
112105
113106
> The scope of this proposal is limited to compile-time behavior and compile-time control. We expect that full user-facing solutions for features like linker sets, test discovery or plugins will also require runtime implementations to discover and iterate the contents of custom sections, possibly from multiple modules. This proposal makes sure to provide the right building blocks and artifacts in binaries for the runtime components, but doesn’t prescribe the shape of those. However, it is providing a significant step towards generalized and safe high-level mechanisms for those use cases. See the discussion in [Runtime discovery of data in custom sections](#runtime-discovery-of-data-in-custom-sections) and [Linker sets, plugins as high-level APIs](#linker-sets-plugins-as-high-level-apis) in Future Directions.
@@ -183,6 +176,8 @@ When allowed, the `@section` attribute on a variable declaration has the followi
183176
- Concretely, the section name string value will be set verbatim as a section specifier for the storage symbol at the LLVM IR level of the compiler. This means that any special behavior that the optimizer, the backend, the assembler or the linker applies based on known section names (or attributes specified as suffixes on the section name) will apply.
184177
3. If applied to a global that is declared as part of top-level executable code (i.e. main.swift), the usual non-top-level-code initialization behavior is applied to the global. I.e. the variable is not sequentially initialized at startup.
185178

179+
The custom section name specified in the `@section` attribute is not validated by the compiler, instead it’s passed directly as a string to the linker.
180+
186181
When allowed, the `@used` attribute on a variable declaration has the following effect:
187182

188183
1. The storage symbol for the variable will be marked as “do not dead-strip”.
@@ -278,20 +273,9 @@ let a = (42, foo) // "foo" is statically initialized into a
278273
// linkable/relocatable pointer
279274
```
280275
281-
### Lazy variables with section placement
282-
283-
On global and static variables that are annotated with `@section`, the compiler will now allow the `lazy` keyword (which is currently disallowed on all global and static variables). Using it will opt such variable out of the "mandatory static initialization" behavior and instead use the at-runtime lazy initialization that traditional global and static variables have. The initializer expression does not need to be a constant expression in this case. This is useful for the uncommon use case of placing variables into a custom section purely for colocation (e.g. to improve performance by increasing page/cacheline locality):
284-
285-
```swift
286-
@section("__DATA,colocated") lazy let data1: Int = 42 //
287-
@section("__DATA,colocated") lazy let data2: Int = Int.random(in: 0 ..< 10) //
288-
```
289-
290-
Traditional global and static variables are backed by two symbols: An init-once token and the actual storage for the variable's content. Both of these symbols are going to be placed into the custom section when using `@section` with `lazy`. This also means that any offline or in-process introspection mechanisms cannot assume a specific layout or state of such variables and their storage bytes in the sections, as the exact layout and content of the symbols of lazy variables is an implementation detail of the Swift language runtime.
291-
292276
### Cross-platform object file format support
293277
294-
The custom section name specified in the `@section` attribute is not validated by the compiler, instead it’s passed directly as a string to the linker. Different platforms supported by Swift are using different object and binary file formats (Linux uses ELF, Darwin uses Mach-O, Windows uses COFF), and that implies different restrictions and rules on what are valid section names. Because of that, a multi-platform library code is expected to use `#if os(...)` to use different section names for different platforms. Because of that, it’s expected that the attributes are to be typically only used indirectly via macros that hide the low-level nature of sections and object file formats from higher-level code developers:
278+
Different platforms supported by Swift are using different object and binary file formats (Linux uses ELF, Darwin uses Mach-O, Windows uses COFF), and that implies different restrictions and rules on what are valid section names. Because of that, a multi-platform library code is expected to use `#if os(...)` to use different section names for different platforms. Because of that, it’s expected that the attributes are to be typically only used indirectly via macros that hide the low-level nature of sections and object file formats from higher-level code developers:
295279
296280
```swift
297281
// Example of a potential project-specific "@RegisterPlugin" macro:
@@ -311,17 +295,17 @@ let plugin = ...
311295
312296
See [Structured section specifiers](#structured-section-specifiers) below for more rationale.
313297
314-
In some cases, it’s not possible to differentiate on the OS to support multiple object file formats, for example when using Embedded Swift to target baremetal systems without any OS. For that, a new `#if objectFileFormat(...)` conditional compilation directive will be provided. The allowed values in this directive will match the set of supported object file formats by the Swift compiler (and expand as needed in the future). Currently, they exact values will be (case sensitive):
298+
In some cases, it’s not possible to differentiate on the OS to support multiple object file formats, for example when using Embedded Swift to target baremetal systems without any OS. For that, a new `#if objectFormat(...)` conditional compilation directive will be provided. The allowed values in this directive will match the set of supported object file formats by the Swift compiler (and expand as needed in the future). Currently, they exact values will be (case sensitive):
315299
316300
* COFF
317301
* ELF
318302
* MachO
319303
* Wasm
320304
321305
```swift
322-
#if objectFileFormat(MachO)
306+
#if objectFormat(MachO)
323307
@section("__DATA_CONST,mysection")
324-
#elseif objectFileFormat(ELF)
308+
#elseif objectFormat(ELF)
325309
@section("mysection")
326310
#endif
327311
let value = ...
@@ -402,9 +386,9 @@ The notions of constant expressions and constant values is applicable to a much
402386
The requirement to only use string literals as the section names could be lifted in the future, and we might allow referring to a declaration of variable with a compile-time string. This would be useful to avoid repetition when placing multiple values into the same section without needing to use macros.
403387
404388
```swift
405-
#if objectFileFormat(ELF)
389+
#if objectFormat(ELF)
406390
let mySectionName = "mysection" // required to be a compile-time value
407-
#elseif objectFileFormat(MachO)
391+
#elseif objectFormat(MachO)
408392
let mySectionName = "__DATA,mysection" // required to be a compile-time value
409393
#endif
410394
@@ -486,7 +470,7 @@ Because `@const` does not affect parsing or type resolution of the expression, i
486470
487471
In Mach-O, custom section names are written as a pair of segment (e.g. `__DATA`) + section (e.g. `mysection`). Structured section names with separate segment and section names, `@section(segment: "...", section: "...")` were considered instead, however this pattern does not generalize across object file formats, and is Mach-O specific (ELF and PE/COFF don’t have segments).
488472
489-
Because different object file formats impose different restrictions on custom section names (length, “.” prefix), a shorthand syntax to specify different section names for different object file formats was considered: `@section(ELF:...”, MachO:...”, COFF:...”)`. This, however, has drawbacks of repeating the file format in cases where the code is only ever targeting a single format (common for example for embedded firmwares on ELF). The benefits of a shorthand syntax is marginal, given that we don’t expect normal application code to used the `@section` attribute directly but instead rely on macros or other higher-level API.
473+
Because different object file formats impose different restrictions on custom section names (length, “.” prefix), a shorthand syntax to specify different section names for different object file formats was considered: `@section(ELF:...”, MachO:...”, COFF:...”)`. This, however, has drawbacks of repeating the file format in cases where the code is only ever targeting a single format (common for example for embedded firmwares on ELF). The benefits of a shorthand syntax is marginal, given that we don’t expect normal application code to use the `@section` attribute directly but instead rely on macros or other higher-level API.
490474
491475
The alternative of using conditional compilation is what is expected to be used for those cases instead.
492476

proposals/0493-defer-async.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
* Proposal: [SE-0493](0493-defer-async.md)
44
* Authors: [Freddy Kellison-Linn](https://github.com/Jumhyn)
55
* Review Manager: [Holly Borla](https://github.com/hborla)
6-
* Status: **Active review (September 22 - October 6, 2025)**
6+
* Status: **Accepted**
77
* Implementation: [swiftlang/swift#83891](https://github.com/swiftlang/swift/pull/83891)
8-
* Review: ([pitch](https://forums.swift.org/t/support-async-calls-in-defer-bodies/81790)) ([review](https://forums.swift.org/t/se-0493-support-async-calls-in-defer-bodies/82293))
8+
* Review: ([pitch](https://forums.swift.org/t/support-async-calls-in-defer-bodies/81790)) ([review](https://forums.swift.org/t/se-0493-support-async-calls-in-defer-bodies/82293)) ([acceptance](https://forums.swift.org/t/accepted-se-0493-support-async-calls-in-defer-bodies/83023))
99

1010
## Introduction
1111

0 commit comments

Comments
 (0)