Weird dynamic linking behaviour on macOS


#1

I made a crate a while ago for dynamically linking code: https://github.com/mistodon/dymod

It worked then on a Macbook Air running Sierra, but on my new machine running High Sierra, it wasn’t properly unloading the dylib - therefore changing the library and reloading it had no effect.

I eventually fixed it with this change: https://github.com/Mistodon/dymod/commit/1e4bdda831369542f12b53c6dd15cb252ea56b65

Basically, changing the crate-type of the dynamically loaded crate from dylib to cdylib. I can’t find much documentation on those two crate types, so I can’t tell if this is intended behaviour, a bug with macOS’s dynamic linker, or a bug in Rust itself.

Does anyone know why this might be occurring, or where to learn more about these crate types?