Commit Graph

17564 Commits

Author SHA1 Message Date
Allan Shortlidge
3f42ec25f9 Concurrency: Fix warnings about unused functions. 2024-11-13 09:51:29 -08:00
Egor Zhdan
c20a2bfade Merge pull request #77559 from swiftlang/egorzhdan/cxxstdlib-resilient
[cxx-interop] Make Cxx and CxxStdlib libraries resilient
2024-11-13 16:45:01 +00:00
Crazy凡
aeaa8ecadd [cxx-interop] Allow removing elements from std::set. 2024-11-13 23:16:45 +08:00
Evan Wilde
af58e6e875 Merge pull request #77566 from etcwilde/ewilde/stdlib-rebuild-all-the-defines
[CMake] Cleaning up macOS symbol list
2024-11-12 22:02:00 -08:00
Dario Rexin
735aa98aad Merge pull request #77569 from drexin/wip-139708680
[Runtime] Add entry for native swift objc reference to initWithTakeTa…
2024-11-12 19:29:28 -08:00
Artem Chikin
e96fc88e58 Merge pull request #77541 from artemcm/AddSwiftScanDepToEmbeddedStdLib
[CMake] Add a dependency on 'libSwiftScan' for 'swiftCore'
2024-11-12 15:58:33 -08:00
Dario Rexin
591c2cbb65 [Runtime] Add entry for native swift objc reference to initWithTakeTable in CVW runtime
rdar://139708680

