Skip to content

Conversation

Xazax-hun
Copy link
Contributor

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.

rdar://138513915

@Xazax-hun Xazax-hun force-pushed the gaborh/default-arg-duplicate-symbols branch 2 times, most recently from 2b5b09a to e24ce67 Compare June 30, 2025 07:23
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.

rdar://138513915
@Xazax-hun Xazax-hun force-pushed the gaborh/default-arg-duplicate-symbols branch from e24ce67 to 33e41f1 Compare June 30, 2025 07:24
@Xazax-hun
Copy link
Contributor Author

@swift-ci please smoke test

@Xazax-hun
Copy link
Contributor Author

@swift-ci please smoke test Windows

Copy link
Contributor

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

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

Thanks! Given that we don't expect usage of the old driver in production environments, I think this should be good to go. I only have one question.

@Xazax-hun Xazax-hun merged commit 11cb7e5 into main Jul 1, 2025
3 checks passed
@Xazax-hun Xazax-hun deleted the gaborh/default-arg-duplicate-symbols branch July 1, 2025 11:50
Xazax-hun added a commit to Xazax-hun/swift that referenced this pull request Sep 9, 2025
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: swiftlang#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
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