Skip to content

Conversation

egorzhdan
Copy link
Contributor

Most of the logic for C++ foreign reference types can be applied to C types as well. Swift had a compiler flag -Xfrontend -experimental-c-foreign-reference-types for awhile now which enables foreign reference types without having to enable C++ interop. This change makes it the default behavior.

Since we don't expect anyone to pass experimental-c-foreign-reference-types currently, this also removes the frontend flag.

rdar://150308819

@egorzhdan
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@Xazax-hun Xazax-hun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG!

@@ -864,11 +864,6 @@ def cxx_interoperability_mode :
SwiftSynthesizeInterfaceOption]>,
HelpText<"Enables C++ interoperability; pass 'default' to enable or 'off' to disable">;

def experimental_c_foreign_reference_types :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong feeling here, but in case someone used this their build now would fail due to unknown argument. Should we make it deprecated/noop for one release? I am also OK just removing it straight away.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a fair point, I just don't think anyone uses this flag at the moment. But I also don't feel strongly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather leave the flag and ignore it (or emit a deprecation message). I've mentioned this flag in various places, so I wouldn't be surprised if it was used somewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I brought back the flag, with a deprecation note.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other deprecated flags also trigger a diag::warn_flag_deprecated diagnostic. I think we should do the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

egorzhdan added a commit to swiftlang/swift-driver that referenced this pull request Jul 1, 2025
The flag is being removed in the compiler: swiftlang/swift#82680.

C foreign reference types will now be available unconditionally.

rdar://150308819
egorzhdan added a commit to swiftlang/swift-driver that referenced this pull request Jul 1, 2025
The flag is being removed in the compiler: swiftlang/swift#82680.

C foreign reference types will now be available unconditionally.

rdar://150308819
Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent!

@@ -864,11 +864,6 @@ def cxx_interoperability_mode :
SwiftSynthesizeInterfaceOption]>,
HelpText<"Enables C++ interoperability; pass 'default' to enable or 'off' to disable">;

def experimental_c_foreign_reference_types :
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather leave the flag and ignore it (or emit a deprecation message). I've mentioned this flag in various places, so I wouldn't be surprised if it was used somewhere.

@egorzhdan egorzhdan force-pushed the egorzhdan/enable-c-frt branch from 6349f78 to e801f0d Compare July 1, 2025 16:57
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

Most of the logic for C++ foreign reference types can be applied to C types as well. Swift had a compiler flag `-Xfrontend -experimental-c-foreign-reference-types` for awhile now which enables foreign reference types without having to enable C++ interop. This change makes it the default behavior.

Since we don't expect anyone to pass `experimental-c-foreign-reference-types` currently, this also removes the frontend flag.

rdar://150308819
@egorzhdan egorzhdan force-pushed the egorzhdan/enable-c-frt branch from e801f0d to 9178af3 Compare July 1, 2025 17:46
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan
Copy link
Contributor Author

@swift-ci please test Linux

@egorzhdan
Copy link
Contributor Author

@swift-ci please test macOS

@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan
Copy link
Contributor Author

@swift-ci please test Windows

2 similar comments
@egorzhdan
Copy link
Contributor Author

@swift-ci please test Windows

@egorzhdan
Copy link
Contributor Author

@swift-ci please test Windows

@egorzhdan
Copy link
Contributor Author

@swift-ci please test Windows

3 similar comments
@egorzhdan
Copy link
Contributor Author

@swift-ci please test Windows

@egorzhdan
Copy link
Contributor Author

@swift-ci please test Windows

@egorzhdan
Copy link
Contributor Author

@swift-ci please test Windows

@egorzhdan egorzhdan merged commit 569ca00 into main Jul 7, 2025
5 checks passed
@egorzhdan egorzhdan deleted the egorzhdan/enable-c-frt branch July 7, 2025 18:42
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.

4 participants