The entry was missing in the function table, causing runtime crashes.
2024-11-12 15:12:19 -08:00
Guillaume Lessard
4a909c7cc8 Merge pull request #77549 from glessard/buffer-update-fromContentsOf-null-check-removal
[stdlib] Elide some null-pointer checks in UM[R]BP bulk-copy functions
2024-11-12 15:51:20 -05:00
Nate Cook
e12e968570 Add contains(_:) methods to (Closed)Range (#76891)
The _StringProcessing module provides a generic, collection-based
`contains` method that performs poorly for ranges and closed ranges.
This addresses the primary issue by providing concrete overloads
for Range and ClosedRange which match the expected performance for
these operations.

This change also fixes an issue with the existing range overlap tests.
The generated `(Closed)Range.overlap` tests are ignoring the "other"
range type when generating ranges for testing, so all overlap tests
are only being run against ranges of the same type. This fixes things
so that heterogeneous testing is included.
2024-11-12 11:47:24 -08:00
Evan Wilde
e160e23dde [CMake] Connecting more flags and options
Making a more in-depth pass over the definition macros and flags in
SwiftSource.cmake _add_target_variant_swift_compile_flags.
These are only flags that actually matter for swiftCore though. This
does not include concurrency flags.
2024-11-12 11:31:10 -08:00
Artem Chikin
58709e58e7 [CMake] Add a dependency on 'libSwiftScan' for 'swiftCore'
It appears that 'swiftCore' and following associated 'embedded-stdlib-*' targets may begin building before the libSwiftScan library has completed building, which may cause crashes if the compiler process building 'swiftCore' attempts to load it.

Resolves rdar://137674862
2024-11-12 10:05:47 -08:00
Egor Zhdan
703e479135 [cxx-interop] Make Cxx and CxxStdlib libraries resilient
This enables library evolution for the two libraries that form the Swift overlay for the C++ standard library.

rdar://129169673
2024-11-12 17:22:03 +00:00
Guillaume Lessard
54066b2562 Merge pull request #77548 from glessard/rdar139668469-not-immortal-vincible
[span] express correct lifetimes for initializers
2024-11-12 07:40:41 -05:00
Guillaume Lessard
a50260b181 [stdlib] Avoid unnecessary null-pointer checks in UM[R]BP bulk-copy functions 2024-11-11 23:57:47 -05:00
Guillaume Lessard
76d22cc675 [span] correctly express lifetimes for initializers 2024-11-11 23:31:16 -05:00
Henrik G. Olsson
0678829cf7 Add @PointerBounds macro (#76969)
Add @PointerBounds macro

@PointerBounds is a macro intended to be applied by ClangImporter when
importing functions with pointer parameters from C headers. By
leveraging C attributes we can get insight into bounds, esapability, and
(eventually) lifetimes of pointers, allowing us to map them to safe(r)
and more ergonomic types than UnsafePointer.

This initial macro implementation supports CountedBy and Sizedby, but
not yet EndedBy. It can generate function overloads with and without an
explicit count parameter, as well as with UnsafeBufferPointer or Span
(if marked nonescaping), and any of their combinations. It supports
nullable/optional pointers, and both mutable and immutable pointers.
It supports arbitrary count expressions. These are passed to the macro
as a string literal since any parameters referred to in the count
expression will not have been declared yet when parsing the macro.

It does not support indirect pointers or inout parameters. It supports
functions with return values, but returned pointers can not be bounds
checked yet.

Bounds checked pointers must be of type Unsafe[Mutable]Pointer[?]<T>
or Unsafe[Mutable]RawPointer[?]. Count expressions must conform to
the BinaryInteger protocol, and have an initializer with signature
"init(exactly: Int) -> T?" (or be of type Int).

rdar://137628612

---------

Co-authored-by: Doug Gregor <dgregor@apple.com>
2024-11-11 14:54:25 -08:00
Artem Chikin
60538d5918 Revert "Attempt to reduce the number of embedded stdlib targets being built simultaneously."
This reverts commit dfa1bdb1ce.
2024-11-11 14:42:59 -08:00
Tim Kientzle
694c533c7f Merge pull request #77496 from tbkka/tbkka-rdar138132321
[ObjC Bridging] Consistently bridge block types verbatim
2024-11-11 08:41:56 -08:00
Artem Chikin
f7013099c5 Merge pull request #77495 from swiftlang/artemcm/FewerEmbeddedStdLibParallelTasks
Attempt to reduce the number of embedded stdlib targets being built simultaneously.
2024-11-08 21:49:43 -08:00
Artem Chikin
dfa1bdb1ce Attempt to reduce the number of embedded stdlib targets being built simultaneously.
We are seeing strange crashes during embedded stdlib build stage on Ubuntu 24.04. These crashes only seem to occur when we dispatch many stdlib emit-module tasks at the same time. While we root-cause it, this change attempts to slow down the process to only two Embedded StdLib tasks at-a-time.

Workaround for rdar://137674862
2024-11-08 13:55:14 -08:00
Tim Kientzle
c262248a27 [ObjC Bridging] Consistently bridge block types verbatim
A `@convention(block)` closure in Swift is completely compatible with Objective-C
and does not need to be wrapped in a `__SwiftValue` box for use.

Previously, it was bridged verbatim when appearing by itself, but
could end up boxed when it went through array bridging.

The test verifies that:
* Objective-C does not see a `__SwiftValue` box
* Swift `type(of:)` does not see a `__SwiftValue` box
* Objective-C can actually call the closure

Resolves rdar://138132321
2024-11-08 13:49:21 -08:00
Ian Anderson
052cc2ec0d Merge pull request #77349 from ian-twilightcoder/clang-headers-need-modulemaps
[CMake] clang-builtin-headers needs to copy the module maps as well as the headers
2024-11-08 12:25:48 -08:00
Guillaume Lessard
20b85ed59d Merge pull request #76406 from glessard/rdar96837923-span 2024-11-07 18:25:49 -08:00
Dario Rexin
4ea0c9bbee Merge pull request #77431 from drexin/wip-138487964
[IRGen+Runtime] Fix tag bit mask handling for objc, unknown objects a…
2024-11-07 15:55:08 -08:00
Mike Ash
c0d64ba850 Merge pull request #77427 from mikeash/lazy-realization-weak-check
[Runtime] Weak-check _objc_supportsLazyRealization.
2024-11-07 17:45:46 -05:00
Guillaume Lessard
4fe9328b65 [span] follow the leading underscore rule
Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2024-11-07 12:40:16 -08:00
Guillaume Lessard
386f041aa8 [span] fix an argument label
Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2024-11-07 12:39:12 -08:00
Guillaume Lessard
0922b6b622 [span] improve argument labels for safe initializers 2024-11-07 11:19:28 -08:00
Guillaume Lessard
9a8f5a7e9d [span] update more doc-comments 2024-11-07 11:18:40 -08:00
Dario Rexin
3c7b556cf1 [IRGen+Runtime] Fix tag bit mask handling for objc, unknown objects and blocks
rdar://138487964

On platforms that don't have reserved bits in objc (including unknown) pointers, we use the spare bits for Swift enums, so they have to be masked out. Blocks don't have reserved bits on any platform.
2024-11-07 09:55:40 -08:00
Jaap Wijnen
ccfbc38ef5 mark multiple autodiff related array methods as inlinable for increased specialization possibilities (#75778)
Co-authored-by: Jaap Wijnen <jaap@passivelogic.com>
2024-11-07 07:20:35 -08:00
Guillaume Lessard
6272ad66a0 [span] address review feedback 2024-11-06 22:48:28 -08:00
Christian
023590a566 Improved Error._domain calculation (#77369) 2024-11-06 15:09:55 -08:00
Mike Ash
7ef7f99490 [Runtime] Weak-check _objc_supportsLazyRealization.
It may not be available at runtime even if it was present at build time, so add a WEAK_CHECK/WEAK_USE to it.
2024-11-06 15:47:15 -05:00
Meghana Gupta
20eff53585 Revert "Make Atomic.deinit @_transparent"
This reverts commit dd037f896f.

@_transparent on deinit was diagnosed as an error in older compilers

Making Atomic.deinit @_transparent will break compiling newer sdk with older compilers

Fixes rdar://139194948
2024-11-05 14:58:04 -08:00
Dario Rexin
47265438b7 Merge pull request #77383 from drexin/wip-139106139
[IRGen+Runtime] Differentiate between pure Swift and regular ObjC ref…
2024-11-05 11:20:22 -08:00
Saleem Abdulrasool
c4266f6c9c Merge pull request #77360 from wabiverse/wabi-interop-vcruntime-modulemap
Fix typos in VCRuntime modulemap.
2024-11-05 10:21:53 -08:00
Dario Rexin
4e7ce5a058 [IRGen+Runtime] Differentiate between pure Swift and regular ObjC references in CVW
rdar://139106139

Regular ObjC references do not have unused bits or extra inhabitants for storing enum tags, because they may be tagged pointers. However, ObjC classes that are implemented in Swift do, so we must differentiate between the two.
2024-11-04 18:52:26 -08:00
Mike Ash
fcdec961b0 Merge pull request #77306 from swiftlang/fix-getTaskId
[Concurrency] Fix getTaskId.
2024-11-04 20:03:19 -05:00
Meghana Gupta
c0a55e11d4 Merge pull request #77314 from meg-gupta/ossaflag
Remove -enable-ossa-modules for Synchronization and Distributed
2024-11-04 02:40:54 -08:00
Allan Shortlidge
26bd056852 stdlib: Add @_disfavoredOverload to various functions for Embedded.
Functions like `fatalError()` have overloads for Embedded Swift only that take
StaticString instead of String, since String is unavailable. Unfortunately,
many of these overloads create the opportunity for ambiguity in certain
contexts. The easiest way to avoid the ambiguities is to mark each of the
overloads taking `String` as `@_disfavoredOverload`. Another approach that
could work would be to remove the default arguments from the `String` variants
in Embedded Swift only, but that would create even more duplication of source
code so it doesn't seem worth it.
2024-11-02 10:41:08 -07:00
furby™
c68b0d8320 Fix typos in VCRuntime modulemap.
* https://github.com/swiftlang/swift/issues/77351

Signed-off-by: furby™ <devs@wabi.foundation>
2024-11-01 19:16:00 -06:00
Allan Shortlidge
f4df1a8e52 Merge pull request #77316 from tshortli/unavailable-in-embedded
Sema: Allow calls to @_unavailableInEmbedded functions in compatible contexts
2024-11-01 17:16:22 -07:00
Allan Shortlidge
686ef29e55 Concurrency: Avoid string interpolation in argument to fatalError().
In Embedded Swift, the `String` type is unavailable. This means that the
overload of `fatalError()` that takes a `String` is also unavailable. Specify a
`StaticString` in the setter for `TaskLocal.projectedValue` to satisfy this
constraint.
2024-11-01 13:03:29 -07:00
Ian Anderson
90a2bde994 [CMake] clang-builtin-headers needs to copy the module maps as well as the headers
When copying the clang builtin headers, the module maps need to go with them.

rdar://139084511
2024-11-01 11:24:10 -07:00
Kuba Mracek
d78be484fc [Concurrency] Avoid reinterpret_cast in Concurrency/Task.cpp, fixes crashes in libdispatch 2024-11-01 10:31:58 -07:00
Kuba Mracek
db94dc7d36 [Concurrency] Fix memory leak around mismatched refcounting in Concurrency 2024-10-31 21:43:02 -07:00
Meghana Gupta
dd037f896f Make Atomic.deinit @_transparent 2024-10-31 13:42:34 -07:00
Meghana Gupta
02a58738a0 Remove -enable-ossa-module for Synchronization and Distributed
These modules import Darwin which is not in ossa. -enable-ossa-modules
results in a one-time recompilation of dependencies when they are not in ossa.
This is not compatible with Explicit Build Modules when the original invocation
did not have -enable-ossa-modules.
2024-10-31 10:55:35 -07:00
Mike Ash
bb09297598 [Concurrency] Fix getTaskId.
We should build a 64-bit value from the two 32-bit Id fields, but we were shifting one field by the other. Coincidentally, this managed to produce the correct value until the ID goes beyond 2^32, but after that it's weird and wrong.
2024-10-30 16:53:48 -04:00