Commit Graph

184374 Commits

Author SHA1 Message Date
Gábor Horváth
22f5eb79aa Merge pull request #84152 from Xazax-hun/add-nullptr-to-metadata
[cxx-interop] Make the size of anonymous types metadata is unchanged
2025-09-09 10:44:07 +01:00
Gábor Horváth
67bc46d0d0 [6.2][cxx-interop] Fix duplicate symbol error with default arguments
Explanation: We synthesize a Swift function that only calls a C++ funtion that produces the default argument. We produce this function for each module that imports the C++ function with the default argument. This symbol needs to be public as it is created in the context of the Clang module and used from the Swift module. To avoid the linker errors, we always emit this function into the client which is also the right thing to do as the whole body is a single function call.
Issues: rdar://160182651
Original PRs: #82333
Risk: Low, this is merged to main in early July and no one complained
yet. And the change is straightforward.
Testing: Added a compiler test.
Reviewers: @egorzhdan
2025-09-09 10:17:44 +01:00
Eric Miotto
90ee0973f5 Merge pull request #84123 from edymtt/edymtt/build-cmake-if-unavailable-on-macos-6.2
[6.2] Build CMake on macOS if one is not preinstalled
2025-09-08 22:36:06 -07:00
Joe Groff
f3d3c5a898 SILGen: Use lowered function type parameters in objc-to-swift thunks for initializers.
Fixes a regression caused by the `self` declaration being given a `DynamicSelfType`
even though the formal type of the enclosing function sometimes still uses the
concrete base class type.

Fixes #83876 | rdar://158956768.
2025-09-08 10:52:01 -07:00
Charles Zablit
f2c3d97c54 [update-checkout] add a check for locked repositories 2025-09-08 17:27:55 +01:00
Charles Zablit
a1f70d608e [windows] update to the 6.1.2 toolchain in build.ps1 2025-09-08 11:59:19 +01:00
Mishal Shah
7ec75e941f Merge pull request #83981 from rjmansfield/cherrypick-rdar159305318
[6.2] [test] Update availability_returns_twice.swift for Darwin module refactoring.
swift-6.2-DEVELOPMENT-SNAPSHOT-2025-09-06-a
2025-09-05 15:32:57 -07:00
Mishal Shah
aade750788 Merge pull request #83978 from rjmansfield/cherrypick-rdar59305532
[6.2] [test] Import locale modules explicitly in PrintFloat.swift.gyb.
2025-09-05 15:32:35 -07:00
Egor Zhdan
0059c4250a Merge pull request #84090 from egorzhdan/egorzhdan/6.2-frt-indirection
🍒[cxx-interop] Pass foreign reference types with correct level of indirection
2025-09-05 21:47:16 +01:00
Max Desiatov
2e9e12a8bd [6.2] Build CMake on macOS if one is not preinstalled
We build CMake on all platforms (except Darwin for an unknown reason) if CMake is not preinstalled. Since CMake 4.0 regresses certain build configurations, there's currently no way to build on Darwin without installing an older CMake version 3.x manually. This can be simplified if we build a pinned version of CMake consistently on all platforms.

Addresses rdar://159939866

