druntime
druntime copied to clipboard
Warn unimplemented loadLibrary on Android
rt_loadLibrary and rt_unloadLibrary are unimplemented for Android. I don't know if this compiles because I can't compile it myself, but the idea should be fairly straightforward.
I don't know about the build process of having pragma(lib) in runtime, but maybe pragma(lib, "android"); Could be required
After a quick look, they aren't implemented for Posix systems without shared-druntime support, so should yield a linker error when trying to use them (directly or indirectly). I think that's better than a runtime error, although a compile error would be best (but doesn't look feasible in this instance, for such a druntime-internal helper).
Well, it's not a runtime error, just a logged warning, even worse IMO. ;) - To be clear: this problem isn't really Android-specific (although it's one of the few platforms where LDC doesn't support a druntime .so, shared by all D binaries of the process - and getting that to work would probably require a total overhaul of our Android TLS emulation).
And it's only a problem when trying to load shared D libraries, as that requires extra work (registering TLS ranges with the GC, running module constructors etc.), where a dlopen alone isn't sufficient and is guaranteed to cause serious problems at some point. So when loading .so libs not containing D parts on Android, it's probably better to dlopen them directly, not going through Runtime.loadLibrary().
Agree with kinke. Changing the linker error into a runtime warning hides what would be a very serious bug. Better to keep the link error and let the user himself choose to use dlopen (and introduce the bug with D libs).