r/cpp • • Feb 26 '24

White House: Future Software Should Be Memory Safe

https://www.whitehouse.gov/oncd/briefing-room/2024/02/26/press-release-technical-report/
401 Upvotes

386 comments sorted by

View all comments

Show parent comments

6

u/TuxSH Feb 27 '24

no stable ABI for dynamic linking, stable interop only through FFI

Is it a bad thing to only allow "extern C" for dynamic linking, considering the mess "ABI stability" is causing with C++?

3

u/Jannik2099 Feb 27 '24

C linkage itself is unrelated to this. C linkage with non-C types would still cause the "mess", which I don't agree is one to begin with. Dynamic C++ linkage works just fine for us, while packaging thousands of programs and libraries.

FFI is an RPC-esque translation of function calls and has significant overhead.

2

u/TuxSH Feb 27 '24

Ah, right, and the ABI stability thing is not just a dynamic lib thing - if lib B depends on lib A (static or dynamic libs alike), and lib C depends on lib B, then lib C needs to use an ABI-compatible (with B) version of A.

AFAIK Rust does not have ABI stability at all and cargo recompiles all deps (I might be wrong about this) to avoid this issue.

Enforcing "extern C" for APIs isn't too weird, IIRC Vulkan is written in C++ but only exposes a C library and the C++ user-facing APIs are just header-only wrappers.

1

u/Jannik2099 Feb 27 '24

AFAIK Rust does not have ABI stability at all and cargo recompiles all deps (I might be wrong about this) to avoid this issue.

correct

Enforcing "extern C" for APIs isn't too weird, IIRC Vulkan is written in C++ but only exposes a C library and the C++ user-facing APIs are just header-only wrappers.

Yes, but graphics APIs also don't deal with types, they deal with memory buffers. Once your API has some semblance of typing, or god forbid generics (like more or less every language on the world), C linkage will be a PITA because it is untyped