(cherry picked from commit 7db6c5ddaa)
2025-09-05 07:19:46 -07:00
Gábor Horváth
e58347e8d2 [6.2][cxx-interop] Basic support for anonymous structs with non-copyable fields
Explanation: Anonymous structs cannot be copied or moved, these operations only
can happen to their enclosing non-anonymous types. Stop trying to emit special
member functions and value witness tables for these structs. This fix is
required to unblock a high priority libc++ change that fixes an
unintended ABI break.
Issues: rdar://159928354
Original PRs: #84105
Risk: Medium. I believe this is the right change but hard to anticipate
if something depends on the presence of these operations (which is
likely to be a bug). But this is required to unblock an important libc++
fix.
Testing: Added a compiler test.
Reviewers: @rjmccall
2025-09-05 10:53:46 +01:00
Konrad `ktoso` Malawski
64e98e66d3 Merge pull request #83997 from ktoso/pick-nonisolatednonsending-by-default-and-distributed 2025-09-05 17:10:34 +09:00
Susana Monteiro
f592747d96 Merge pull request #84104 from susmonteiro/6.2-nonescapable-std-optional
🍒 [cxx-interop] Prevent crash when importing a std::optional of nonescapable
2025-09-05 00:53:32 +01:00
Konrad Malawski
0ab9f4f35e [Distributed] We're currently not using this isDistributedThunk func 2025-09-05 08:34:31 +09:00
Dario Rexin
5bc14ff7e6 Merge pull request #84007 from drexin/wip-159143492-6.2
[6.2][IRGen] Fix computation of spare bits for fixed arrays
2025-09-04 13:25:39 -07:00
Gábor Horváth
cbdeaec4b6 Merge pull request #84076 from Xazax-hun/os-objects-support-on-6.2
[6.2][cxx-interop] Properly support OS objects in reverse interop
2025-09-04 21:15:19 +01:00
Artem Chikin
fdaafd6a10 Merge pull request #84089 from artemcm/62_DepScanWorkersNoShareDiagEngine
[6.2 🍒][Dependency Scanning] Give each scanner worker a unique Diagnostic Engine
2025-09-04 12:42:42 -04:00
susmonteiro
29e5549e44 [6.2][cxx-interop] Prevent crash when importing a std::optional of nonescapable
When we tried to create a std::optional of a nonescapable type in Swift, the compiler would run into an assertion failure.
This is because std::optional has an anonymous union where one of its members would be of this nonescapable type.

Turns out that we were not handling anonymous unions with nonescapable members correctly.
Fields of anonymous unions are injected to the parent as IndirectFieldDecl, so we need to handle these indirect fields the same way we handle "normal" fields.

rdar://156704699
2025-09-04 16:21:21 +01:00
Gábor Horváth
209fecaba2 [6.2][cxx-interop] Properly support OS objects in reverse interop
Explanation:These objects are behind typedefs and user code supposed to
use the typedef names. We already have some logic in place for Obj-C
interop. Reuse the same logic for C++ to use the correct names.
Issues: rdar://150453489
Original PRs: #83670
Risk: Low, only OS object types are affected and they were problemtic
before the change.
Testing: Added a compiler test.
Reviewers: @egorzhdan
2025-09-04 10:56:24 +01:00
Gábor Horváth
3ba22e2ac0 Merge pull request #84080 from Xazax-hun/fix-rvalue-ref-virtual-on-6.2
[6.2][cxx-interop] Fix import virtual methods with rvalue ref params
2025-09-04 10:51:51 +01:00
Gábor Horváth
a2ced86c80 Merge pull request #84078 from Xazax-hun/simd-is-escapable-on-6.2
[6.2][cxx-interop] Handle vector types in escapability analysis
2025-09-04 10:50:32 +01:00
Gábor Horváth
4008d3031a Merge pull request #84077 from Xazax-hun/optional-cf-type-fix-on-6.2
[6.2][cxx-interop] Fix passing optional CoreFoundation types from Swift to C++
2025-09-04 10:49:23 +01:00
Gábor Horváth
cf97e8a5fe Merge pull request #84075 from Xazax-hun/inherited-ctors-lifetime-dependence-on-6.2
[6.2][cxx-interop] Do not define inherited copy/move operations
2025-09-04 10:48:17 +01:00
Gábor Horváth
4a394fcfbb Merge pull request #84073 from Xazax-hun/func-ptr-is-not-fragile-on-6.2
[6.2][cxx-interop] Do not consider function types fragile
2025-09-04 10:47:19 +01:00
Gábor Horváth
f114a1e60f Merge pull request #84053 from Xazax-hun/attr-hide-swift-decls-on-6.2
[cxx-interop] Add attribute to hide Swift declarations from interop
2025-09-04 10:37:36 +01:00
Artem Chikin
0fa722f41f [6.2][Dependency Scanning] Give each scanner worker a unique Diagnostic Engine
Otherwise, when multiple workers encounter a diagnostic simultaneously we can encounter races which lead to corrupted diagnostic data or crashes

Resolves rdar://159598539
2025-09-03 13:55:02 -07:00
Egor Zhdan
da96a98f45 [cxx-interop] Add missing // REQUIRES: executable_test (#83896)
(cherry picked from commit a782752131)
2025-09-03 20:42:24 +01:00
Egor Zhdan
8178aa8b65 [cxx-interop] Pass foreign reference types with correct level of indirection
When calling a C++ function that takes a reference to a pointer to a foreign reference type, Swift would previously pass a pointer to the foreign reference type as an argument (instead of a reference to a pointer), which resulted in invalid memory accesses.

