How does Carbon plan to handle shared/dynamic libraries and their interfaces (headers/module files in C++) #5315
Replies: 1 comment 5 replies
-
Hi! There are some interesting thoughts here, but to be transparent, we're still working on the 0.1 language. The roadmap has some timeline for this, and it's uncertain when we're going to dig more into the ABI. It's possible early versions of the language (i.e., 0.1 and 0.2) won't need to be able to make We do plan on having some way to define a stable ABI for things like .so files, although the shape of that isn't well defined (nor what language features would be allowed on the stable ABI). It might be file-level with limited language functionality inside, or perhaps it would be done through attributes on functions. Whether that has an effect of hiding private data isn't clear, and may have limits. Whatever that ends up, it will probably look a little like what you suggest: the compiler will need to know what's intended to be visible outside the shared library, because that's the stable ABI. I would suspect, though, that whatever is built would end up being maintained by developers. That could take the form of autogenerated code. In particular if there's a separate stable API based on a private API, it might make sense to have a tool that generates the stable API based on annotations in the private API file. That's something possible with C++, though could be a little inconvenient; Carbon's trying to do a little more to support language-aware tooling. Anyways, we expect some distinction for calls exposed on ABI boundaries, it's just too early to speak with much confidence about how that'll look. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I'm hoping this is the right place to discuss it but I am happy to be redirected if it's not. I've been keeping an eye on Carbon from a distance and this would be my first proper in-depth discussion about something within the language.
I'm here because I feel like when it comes to making and sharing dynamic libraries I don't think any language has quite got it right. For some background most of my opinion comes from my professional work where I work with confidential IP so any code we share has to be in the form of fully compiled code. But some of it will apply to more generic situations as well.
I mostly work in C++ where creating a shared binary ends up being more complex than I feel like it needs to be. There are three main issues I have:
So here is my idea/proposal to improve the process of making shared libraries (Disclaimer: not a compiler engineer, what I suggest might not be possible. These are just ideas from a C++ developer):
__GET__LIBRARY__API__()
or something similar when you load it and the user would be able to print a list of classes and functions you can use now it's loaded. Combine this with clever generics work and you could probably setup a whole plugin system with that information.Thanks for reading. Again, if this isn't the right place please feel free to direct me to the right place. All feedback is welcome. 🙂
Beta Was this translation helpful? Give feedback.
All reactions