Commit Graph

21803 Commits

Author SHA1 Message Date
Alastair Houghton
79f746e62d [Concurrency] Don't use ExecutorJob for task-to-thread model.
Task-to-thread model doesn't have `ExecutorJob`, so we can't use it;
however, we probably also don't need `_swift_createJobForTestingOnly`
there so just `#if` it out in that case.

rdar://155054460
2025-07-07 11:43:53 +01:00
Guillaume Lessard
36b5090a98 Merge pull request #82598 from glessard/rdar153654652-now-available
[stdlib] add `span` properties to the backdeployment library
2025-07-07 02:46:10 -07:00
Guillaume Lessard
9ac65cf735 [stdlib] fix some unsafe errors 2025-07-07 02:29:51 -07:00
Pavel Yaskevich
e108524d98 [Concurrency] Remove deprecated Task.startSynchronously API
This is the original spelling which was not accepted. We kept
it for a bit to give adopters time to switch but it's time to
remove it now.
2025-07-07 00:31:19 -07:00
Egor Zhdan
19c7884ec5 [cxx-interop] Allow creating Dictionary from std::map
This adds an initializer to `Swift.Dictionary` that takes an instance of `std::map` or `std::unordered_map`.

rdar://155050682
2025-07-05 21:54:11 +01:00
Doug Gregor
15123f5771 [Runtime] Don't fail conformances when the global actor hook is missing
When the concurrency library's "is current global actor" hook is not
available, assume that we are already executing on the right global
actor. This mimics the behavior of earlier standard libraries when
faced with an isolated conformance, as well as dealing with odd
configurations where the code might not load the concurrency library
yet

