Stable interface to see content of abi stable module


(Carlo Kok) #1

Presuming I compile a shared object, dylib or static library with Swift. Is .swiftinterface the most stable way to see what's in it? If yes, is the format .swiftinterface final yet?

my use case:

I'm researching if I can interact with a swift library from another unrelated compiler and need to find out what's in a library.


(Jordan Rose) #2

That's the goal of the swiftinterface format, yes (cf. Plan for module stability). It's not quite final yet but we're pretty close, at least on the master branch. If you spot any omissions or errors in your experiments, please file a bug!


(Carlo Kok) #3

One thing that would be very useful for me and possibly for swift future proofing would be including the (object level) symbol names of types, accessors and methods. I realize I'm talking from a pov that makes it easier for me, but annotating the symbol names makes it possible to modify the mangling later for swift while keeping back/forward compatibility.


(Jordan Rose) #4

Interesting idea! It's tricky because there are manglings for things that don't have declarations in the base language, like Fooable & Barable (the composition type that includes both of these protocols as requirements), or Int: Equatable (the conformance of Int to Equatable). Because of that, the general plan is to consider mangling to be part of the ABI.

SourceKit can give you mangled names for declarations, though, and that ought to work with swiftinterface files (by importing the appropriate module so that they get loaded with their options intact, rather than reading them directly).


(Carlo Kok) #5

Fair enough. My goal will be to do this without source kit so I'll have to redo the mangling. Thanks for the info though.


(Joe Groff) #6

The mangling related parts of the compiler should hopefully be easily separable from the rest of the compiler, since they’re also shared by the Swift runtime and used by various tools outside the Swift compiler. You might try using our libraries instead of rolling your own implementation from scratch.