Commit Graph

21434 Commits

Author SHA1 Message Date
Doug Gregor
657adcb259 Merge pull request #77780 from DougGregor/willthrow-no-locks
Treat swift_willThrow(Typed) as not locking or performing allocation
2024-11-21 20:02:31 -08:00
Doug Gregor
eff9bacb1b Treat swift_willThrow(Typed) as not locking or performing allocation
Prior to throwing, Swift emits a call to `swift_willThrow(Typed)`,
which allows various diagnostic tools (such as debuggers and testing
libraries) to intercept errors at the point where they are initially
thrown.

Since `swift_willThrow(Typed)` can be hooked by arbitrary code at
runtime, there is no way for it to meet performance constraints like
@_noLocks or @_noAllocation. Therefore, in a function that has those
performance constraints specified, disable emission of the call to
`swift_willThrow(Typed)`.

Fixes rdar://140230684.
2024-11-21 10:18:57 -08:00
Egor Zhdan
fb529ff0ce [cxx-interop] Mark all CxxStdlib APIs as @_alwaysEmitIntoClient
The change in 269fc941 turned out not to be enough to solve linker errors when using the CxxStdlib overlay with a non-default C++ stdlib.

In addition to `@inlinable`, the Swift functions in the overlay need to be `@_alwaysEmitIntoClient` to prevent Swift from trying to link a program that uses libc++ on Linux against the CxxStdlib binary shipped in the toolchain.

rdar://138838506
2024-11-21 17:09:33 +00:00
Egor Zhdan
ad70dc836f Merge pull request #77746 from swiftlang/egorzhdan/always-emit-into-client
[cxx-interop] Mark all CxxStdlib APIs as `@inlinable`
2024-11-21 11:48:04 +00:00
Egor Zhdan
269fc941de [cxx-interop] Mark all CxxStdlib APIs as @inlinable
This is a requirement for being able to use the CxxStdlib overlay with a C++ standard library which is not the platform default, specifically libc++ on Linux.

The module would get rebuilt from its textual interface (`CxxStdlib.swiftinterface`) by the compiler whenever a custom C++ stdlib is used. Since the mangled names of C++ stdlib symbols differ across implementations (libc++ vs libstdc++), a Swift program that uses these overlay functions would fail to link, unless the definitions of these functions are available.

rdar://138838506
2024-11-20 22:33:18 +00:00
Andrew Trick
fe59764f31 Make Unsafe[Mutable]BufferPointer conform to BitwiseCopyable.
The Span interface requires this. It needs to be able to create dependencies on
UBP values without creating extra temporary copies.

This is only a temporary workaround for:

rdar://140291657 (ASTPrinter: print synthesized conformances on the type
definition, not as an extension)

Until that ASTPrinter bug is fixed, .swiftinterface files drop BitwiseCopyable
conformance on types that have conditionally ~Copyable generic parameters.
2024-11-20 12:27:23 -08:00
Andrew Trick
d7806ebb76 Span: Remove ownership modifiers and explicit copies from pointers.
Without this fix, the standard library source will break with shortly upcoming
compiler toolchain.

Never explicitly copy a pointer before passing it to an argument that is the
source of a lifetime dependency on the function's return value. That will always
raise a diagnostic error: depending on a temporary value is not the same as
depending on a variable. A temporary value's scope is only the current expression.

Also avoid using ownership modifiers for UnsafePointer. We don't want to treat
them like noncopyable types. They are simply values. Treating them like
noncopyable types creates a lot of overhead in the representation, which is
likely to interfere with diagnostics and optimization.
2024-11-20 11:44:18 -08:00
Kuba (Brecka) Mracek
3fdec2171f Merge pull request #77657 from kubamracek/embedded-more-stdlib
[embedded] Add back lazy collection operations, collection diffing and StaticBigInt to Embedded Stdlib
2024-11-19 15:03:31 -08:00
Egor Zhdan
242fe5cfac Merge pull request #77677 from swiftlang/egorzhdan/cxxstdlib-builtin-float
[cxx-interop] Declare CxxStdlib dependency on _Builtin_float
2024-11-19 12:57:53 +00:00
Meghana Gupta
92782a0e08 Add an initializer for Span without lifetime dependence
Without this, supported old compilers which don't recognize LifetimeDependence feature but
recognize the NonEscapableTypes feature will run into lifetime dependence inference errors
on the implicit initializer generated for the stdlib's swiftinterface
2024-11-18 18:09:19 -08:00
Meghana Gupta
5b5acc64e0 Promote Nonescapable types to a language feature 2024-11-18 18:09:17 -08:00
Meghana Gupta
ddd107911d Add -enable-experimental-feature LifetimeDependence to stdlib 2024-11-18 18:08:32 -08:00
Guillaume Lessard
807b543bad Merge pull request #77688 from glessard/span-gardening
[stdlib] Span gardening
2024-11-18 20:11:01 -05:00
Guillaume Lessard
9084af187f [span] remove the _elementsEqual() functions
We should only add them once they reach their final form.
2024-11-18 16:18:17 -05:00
Guillaume Lessard
9936393183 [span] temporarily add a feature guard 2024-11-18 15:45:07 -05:00
Guillaume Lessard
9073576e84 [span] formulate Span.withUnsafeBytes() better 2024-11-18 15:14:16 -05:00
Guillaume Lessard
2b916a10b3 [gardening] improves some comments in Span and RawSpan 2024-11-18 14:24:56 -05:00
Allan Shortlidge
c9c36732be stdlib: Enable upcoming MemberImportVisibility feature.
It was already supposed to be enabled, but I forgot to update the CMake when I
renamed the feature from ExtensionImportVisibility to MemberImportVisibility.

