Commit Graph

21502 Commits

Author SHA1 Message Date
Saleem Abdulrasool
35e9b0bcfd Merge pull request #81951 from Steelskin/fabrice/ucrt-modulemap-26100-3916
Platform: Windows SDK 26100.3916 module map update
2025-06-05 10:05:02 -07:00
Saleem Abdulrasool
8a64f4105e Merge pull request #81826 from Steelskin/fabrice/update-ucrt-vcruntime-modulemap
Platform: Update module maps for the static SDK
2025-06-05 10:04:34 -07:00
Henrik G. Olsson
18a3f083ba Merge pull request #81827 from hnrklssn/swiftify-fixes-6.2
Swiftify fixes for 6.2
2025-06-04 11:30:34 -07:00
Konrad 'ktoso' Malawski
11fb1ad419 [Concurrency] Prefer swift_auth_code_function over swift_auth_code
This allows us to use constants, and not hardcoded numbers
2025-06-03 07:02:48 +09:00
Konrad 'ktoso' Malawski
e18f553eab Correct priority cancellation handler signing once more
Resolves rdar://150378890 for real this time, verified on arm64e myself
2025-06-02 21:40:18 +09:00
Henrik G. Olsson
8584d343cb [Swiftify] Update availability for CxxSpan<->Span, fix lifetimebound on parameters with reference type (#81634)
Update availability for CxxSpan<->Span, fix lifetimebound on parameters
with reference type

Because swift-ide-test doesn't care about typechecking,
std-span-interface.swift passed despite containing 2 separate errors.
This updates the test file to properly exercise the entire compilation
pipeline for the macro expansions, by running swift-frontend
-emit-module and calling each macro expansion.

The first issue was that CxxSpan initializers taking [Mutable]Span still
had their availability set to Swift 6.2+, even after back-deploying
caused [Mutable]Span to have availability back to Swift 5.0. Since
_SwiftifyImport expansions copy the availbility of Span, this resulted
in the macro expansions calling unavailable initializers. Interestingly
enough, this manifested itself in the form of a tripped assert in SIL
verification, because although we do now typecheck the expansions from
_SwiftifyImport, the compilation can still keep going after
`shouldEmitFunctionBody` returns false: the macro expansion declaration
is still there, but is now missing its definition, despite not being
external.

The second issue was when parameters with C++ reference types were
annotated with `[[clang::lifetimebound]]`. For parameters with a type
that is `Escapable`, this is normally done using `@lifetime(borrow
foo)`. However C++ reference parameters are imported as `inout`, which
requires the `@lifetime(&foo)` syntax.

rdar://151493400
rdar://151678415
(cherry picked from commit 262a53f599)
2025-05-30 18:19:57 -07:00
Guillaume Lessard
3a3ea0cb10 Merge pull request #81871 from glessard/rdar138440979-mutablespan-abi-fix-62
[6.2, stdlib] fix an extraneous symbol exported by MutableSpan
2025-05-30 18:01:25 -07:00
Guillaume Lessard
6acbdde394 [stdlib] fix an extraneous symbol exported by MutableSpan 2025-05-30 08:23:42 -07:00
Alastair Houghton
6beca9639f Merge pull request #81528 from al45tair/fix-static-sdk-build-6.2
[6.2][Cxx] Build the C++ interop support library for the Static SDK for Linux.
2025-05-29 15:53:37 +01:00
Mike Ash
90b232caa4 Merge pull request #81815 from mikeash/taskgroup-fixes-6.2
[6.2][Concurrency] Fix races/overflows in TaskGroup implementation.
2025-05-29 05:16:58 -04:00
Konrad `ktoso` Malawski
5baa624085 Merge pull request #81820 from ktoso/pick-abi-fix-startSynchronously
[6.2][Concurrent] Restored old symbol for obsoleted `Task.startSynchronously`
2025-05-29 16:19:38 +09:00
Mike Ash
b42c7fa172 [6.2][Concurrency] Fix races/overflows in TaskGroup implementation.
statusCompletePendingReadyWaiting(), offer(), and poll() did a one-off compare_exchange_strong which could fail if the group was concurrently cancelled. Put these into loops so that they are retried when needed.

DiscardingTaskGroup creation passed the group result type as the task result type. waitAll() would then use the group result type when collecting task results. Since the task result type is always Void in this case, this would overflow the result buffer if the group result type was larger. This often works as it writes into the free space of the task allocator, but can crash if it happens to be at the end of a page or the group result type is particularly large.

rdar://151663730
(cherry picked from commit 5be22fa7cc)
2025-05-28 20:59:17 -04:00
Konrad `ktoso` Malawski
c8a8183d26 [6.2][Concurrency][SE-review update] Task names update (#81132)
**Description**: This adds "task name" parameter to all task creating
functions.

This is done in a few ways, e.g. we can backdeploy this to 5.1 in APIs
which do not accept the `TaskExecutor` but it they do we provide a
version for 6.0+ etc. This was requested in the SE acceptable of this
proposal [Acceptance post
SE-0469](https://forums.swift.org/t/accepted-with-modifications-se-0469-task-naming/79438).

This moves all these declarations to gyb since going through them one by
one has become unmaintainable otherwise.

**Scope/Impact**: All task creation APIs now gain a new task name
parameter.
**Risk:** Medium, changes existing APIs rather than adding "even more
overloads" though this risk was discussed in the team and accepted. This
has a potential to be source breaking it someone used Task.init and
friends as function.
**Testing**: CI testing, source compatibility suite testing
**Reviewed by**: 

**Original PR:** 
- https://github.com/swiftlang/swift/pull/81107 build changes required
for this
- https://github.com/swiftlang/swift/pull/80984


**Radar:**

---------

Co-authored-by: Kuba Mracek <mracek@apple.com>
2025-05-29 07:52:33 +09:00
Pavel Yaskevich
f404274e6d [Concurrent] Restored old symbol for obsoleted Task.startSynchronously
https://github.com/swiftlang/swift/pull/80821 added `@isolated(any)`
which is an ABI breaking change but since we are not planning to keep
this API around, let's use `@_silgen_name` to bring the old name back
for now.

Resolves: rdar://152178221
2025-05-29 06:48:31 +09:00
Konrad 'ktoso' Malawski
fa817f951d [Concurrency] Correct the signing of priority escalation handler 2025-05-23 17:06:12 -07:00
Pavel Yaskevich
5997a4dec4 [stdlib] Adopt @_inheritActorContext(always) on Task.immediate
This change aligns implementation with the current SE-0472 proposal.

(cherry picked from commit c3c1b4fca0)
(cherry picked from commit 8c05636e28)
(cherry picked from commit 0598b8c9f4)
2025-05-22 11:32:37 -07:00
Mike Ash
b319e4eaf0 Merge pull request #81616 from mikeash/error-object-weak-reference-6.2
[6.2][Runtime] Allow weak references to ErrorObjects.
2025-05-20 20:49:06 -04:00
Mike Ash
736337dceb [6.2][Runtime] Allow weak references to ErrorObjects.
When ObjC interop is not available, Error values are represented in ErrorObject boxes. These are full HeapObjects, but unowned refcounting ops asserted that the metadata was class metadata. This assert would be hit when destroying an ErrorObject that was weakly referenced. Expand the asserts to accept ErrorObject metadata as well.

rdar://150214921
(cherry picked from commit aea9c0c65a)
2025-05-19 15:21:45 -04:00
Allan Shortlidge
2d96b24e57 Embedded: Suppress spurious unused result warnings.
The results of `swift_retain(object:)` and `swift_bridgeObjectRetain(object:)`
should be discardable since it's typcial to not need the pointer returned from
these calls. Suppresses unused result warnings that were generated previously.
2025-05-19 09:24:53 -07:00
Allan Shortlidge
98951af301 CompatbilitySpan: Add a missing @unsafe.
The missing attribute was causing "no unsafe expressions" warnings elsewhere
when building the CompatibilitySpan library.
2025-05-19 09:24:41 -07:00
Allan Shortlidge
63adabb7ef Concurrency: Address new -strict-memory-safety warnings. 2025-05-19 09:24:13 -07:00
Alastair Houghton
77a9aa2089 [Cxx] Build the C++ interop support library for the Static SDK for Linux.
We need the C++ interop support library to make the build work, as
the Runtime module uses C++ interop.

(Also, we should build it, because some user programs might want to
use C++ interop.)

rdar://147201087
2025-05-15 14:30:37 +01:00
Pavel Yaskevich
b2e962068d [stdlib] Temporarily bring back Task.startSynchronously as deprecated
(cherry picked from commit 99d810aa7d)
2025-05-13 20:11:28 -07:00
Pavel Yaskevich
2bf00077e4 [stdlib] SE-0472: Rename Task and*TaskGroup APIs to match the proposal
`Task.startSynchronously` -> `Task.immediate`
`*TaskGroup.startTaskSynchronously{UnlessCancelled}` -> `*TaskGroup.addImmediateTask{UnlessCancelled}`

(cherry picked from commit 001eab867d)
2025-05-13 20:11:28 -07:00
Konrad 'ktoso' Malawski
910bc1a1a3 [Concurrency] Improve in order synchronous enqueue of startSynchronously
Previously there was still a sneaky hop which caused ordering issues.
This introduced a specific test startSynchronously_order which checks
that the task enqueues indeed are "immediate" and cleans up how we
handle this.

This also prepares for the being discussed in SE review direction of
this API that it SHOULD be ALLOWED to actually hop and NOT be
synchronous at all IF the isolation is specified on the closure and is
DIFFERENT than the callers dynamic isolation.

This effectively implements "synchronously run right now if dynamically
on the exact isolation as requested by the closure; otherwise enqueue
the task as usual".

resolves rdar://149284186
cc @drexin

(cherry picked from commit a24a28c217)
2025-05-13 20:10:35 -07:00
Alastair Houghton
02c160cdac Merge pull request #81335 from al45tair/eng/PR-148899609-6.2
[Concurrency] Don't pass negative times to the Dispatch code.
2025-05-13 11:29:35 +01:00
Doug Gregor
1072dbebb5 Merge pull request #81410 from swiftlang/egorzhdan/6.2-do-not-install-swiftmodules
🍒[cxx-interop] Do not install binary `.swiftmodule` files for the overlays
2025-05-12 19:28:38 -07:00
Devin Coughlin
2e941ef2db Merge pull request #81388 from hnrklssn/swiftify-anonymous-params-qual
[Swiftify] Emit @availability when expansions contain Span (#81320)
2025-05-12 17:29:18 -07:00
Egor Zhdan
10ab242b64 [cxx-interop] Do not install binary .swiftmodule files for the overlays
This fixes a deserialization failure in the compiler that occurred while loading the CxxStdlib overlay module:
```
Cross-reference to module 'Swift'
... Optional
... some
... with type <τ_0_0 where τ_0_0 : ~Copyable, τ_0_0 : ~Escapable> (Optional<τ_0_0>.Type) -> (τ_0_0) -> Optional<τ_0_0>
```

This was happening because the overlays were built against a different version of the Swift stdlib than is being used. The compiler is able to rebuild the Cxx and CxxStdlib modules from their textual interfaces. Let's use that feature unconditionally in production toolchains to avoid this kind of binary incompatibilities.

rdar://150416863
(cherry picked from commit 16b280862a)
2025-05-12 19:30:15 +01:00
Alastair Houghton
d6ce27b0e6 Merge pull request #81326 from al45tair/eng/PR-150753884
[Concurrency] Make initial executor construction fully thread safe.
2025-05-12 11:56:45 +01:00
Slava Pestov
874449374e RemoteInspection: Support for parameter packs 2025-05-09 14:50:19 -04:00
Slava Pestov
e2f10ed7ca RemoteInspection: Remove 'DidSubstitute' form of TypeRef::subst() 2025-05-09 14:50:16 -04:00
Nate Cook
c8c035ec32 [6.2][stdlib] Allow a default for optional interpolations (#81360)
Cherry-pick of #80547 for the 6.2 release branch.

---

Explanation: This cherry picks the implementation of SE-0477 to add a
string interpolation method with a `default:` parameter for optional
interpolation values.
Main Branch PR: https://github.com/swiftlang/swift/pull/80547
Risk: Low.
Reviewed By: @stephentyrone 
Resolves: rdar://150865613
Testing: New tests for the string interpolations and fix-its.
2025-05-09 12:10:58 -05:00
Henrik G. Olsson
f70676a340 [Swiftify] Emit @availability when expansions contain Span (#81320)
This prevents errors when compiling for older targets using a newer
compiler.

rdar://150740330
(cherry picked from commit 59d7d3160f)
2025-05-08 16:40:20 -07:00
3405691582
7a87fa5cbc Add a platform executor module for OpenBSD.
This is basically the same as the one for Linux, but it would be
somewhat awkward to add the platform conditional on a file named for
Linux when OpenBSD is not Linux.

Important note: if Dispatch is disabled, then this will cause a
compilation error (probably not just for OpenBSD either), because
PlatformExecutorFactory is both defined in PlatformExecutorNone.swift
and PlatformExecutor<...>.swift in this case.

Because this only bites OpenBSD bootstrap builds, and since OpenBSD
support has been upstreamed to Dispatch, default to the Dispatch
implementation for now to get this in, and we'll refactor in a different
pr.
2025-05-08 17:46:30 -04:00
Eric Miotto
6f696a4a75 Merge pull request #81165 from edymtt/edymtt/add-builtin-float-dep-to-distributed-and-synchronization-6.2
6.2: CMake: add explicit dependency to `_Builtin_float` to targets...
2025-05-08 12:07:41 -07:00
Guillaume Lessard
8d860936b2 Merge pull request #81225 from glessard/override-lifetime-publicly-6.2
[6.2, stdlib] make _overrideLifetime() functions public
2025-05-08 08:59:21 -07:00
Henrik G. Olsson
6861f2f4e4 [Swiftify] Don't use count from Span inside withUnsafeBufferPointer c… (#81316)
[Swiftify] Don't use count from Span inside withUnsafeBufferPointer c… (#81316)

Given a call like: ptr.withUnsafeBufferPointer { _ptrPtr in ... } ptr.count and _ptrPtr.count both contain the same value, but when ptr is a MutableSpan we get an error when referring to ptr inside a call to withUnsafeMutableBufferPointer, so we should use _ptrPtr.count instead.

rdar://150551109

[Swiftify] add _swiftifyOverrideLifetime for return Spans

std::span imports already have _cxxOverrideLifetime for their return
values. __counted_by needs the same, but Cxx may not be available at the
macro site, so we introduce _swiftifyOverrideLifetime in SwiftifyImport.

rdar://150569220
2025-05-07 21:06:45 -07:00
Guillaume Lessard
2942637f4a [stdlib] remove TODOs
These TODOs aren’t particularly actionable. What we really want is a way to define `_overrideLifetime()` in a not-unsafe way, and that will probably be a `Builtin` operation.
2025-05-07 17:14:08 -07:00
Guillaume Lessard
cae45f1584 [stdlib] make _overrideLifetime functions public
These are discussed in the lifetime annotations pitch: https://github.com/swiftlang/swift-evolution/pull/2750

Addresses rdar://150400414
2025-05-07 17:13:50 -07:00
Michael Gottesman
322a376432 Merge pull request #81334 from gottesmm/release/6.2-rdar150695113
[6.2][swift-settings] Now that we aren't using it immediately, remove it from tree.
2025-05-06 22:41:46 -07:00
Alejandro Alonso
2cc9fc61f4 Merge pull request #80855 from Azoy/62-value-generic-namelookup
[6.2] [NameLookup] Allow value generics to show up as static members
2025-05-06 20:55:07 -07:00
Michael Gottesman
e04e15f125 [swift-settings] Now that we aren't using it immediately, remove it from tree.
We can always get it back from the git history.

rdar://150695113
(cherry picked from commit 9d59dbed17)

Conflicts:
	include/swift/AST/DiagnosticsSema.def
	include/swift/Basic/Features.def
	test/abi/macOS/arm64/concurrency.swift
	test/abi/macOS/x86_64/concurrency.swift
2025-05-06 14:12:23 -07:00
Doug Gregor
68c7c85132 Merge pull request #81288 from swiftlang/revert-81127-pick-wip-inlinable-for-hashable-asyncstream
Revert "[6.2][Concurrency] Hashable funcs should be inlinable for AsyncStream"
2025-05-06 10:31:30 -07:00
Alastair Houghton
315d67c0e8 [Concurrency] Don't pass negative times to the Dispatch code.
Dispatch uses unsigned times, and cannot cope with times before its
clock started.  As such, passing negative times from Swift through to
the C++ code results in large unsigned values, which then causes us to
wait forever.  This is undesirable.

rdar://148899609
2025-05-06 16:31:05 +01:00
Alastair Houghton
418ae45ce2 [Concurrency] Make initial executor construction fully thread safe.
I had originally thought that we'd get away without this because the
executor construction generally happens in the async `main` function,
but of course if a program doesn't already use Swift Concurrency,
and someone uses it from a plug-in or library it loads, there's a
risk that we might have a race condition.

rdar://149346132
2025-05-06 11:50:07 +01:00
Evan Wilde
728e57c022 Merge pull request #81283 from etcwilde/ewilde/6.2-FreeBSDPlatformExecutor
[6.2 🍒]: Add platform executor module for FreeBSD
2025-05-05 20:51:20 -07:00
Alejandro Alonso
9204a94a62 Merge pull request #81169 from Azoy/wrap-in-feature
[stdlib] Wrap InlineArray inlinable code in new feature
2025-05-05 18:42:52 -07:00
Alejandro Alonso
12919a2300 Merge pull request #78248 from Azoy/value-generic-static-member
[NameLookup] Allow value generics to show up as static members
2025-05-05 18:42:15 -07:00
Eric Miotto
06a2001708 CMake: add explicit dependency to _Builtin_float to targets...
... that would import that as a result of importing Darwin from the SDK.

Amend my previous change to Differentiation and Distributed in this
sense.

Addresses rdar://150400049

(cherry picked from commit 8c7e8550aa)
2025-05-05 13:48:55 -07:00