Skip to content

Commit 6d648f3

Browse files
Rollup merge of #155815 - djc:swift-cc, r=jieyouxu
Add Swift function call ABI Adds an unstable `extern "Swift"` ABI behind the `abi_swift` feature gate, mapping to LLVM's `swiftcc` calling convention. This is only allowed (a) for `is_darwin_like` targets, since the [ABI is only stable for those platforms](https://www.swift.org/blog/abi-stability-and-more/) 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 rust-lang/rust#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.
2 parents 2f4c35e + 6f52550 commit 6d648f3

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/abi.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ pub fn conv_to_fn_attribute<'gcc>(conv: CanonAbi, arch: &Arch) -> Option<FnAttri
245245
// possible to declare an `extern "custom"` block, so the backend still needs a calling
246246
// convention for declaring foreign functions.
247247
CanonAbi::Custom => return None,
248+
// gcc/gccjit does not have anything for Swift's calling convention.
249+
CanonAbi::Swift => panic!("gcc/gccjit backend does not support Swift calling convention"),
248250
CanonAbi::Arm(arm_call) => match arm_call {
249251
ArmCall::CCmseNonSecureCall => FnAttribute::ArmCmseNonsecureCall,
250252
ArmCall::CCmseNonSecureEntry => FnAttribute::ArmCmseNonsecureEntry,

0 commit comments

Comments
 (0)