At the moment, WebAssembly ends up in this configuration because we
don't run the initialization for the concurrency library. That makes
this also a workaround for issue #82682 / rdar://154762027.
2025-07-05 08:50:26 -07:00
Alastair Houghton
57d056e1a3 Merge pull request #82457 from al45tair/external-executor-test-support
[Concurrency] Add functions to allow testing of external executors.
2025-07-04 09:52:57 +01:00
Konrad `ktoso` Malawski
ec8caf3cdd Remove the experimental @Task macro (#82437) 2025-07-03 10:15:21 -07:00
Guillaume Lessard
6c588dc908 Merge pull request #82701 from glessard/rdar154776967-generalize-expectNil
[stdlibUnittest] generalize `expectNil(_:)`
2025-07-03 01:16:24 -07:00
Alex Martini
c727b0e3bc Merge pull request #82635 from amartini51/typo_154473231
Fix repeated words in documentation

Fixes: rdar://154473231
2025-07-02 19:26:55 -07:00
Allan Shortlidge
ede7bdb5d7 Merge pull request #82671 from tshortli/zippered-miscompile-if-unavailable
SILGen: Fix `if #unavailable` mis-compile for zippered libraries
2025-07-02 16:05:51 -07:00
Stephen Canon
fddd8bd5b9 Mark the concrete SIMD/Scalar comparisons disfavored (#82686)
Adding the concrete versions (https://github.com/swiftlang/swift/pull/81892) introduced an ambiguity for concrete vec .<= .zero comparisons; previously the concrete SIMD .<= SIMD operation would win (because we didn't have a concrete overload for SIMD .<= SIMD.Scalar). We can restore the old behavior by marking these disfavored.
2025-07-02 11:59:07 -04:00
Alastair Houghton
fbd87591d0 [Backtracing][Linux] Ignore SHT_NULL sections.
The ELF specification says that if a section's type is set to `SHT_NULL`,
_none_ of the other fields are valid, so we shouldn't even be trying to
read the section name.

(We won't crash, because of how all of this code works, but we might
read an incorrect name.)

rdar://154837649
2025-07-02 14:35:16 +01:00
Konrad 'ktoso' Malawski
e32d221e2a [StdlibUnittest] Warn if no tests were executed 2025-07-02 19:38:50 +09:00
Doug Gregor
46572f80a2 Merge pull request #82661 from DougGregor/back-deploy-main-actor-isolated-deinit
[SE-0371] Back-deploy support for main-actor-isolated deinit
2025-07-01 20:50:19 -07:00
Doug Gregor
bfb62e1262 Don't implement swift_task_deinitOnExecutorMainActorBackDeploy in the task-to-thread model 2025-07-01 16:06:05 -07:00
Guillaume Lessard
987fedf46a [stdlibUnittest] generalize expectNil(_:) 2025-07-01 15:16:49 -07:00
Alastair Houghton
26878c98de [Concurrency] Add functions to allow testing of external executors.
Added a couple of functions to allow for the testing of executors that
aren't implemented inside the concurrency runtime itself.

rdar://154195821
2025-07-01 16:48:03 +01:00
Doug Gregor
f736677022 Switch to the appropriate C calling convention for pthread_main_np 2025-07-01 08:15:54 -07:00
Alastair Houghton
76f235154d Merge pull request #82624 from al45tair/eng/PR-154282813
[Backtracing][Linux] Fix crash handler for musl.
2025-07-01 11:17:28 +01:00
Luke Howard
451f309935 build with 64-bit time_t on 32-bit platforms (#82595)
It is good practice to build with 64-bit `time_t`/timeval on 32-bit
platforms to avoid the Y2038 issue. This is the default when building on
Yocto for armv7, for example. Unfortunately `suseconds_t` is not an
alias to a type of the correct width (unlike time_t).

Question: on release/6.1, tv_usec is assumed to be `Int32`, but on main
it is `Int`, but appears to be the same commit hash?

#### git blame main stdlib/public/Platform/Platform.swift

```
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 350) @available(SwiftStdlib 5.7, *)
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 351) extension timeval {
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 352)   @available(SwiftStdlib 5.7, *)
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 353)   public init(_ duration: Duration) {
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 354)     let comps = duration.components
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 355)   // Linux platforms define timeval as Int/Int
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 356)   self.init(tv_sec: Int(comps.seconds),
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 357)               tv_usec: Int(comps.attoseconds / 1_000_000_000_000))
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 358)   }
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 359) }
```

#### git blame release/6.1 stdlib/public/Platform/Platform.swift

```
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 455) @available(SwiftStdlib 5.7, *)
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 456) extension timeval {
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 457)   @available(SwiftStdlib 5.7, *)
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 458)   public init(_ duration: Duration) {
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 459)     let comps = duration.components
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 460) #if os(Linux)
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 461)   // Linux platforms define timeval as Int/Int
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 462)   self.init(tv_sec: Int(comps.seconds),
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 463)               tv_usec: Int(comps.attoseconds / 1_000_000_000_000))
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 464) #else
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 465)     // Darwin platforms define timeval as Int/Int32
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 466)     self.init(tv_sec: Int(comps.seconds),
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 467)               tv_usec: Int32(comps.attoseconds / 1_000_000_000_000))
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 468) #endif
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 469)   }
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 470) }
```
2025-06-30 18:19:32 -07:00
Doug Gregor
7789a0ce64 [SE-0371] Back-deploy support for main-actor-isolated deinit
When targeting a platform that predates the introduction of isolated
deinit, make a narrow exception that allows main-actor-isolated deinit
to work through a special, inlineable entrypoint that is
back-deployed. This implementation

  1. Calls into the real implementation when available, otherwise
  2. Checks if we're on the main thread, destroying immediately when
we are, otherwise
  3. Creates a new task on the main actor to handle destruction.

This implementation is less efficient than the implementation in the
runtime, but allows us to back-deploy this functionality as far back
as concurrency goes.

Fixes rdar://151029118.
2025-06-30 17:38:08 -07:00
Guillaume Lessard
5d4c445347 [stdlib] some span properties are more available 2025-06-30 17:13:35 -07:00
Stephen Canon
377c66b6e7 Replace some precondition with _precondition in the stdlib. (#82641) 2025-06-30 19:12:00 -04:00
Guillaume Lessard
f97961a86f [stdlib] fix _makeMutableAndUniqueUnchecked() 2025-06-30 16:05:00 -07:00
Henrik G. Olsson
e9ba8f8a03 Merge pull request #81855 from hnrklssn/swiftify-availability-check-sdk
[Swiftify] Adjust _SwiftifyImport invocation to align with the signature
2025-06-30 12:00:20 -07:00
Alastair Houghton
f2c820a35c Merge pull request #82563 from al45tair/eng/PR-154346018
[Concurrency] Prevent negative sleeps from sleeping forever.
2025-06-30 17:45:36 +01:00
Alex Martini
3928ddfeb4 Fix repeated text 2025-06-30 09:36:37 -07:00
Alastair Houghton
b498b39b79 [Backtracing][Linux] Fix crash handler for musl.
Musl's `clone()` wrapper returns `EINVAL` if you try to use `CLONE_THREAD`,
which seems a bit wrong (certainly it is in this particular application,
since we *really* don't care whether the thread is a valid C library
thread at this point).

Also properly support ELF images that are built with a base address other
than zero (this typically isn't an issue for dynamically linked programs,
as they will be relocated at runtime anyway, but for statically linked
binaries it's very common to set the base address to a non-zero value).

rdar://154282813
2025-06-30 14:21:27 +01:00
Konrad `ktoso` Malawski
396379ecbf Merge pull request #82227 from ktoso/wip-deprecate-extractisolation 2025-06-30 20:32:30 +09:00
Henrik G. Olsson
bd11926bf7 [Swiftify] Adjust _SwiftifyImport invocation to align with the signature
of the macro in the currently laoded macro module

Stdlib macros are shipped with the SDK, so we need to make sure that the
way we invoke the macro matches the version of the macro in the SDK.
This patch skips the `spanAvailability` parameter if it isn't present.
There's no good way to test this, because we will always pick up the
current macro in our llvm-lit test suite, but I've tested it manually.

rdar://152278292
2025-06-27 19:10:23 -07:00
David Smith
1a56da655f Native implementation of -lengthOfBytesUsingEncoding, plus handling ASCII-subset MacRoman in a few places (#81791)
Fixes rdar://154341146
2025-06-27 13:48:10 -07:00
Guillaume Lessard
96f6f5e25a Merge pull request #82442 from glessard/rdar147500261-utf8span-32bit 2025-06-27 08:18:46 -07:00
Alastair Houghton
80791035a3 [Concurrency] Prevent negative sleeps from sleeping forever.
Requests to sleep until a negative timestamp would result in sleeping
until `UINT64_MAX` nanoseconds from the start of the relevant clock,
which is about 585 years.

rdar://154346018
2025-06-27 11:15:05 +01:00
Ben Rimmington
1b1e9d4d80 [stdlib] Update InlineArray documentation (#82363)
Remove misleading big O notation from initializers.
2025-06-27 11:14:24 +01:00
Guillaume Lessard
4927c0c1c8 [stdlib] improve more accessor declarations 2025-06-26 14:57:21 -07:00
Guillaume Lessard
c8092f50d1 [stdlib] simplify borrowing accessors 2025-06-26 14:57:21 -07:00
Guillaume Lessard
bbfe648c54 [stdlib] improve accessor declarations 2025-06-26 14:57:21 -07:00
Alejandro Alonso
883716bd1a Merge pull request #80858 from Azoy/remove-wubp-inlinearray
[stdlib] Remove _withUnsafeBufferPointer APIs on InlineArray
2025-06-26 14:44:08 -07:00
Alastair Houghton
f7f4a19baf Merge pull request #82417 from al45tair/eng/PR-153531418
[Concurrency] Rename Dummy(Main|Task)Executor.
2025-06-26 10:53:57 +01:00
Guillaume Lessard
791dd4cb0a [stdlib] name your constants better
- computed properties have an ABI impact; a function is fine here
2025-06-25 22:01:28 -07:00
Alejandro Alonso
596b015994 Adjust ABI test and guard address of property 2025-06-25 14:08:53 -07:00
Alejandro Alonso
6953a7c6f9 Update InlineArray.swift 2025-06-25 14:00:16 -07:00
Alejandro Alonso
5ac3a655d4 Update InlineArray.swift 2025-06-25 14:00:15 -07:00
Alejandro Alonso
db13bf0802 Update InlineArray.swift 2025-06-25 14:00:14 -07:00
Alejandro Alonso
8058bd26f6 Remove underscored with buffer pointer APIs on InlineArray 2025-06-25 14:00:12 -07:00
Gábor Horváth
7f7a5b19eb Merge pull request #81024 from swiftlang/gaborh/fix-cpp-benchmarks
[cxx-interop] Reenable C++ benchmarks
2025-06-25 12:30:01 +02:00
Konrad `ktoso` Malawski
989ec93762 Merge branch 'main' into wip-deprecate-extractisolation 2025-06-25 16:57:52 +09:00
Guillaume Lessard
4a13c916d7 [stdlib] name your constants 2025-06-24 17:19:48 -07:00
Guillaume Lessard
e8f0d52fe2 [gardening] labels for conditional compilation markers 2025-06-24 17:10:37 -07:00