logoalt Hacker News

pizlonatortoday at 5:50 AM1 replyview on HN

> Rust has full blown safe dynamic linking - so long as you use rust, and the the same compiler version, for everything.

This is UB in rust as far as I understand:

1) you compile bar using version 1.5 of libfoo.so at link/compile time

2) you update libfoo.so to version 1.6. It has a lot of changes, but is still source compatible and some kind of reasonable precautions were taken, like that struct layouts are the same

3) you run bar with the new libfoo.so version 1.6

This is UB even if you use the same compiler.

If this is UB then that’s not “full blown safe dynamic linking”.

Note that Fil-C does safely support this. This is safe in Fil-C even if you don’t take appropriate precautions (like if you change function signatures, change struct layouts, etc - it’ll still be safe and have well defined outcomes in Fil-C).


Replies

gpmtoday at 6:18 AM

What you're looking for is a stable ABI, not just dynamic linking. Honestly not sure if rust guarantees a stable ABI under some set of "reasonable" precautions... likely not but it's never been something I've needed when I've even wanted in the context of matching rust's other constraint of matching compiler versions.