ABI stability for dynamically linked standard library

I've recently read the following article, which states, that type layouts could change between every two compiler invocations. Some posts in this forum confirm this statement. I was only aware about changing ABI between rustc versions. Doesn't this mean, that the entire prefer-dynamic compiler flag itself is flawed? Or how is e.g. the layout stability from the structs in std-lib upheld?

Do I need to wrap every i8 or &dyn MyTrait I want to pass from binary "A" to a dylib "B", if they are compiled separately with the same compiler version?

I don't know about the standard library specifically, but it is in general a good idea to have dynamically loaded libraries talk to other things over a C FFI based api. We recently received a related issue on the Tokio issue tracker here.

Thank you for your reply. So you suggest to even wrap types like String, Box or &references?

Well, Box and references are C FFI safe and their layout are guaranteed. String is not though.


I don't think so. That would be silly and break large swathes of Rust code, including the compiler and std itself.

You will probably get better responses from i.rl.o or Zulip because that's where the compiler people hang out.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.