This was observed when using `std::vector<ImmortalRef*>::push_back`.

rdar://150791778
(cherry picked from commit 0a766e59ce)
2025-09-03 20:42:06 +01:00
Dario Rexin
1a10f85782 [IRGen] Fix computation of spare bits for fixed arrays
rdar://159143492

Previously all bits after the spare bits of the first element were marked as spare bits. This caused enum tags to be stored in bits used by the payload.
2025-09-03 10:27:10 -07:00
Gábor Horváth
448cdce50c [6.2][cxx-interop] Fix import virtual methods with rvalue ref params
Explanation: We generate forwarding calls for virutal methods. These forwarding
calls had a type error when the original parameter had an rvalue reference type.
In those scenarios we need to insert a static cast to make the type checker happy.
Issues: rdar://154969620
Original PRs: #83453
Risk: Low, narrow fix.
Testing: Added a compiler test.
Reviewers: @egorzhdan
2025-09-03 12:41:53 +01:00
Gábor Horváth
a2f4aba7e0 [6.2][cxx-interop] Handle vector types in escapability analysis
Explanation: Whenever we have a vector type, the escpability depends on the
escapability of the element type. This will enable us to consider more type
like std::vector<simd::float3> as safe by default.
Issues: rdar://157141552
Original PRs: #83542
Risk: Low, narrow fix.
Testing: Added a compiler test.
Reviewers: @egorzhdan
2025-09-03 12:36:16 +01:00
Gábor Horváth
1861073cf1 [6.2][cxx-interop] Fix passing optional CoreFoundation types from Swift to C++
ExplanationThese types are passed around as reference counted pointers,
so the optional representation of them are nullable pointers.
Previously, we tried to wrap them in swift::Optional.
Issues: rdar://157667946
Original PRs: #83609
Risk: Low, the fix is narrow.
Testing: Added a compiler test.
Reviewers: @hnrklssn
2025-09-03 12:09:32 +01:00
Gábor Horváth
cda402c225 [6.2][cxx-interop] Do not define inherited copy/move operations
Explanationi: When inheriting constructors, we define the inherited ctors in the derived class. We should not do that for copy and move operations as these operations can never be invoked (the implicit/defined/deleted ctor in the derived class always takes precedence). This fixes an issue where the lifetime parameters are not getting inferred for these spurious constructor definitions. This should also save us from doing some redundant work in the importer.
Issues: rdar://153081347
Original PRs: #83694
Risk: Low, we do not import some ctors that can never be called.
Testing: Added a compiler test.
Reviewers: @egorzhdan
2025-09-03 11:30:03 +01:00
Gábor Horváth
95cf518be4 [6.2][cxx-interop] Do not consider function types fragile
Explanationion: Function pointer types wee always considered fragile in
C++ mode, this manifested as a regression when interfacing with glibc.
Issues: rdar://159184118
Original PRs: #84040
Risk: Low, this only removes a spurious error for library evolution.
Testing: Added a compiler test.
Reviewers: @egorzhdan
2025-09-03 11:18:05 +01:00
Konrad Malawski
838bc9ee67 [Concurrency/Distributed] ensure distributed thunks are @concurrent
Otherwise the "nonisolated nonsending by default" mode blows up as
distributed thunk signatures dont match expectations.

