Add Swift function call ABI#155815
Conversation
|
r? @jieyouxu rustbot has assigned @jieyouxu. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
|
When will arguments be marked as |
So this is a bit experimental. I plan on looking into all the things (though in my free time, and thus slowly) needed to call into Swift from Rust, but I don't have a plan today. If you want a more concrete plan before merging this, I'd like hear some more detail (in the sense of, maybe a bullet list) of things that need to be done. |
|
To be clear, I'm not going to block this PR on figuring out By the way I noticed that a question of mine in the previous attempt hadn't been answered yet: #64582 (comment) https://github.com/swiftlang/swift/blob/main/docs/ABI/CallingConventionSummary.rst seems to suggest like the answer to my question is no it doesn't need a separate |
|
For something like adding a new ABI, it'd definitely need a RFC accepted prior to stabilization. There are mechanisms to support "land something unstably to gather impl experience to feed RFC design / explore edge cases", in this case I would expect to take the form of a lang experiment. That is, if there is a lang champion happy to champion this. Asked in #t-lang > Swift call ABI. |
|
To spell it out explicitly, the primary reason this is interesting is because there's a bunch of platform APIs that are only exposed over the Swift ABI, such as Existing solutions need users to write |
There was a problem hiding this comment.
Also, can you please expand on the motivations (in PR description or elsewhere) for adding a new Swift fn call ABI (unstable or not)? There was an earlier PR which this PR revives yes, but we would definitely like to know if the motivations and circumstances have changed since then.
E.g. Mads shared one such motivation in comment above, I'd be curious if you had the same motivations or additional/different ones.
It would also help a lot if the PR description could also be updated to include details like #155815 (comment).
@rustbot author
|
Reminder, once the PR becomes ready for a review, use |
|
@rustbot ready |
This comment has been minimized.
This comment has been minimized.
Adds an unstable `extern "Swift"` ABI behind the `abi_swift` feature gate, mapping to LLVM's `swiftcc` calling convention. Cranelift and GCC backends fall back to the platform default since they have no equivalent.
View all comments
Adds an unstable
extern "Swift"ABI behind theabi_swiftfeature gate, mapping to LLVM'sswiftcccalling convention. This is only allowed (a) foris_darwin_liketargets, since the ABI is only stable for those platforms and (b) with the LLVM backend, since the other backends don't support it.Current approaches to interoperability with Swift lower to Objective-C (or require a Swift stub exposing a C ABI), but that is an optional mapping on the Swift side that some newer Apple frameworks omit. It would be great to be able to more directly/natively be able to call into Swift code directly via its stable API (on Apple platforms at least).
Reimplements #64582 on top of current main. The main objection to the previous PR seemed to be that it needed an RFC, but there was pushback (which seems sensible to me) that an RFC could be deferred until stabilization.
I think this needs a tracking issue? Would be happy to write one up if/when there is a consensus that this will be merged.