Skip to content

[cxx-interop] Pull changes from swift-6 compat mode into swift-5.9 #72912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2024

Conversation

egorzhdan
Copy link
Contributor

@egorzhdan egorzhdan commented Apr 8, 2024

This gives projects using C++ interop compat mode 5.9 access to the new features such as virtual methods and move-only types.

rdar://126485814

@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Apr 8, 2024
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan
Copy link
Contributor Author

@swift-ci please test macOS

@hyp
Copy link
Contributor

hyp commented Apr 9, 2024

Swift-5.10 is not a valid interop version. Do you want to use 5.9 instead?

@egorzhdan egorzhdan force-pushed the egorzhdan/cxx-interop-compat-mode branch from 518cb0b to 19d8ea6 Compare April 15, 2024 12:02
@egorzhdan
Copy link
Contributor Author

🤦‍♂️ Right, thank you!

@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan changed the title [cxx-interop] Pull changes from swift-6 compat mode into swift-5.10 [cxx-interop] Pull changes from swift-6 compat mode into swift-5.9 Apr 15, 2024
@egorzhdan egorzhdan force-pushed the egorzhdan/cxx-interop-compat-mode branch 2 times, most recently from 9f1e8d1 to eca9ccc Compare April 15, 2024 15:34
@egorzhdan egorzhdan marked this pull request as ready for review April 15, 2024 15:34
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan
Copy link
Contributor Author

@swift-ci please test macOS

@fahadnayyar fahadnayyar self-requested a review April 15, 2024 18:23
@egorzhdan
Copy link
Contributor Author

Hmm, this only seems to fail on macOS, and only with a release compiler:

(invalid_conformance)<unknown>:0: error: fatal error encountered during compilation; please submit a bug report (https://swift.org/contributing/#reporting-bugs)
<unknown>:0: note: Invalid conformance in type-checked AST
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bootstrapping0/bin/swift-frontend -frontend -c /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/ApplySite.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/Argument.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/BasicBlock.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/Builder.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/Effects.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/ForwardingInstruction.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/Function.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/FunctionConvention.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/GlobalVariable.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/Instruction.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/Location.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/Operand.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/Registration.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/SILStage.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/SubstitutionMap.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/Type.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/Value.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/VTable.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/WitnessTable.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/Utilities/AccessUtils.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/Utilities/SequenceUtilities.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/Utilities/SmallProjectionPath.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/Utilities/WalkUtils.swift -supplementary-output-file-map /var/folders/bb/hcrjxg1s0b96pfst0ymhmp240000gn/T/supplementaryOutputs-334c25 -target x86_64-apple-macosx10.13 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -I /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bootstrapping0/bin/../lib -I /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib -I /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bootstrapping1/SwiftCompilerSources -color-diagnostics -O -cxx-interoperability-mode=default -validate-tbd-against-ir=none -disable-target-os-checking -min-runtime-version 5.9.2 -disable-implicit-string-processing-module-import -external-plugin-path /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/swift/host/plugins#/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/local/lib/swift/host/plugins#/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -plugin-path /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bootstrapping0/lib/swift/host/plugins -plugin-path /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bootstrapping0/local/lib/swift/host/plugins -Xcc -std=c++17 -Xcc -DCOMPILED_WITH_SWIFT -Xcc -DSWIFT_TARGET -Xcc -UIBOutlet -Xcc -UIBAction -Xcc -UIBInspectable -Xcc -UNDEBUG -Xcc -I -Xcc /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/llvm-project/llvm/include -Xcc -I -Xcc /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/build/buildbot_incremental/llvm-macosx-x86_64/include -Xcc -I -Xcc /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/llvm-project/clang/include -Xcc -I -Xcc /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/build/buildbot_incremental/llvm-macosx-x86_64/tools/clang/include -Xcc -I -Xcc /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/include -Xcc -I -Xcc /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/build/buildbot_incremental/swift-macosx-x86_64/SwiftCompilerSources/../include -target-sdk-version 14.2 -dwarf-version=4 -parse-as-library -module-name SIL -cross-module-optimization -o /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bootstrapping1/SwiftCompilerSources/SIL.o
1.	Apple Swift version 6.0-dev (LLVM a28c877176ffe52, Swift 567052f5bdf0824)
2.	Compiling with effective version 5.10
3.	While evaluating request ASTLoweringRequest(Lowering AST to SIL for module SIL)
4.	While silgen emitFunction SIL function "@$s3SIL7OperandV2eeoiySbAC_ACtFZ".
 for '==(_:_:)' (at /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/SIL/Operand.swift:30:10)

@egorzhdan
Copy link
Contributor Author

Ah! We're importing swift::Operand * _Nonnull op as UnsafeMutablePointer<swift.Operand> where swift.Operand is a non-copyable type, but the current version of the Swift stdlib doesn't yet support non-copyable generics, which means UnsafeMutablePointer<swift.Operand> isn't a valid type 🤯

egorzhdan added a commit that referenced this pull request Apr 16, 2024
…ble generics are disabled

C++ pointer type `T*` is generally imported as `Unsafe(Mutable)Pointer<T>`. However, if `T` is non-copyable in Swift (e.g. it has a deleted C++ copy constructor), using `UnsafePointer<T>` type requires noncopyable generics to be enabled.

This was causing assertion failures when building SwiftCompilerSources in #72912.
@egorzhdan egorzhdan force-pushed the egorzhdan/cxx-interop-compat-mode branch from b987e72 to c37a685 Compare April 16, 2024 15:57
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

egorzhdan added a commit that referenced this pull request Apr 16, 2024
… generics are disabled

C++ pointer type `T*` is generally imported as `Unsafe(Mutable)Pointer<T>`. However, if `T` is non-copyable in Swift (e.g. it has a deleted C++ copy constructor), using `UnsafePointer<T>` type requires noncopyable generics to be enabled.

This was causing assertion failures when building SwiftCompilerSources in #72912.
egorzhdan added a commit that referenced this pull request Apr 18, 2024
… generics are disabled

C++ pointer type `T*` is generally imported as `Unsafe(Mutable)Pointer<T>`. However, if `T` is non-copyable in Swift (e.g. it has a deleted C++ copy constructor), using `UnsafePointer<T>` type requires noncopyable generics to be enabled.

This was causing assertion failures when building SwiftCompilerSources in #72912.
egorzhdan added a commit that referenced this pull request Apr 23, 2024
… generics are disabled

C++ pointer type `T*` is generally imported as `Unsafe(Mutable)Pointer<T>`. However, if `T` is non-copyable in Swift (e.g. it has a deleted C++ copy constructor), using `UnsafePointer<T>` type requires noncopyable generics to be enabled.

This was causing assertion failures when building SwiftCompilerSources in #72912.
This gives projects using C++ interop compat mode 5.9 access to the new features such as virtual methods and move-only types.

rdar://126485814
@egorzhdan egorzhdan force-pushed the egorzhdan/cxx-interop-compat-mode branch from c37a685 to b330376 Compare April 24, 2024 10:54
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan merged commit 3fe8b71 into main Apr 24, 2024
@egorzhdan egorzhdan deleted the egorzhdan/cxx-interop-compat-mode branch April 24, 2024 16:54
egorzhdan added a commit that referenced this pull request Apr 24, 2024
… generics are disabled

C++ pointer type `T*` is generally imported as `Unsafe(Mutable)Pointer<T>`. However, if `T` is non-copyable in Swift (e.g. it has a deleted C++ copy constructor), using `UnsafePointer<T>` type requires noncopyable generics to be enabled.

This was causing assertion failures when building SwiftCompilerSources in #72912.

(cherry picked from commit 78eee32)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants