Using Swift ABI from Rust

My objrs crate is a collection of attribute macros that transforms Rust code so that it generates Objective-C compatible binaries. This makes some Rust and Swift interactions possible (via Rust :left_right_arrow: Objective-C :left_right_arrow: Swift), but not all. I’ve long been thinking of adding direct Swift support (assuming it’s feasible, which I suspect it is but haven’t actually dug into), but I don’t have time to work on both Swift and Objective-C right now.

Anyway, my point is that I think we should explore the Swift ABI from Rust via user land crates that use macros. If it works out, there might not be much need for core compiler support. If it doesn’t work, then that might help justify core compiler work.


The components that require compiler support include:

  • The LLVM calling convention.
  • The swiftself and (if support is desired) swifterror LLVM attributes.

Name mangling, and parameter exploding could probably be done externally.

So should a tracking issue be filled currently for these?


BTW, will it be possible if we create a new Rust grammar or Cargo configuration for exporting function as ABI convention specified by programmers? We can even allow crate authors to implement their own ABI’s, and this could be a nice solution to adapt ABI for other programming languages or runtime platforms. Just a random thought, feel free to be critical if there is a mistake :slight_smile:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.