Weird dynamic linking behaviour on macOS


I made a crate a while ago for dynamically linking code:

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:

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?