最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

rust - Are dynamic C libraries stable? - Stack Overflow

programmeradmin1浏览0评论

Apologise for the basic question. I have limited experience with C, more experienced writing C bindings in Rust.

I was learning about the Linux kernel, specifically the reasoning behind not offering a stable driver ABI and that sent me over to learn about how dynamic C libraries work in general.

One of the reasons cited was:

Depending on the version of the C compiler you use, different kernel data structures will contain different alignment of structures, and possibly include different functions in different ways (putting functions inline or not.) The individual function organization isn't that important, but the different data structure padding is very important.

Ignoring libraries built for specific processors and platforms, if I am understanding this correctly, it appears that dynamic C libraries are not compatible if the consumer is built using a different version of the C compiler, different compilers (GCC, Clang), and even different flags on the same compiler version.

Originally, I had viewed dynamic C libraries as a safe interlanguage target for libraries (write a library in Rust, offer a dynamic C library for consumers, the C library can then be consumed in Rust, Go, etc) - is this the case?

From experience, I know there are thousands of dynamic C libraries on my machine. If C ABI compatibility is so delicate, how have dynamic C libraries ever worked?

If I write a C library built with GCC, can I consume that from an application built with Clang?

If I consume (or write) a C library in Rust and the bindings adhere to the library's interface such that it works logically, can it fail to work due to unobvious ABI instability?

发布评论

评论列表(0)

  1. 暂无评论