This undoes the fix from https://github.com/swiftlang/swift/pull/83940
and applies the fix on the synthesis side of the distributed thunks,
such that they are @concurrent always -- which keeps their old semantics
basically, regardless of what "default" mode we have.
2025-09-03 18:58:49 +09:00
Mishal Shah
d4c0b15956 Merge pull request #84065 from adrian-prantl/virtual-6.2
[demangling] make printGenericSignature virtual
swift-6.2-DEVELOPMENT-SNAPSHOT-2025-09-03-a swift-6.2-DEVELOPMENT-SNAPSHOT-2025-09-04-a
2025-09-02 15:24:17 -07:00
Charles Zablit
34db9e8d2e [demangling] make printGenericSignature virtual
(cherry picked from commit 6324f20318)
2025-09-02 15:20:25 -07:00
Mishal Shah
8d1b85f68e Merge pull request #83935 from swiftlang/shahmishal-patch-2
[6.2] Update the runtime version to 6.2
2025-09-02 10:05:27 -07:00
eeckstein
90e245a840 Merge pull request #84006 from eeckstein/fix-array-property-opt-6.2
[6.2] Optimizer: fix an ownership violation when duplicating loops
2025-09-02 18:52:35 +02:00
Gábor Horváth
fa65cc9b2b [cxx-interop] Add attribute to hide Swift declarations from interop
Explanation: We generate declarations in the C++ interop header with
"unavailable" annotations when we cannot export something to C++. These
declarations can collide with existing names. Previously, there were no
ways to resolve these name collisions. This PR introduces a new
attribute to hide declarations from the interop header.
Issues: rdar://158843666
Original PRs: #82616
Risk: Low, this adds a new, straightforward code path.
Testing: Added a compiler test.
Reviewers: @egorzhdan
2025-09-02 13:28:27 +01:00
Alejandro Alonso
f15d600460 Merge pull request #83953 from Azoy/62-extended-existentials
[6.2] [AST & Runtime] Correctly mangle extended existentials with inverse requirements
swift-6.2-DEVELOPMENT-SNAPSHOT-2025-08-30-a
2025-08-30 11:10:21 -07:00
Erik Eckstein
9081edd4c2 Optimizer: fix an ownership violation when duplicating loops
If a guaranteed value is used in a dead-end exit block and the enclosing value is _not_ destroyed in this block, we end up missing the enclosing value as phi-argument after duplicating the loop.
TODO: once we have complete lifetimes we can remove this check again.

rdar://159125605
2025-08-29 17:28:57 +02:00
Konrad Malawski
011d2d2edc [Concurrency/Distributed] nonisolated-nonsending by default breaks distributed thunks
the new NonisolatedNonsendingByDefault upcoming feature breaks remote
calls in distributed actors, because the expected isolation doesn't
match and the runtime swift_distributed_execute_target_resume will
crash.

This is a short term fix to unblock adopters, however preferably we
should mark the thunks as nonisolated(nonsending), though that seems to
be more involved.

resolves rdar://159247975
2025-08-29 16:38:10 +09:00
nate-chandler
5f20a5b8b5 Merge pull request #83962 from nate-chandler/cherrypick/release/6.2/rdar158149082
6.2: [AllocBoxToStack] Don't destroy in dead-ends.
swift-6.2-DEVELOPMENT-SNAPSHOT-2025-08-29-a
2025-08-28 14:26:38 -07:00
Ryan Mansfield
4cf02d9493 [6.2] [Test] Update availability_returns_twice.swift for Darwin module refactoring.
rdar://159305318
2025-08-28 14:11:00 -04:00
Ryan Mansfield
69d6e4477c [6.2] [test] Import locale modules explicitly in PrintFloat.swift.gyb.
Darwin module is being split up and will eventually stop importing
locale APIs.

rdar://159305532
2025-08-28 13:12:06 -04:00
Nate Chandler
5798e71baf [MemoryLifetimeVerifier] Permit leaks in dead-ends 2025-08-28 05:47:40 -07:00
eeckstein
6713168abd Merge pull request #83947 from eeckstein/fix-combine-apply-of-convertfunction-6.2
[6.2] SILCombine: fix `convert_function` -> `apply` peephole for generic function types
swift-6.2-DEVELOPMENT-SNAPSHOT-2025-08-28-a
2025-08-28 06:38:46 +02:00
eeckstein
90e599b174 Merge pull request #83946 from eeckstein/fix-simplify-alloc-stack-apply-6.2
[6.2] Optimizer: fix handling of dependent existential archetypes in `alloc_stack` and `apply` simplification
2025-08-28 06:38:32 +02:00
Allan Shortlidge
59fa85811b Merge pull request #83955 from tshortli/nsmanaged-attr-test-xcode26-6.2
[6.2] Tests: Update the nsmanaged-attr.swift test for the Xcode 26 SDKs
2025-08-27 18:57:39 -07:00