However, leave it disabled on the CxxStdlib module since the C++ standard
library's modularization varies a lot by platform, making it difficult to add
the right conditional imports.
2024-11-18 10:27:14 -08:00
Egor Zhdan
72425fa750 [cxx-interop] Declare CxxStdlib dependency on _Builtin_float
This fixes incremental builds of the overlay.

The CxxStdlib overlay re-exports the entire C++ standard library, which has headers that transitively include Clang builtin headers, bringing in the _Builtin_float module.

rdar://140036608
2024-11-18 13:01:31 +00:00
Kuba Mracek
0d4f91f271 [embedded] Add back lazy collection operations, collection diffing and StaticBigInt to Embedded Stdlib 2024-11-16 08:16:57 -08:00
John McCall
d8d70d9aac Add support for creating a task with a self-consuming task function.
Not used yet.
2024-11-15 22:51:57 -05:00
Konrad `ktoso` Malawski
45d15d1268 Merge pull request #76460 from finagolfin/ndk27 2024-11-15 17:50:40 +09:00
Artem Chikin
9cd689816c Revert "[NFC][CMake] Disable use of in-process 'libSwiftScan' queries when building the Standard Library" 2024-11-14 12:47:32 -08:00
Artem Chikin
201edb83f6 Merge pull request #77606 from artemcm/MoveLibSwiftScanOutOfTools
[CMake] Establish a dependency from standard library variants onto 'libSwiftScan'
2024-11-14 12:31:12 -08:00
Kuba (Brecka) Mracek
a680211a4f Merge pull request #77594 from kubamracek/embedded-int-parsing
[embedded] Enable integer parsing in Embedded Swift
2024-11-14 10:23:01 -08:00
Artem Chikin
338b9141e3 Move libSwiftScan from 'tools' to 'lib/Tooling'
'tools' should be reserved for executable tools.
2024-11-14 08:44:32 -08:00
Alastair Houghton
f2e48bd293 Merge pull request #76257 from AreaZR/e
Use instancetype for the benchmark and SwiftNativeNSObject
2024-11-14 14:18:00 +00:00
Egor Zhdan
f88b29bfdc Merge pull request #77445 from CrazyFanFan/feature_cxxset_remove
[cxx-interop] Allow removing elements from `std::set`.
2024-11-14 13:09:21 +00:00
Artem Chikin
419041163b Merge pull request #77601 from artemcm/DisableLibSwiftScanOnStdLib
[NFC][CMake] Disable use of in-process 'libSwiftScan' queries when building the Standard Library
2024-11-13 19:02:37 -08:00
artemcm
4deff61e11 [NFC][CMake] Disable use of in-process 'libSwiftScan' queries when building the Standard Library
Due to the ordering of our build system, we may encounter a race when building standard library variants using tools produced by Swift's 'tools' CMake build.
As a workaround, for now, ensure that the compiler building standard library variants does not rely on libSwiftScan built as part of 'tools'.
2024-11-13 23:15:08 +00:00
Allan Shortlidge
3914cdd425 Merge pull request #77578 from tshortli/warnings
stdlib/Concurrency: Resolve or suppress a bunch of warnings
2024-11-13 13:37:06 -08:00
Kuba Mracek
b370050dd0 [embedded] Enable integer parsing in Embedded Swift 2024-11-13 11:52:37 -08:00
Finagolfin
22833fbc54 [android] Update to LTS NDK 27c
Add a new bits/ header to the Android overlay, include runtime libraries that are
auto-extracted and listed many times to the list of libraries to be de-duplicated,
enable a C++ interop test that's working again, and update the doc with new
libraries that need to be available to run a simple executable.
2024-11-14 00:11:53 +05:30
Allan Shortlidge
1ee4924542 Concurrency: Suppress -Wcast-function-type-mismatch warnings. 2024-11-13 09:51:29 -08:00
Allan Shortlidge
806c60020c stdlib: Resolve an unused variable warning. 2024-11-13 09:51:29 -08:00
Allan Shortlidge
a549d0144e stdlib: Resolve -Wmissing-designated-field-initializers warnings. 2024-11-13 09:51:29 -08:00
Allan Shortlidge
3f42ec25f9 Concurrency: Fix warnings about unused functions. 2024-11-13 09:51:29 -08:00
Allan Shortlidge
17fd27554b stdlib: Adopt internal imports to suppress some warnings in tests. 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