https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88150
--- Comment #16 from Martin Nowak <code at dawg dot eu> --- Regarding the dlopen/dlclose in handleForName, the semantics of RTLD_NOLOAD are so that it bumps the reference count if the library had been previously loaded. The sections module uses the handle as identifier to distinguish different DSOs and store metadata. Due to the self-registration mechanism of D DSOs (see _d_dso_registry) any D library remains loaded and (presumably) keeps the same handle if it is needed by the executable and loaded during startup. If a shared library is loaded dynamically, then the dlopen/dlclose actions will surround the calls to _d_dso_registry by the library, hence the handle should stay valid while until the DSO is unregistered. This is a lot of low-level plumbing (without going into private runtime linker structs) and semantics have been modeled after Linux and FreeBSD. If they differ on Solaris the code might indeed need some fixup. The RTLD_NOLOAD behavior of only inc-refing already loaded libs isn't well documented but seems like the only sensible one.