Avoid using unavailable RTLD_NODELETE flag on Android targets

This commit is contained in:
Anton Lazarev 2021-12-01 20:24:02 -08:00 committed by Michael Vines
parent 04c0f124c4
commit 60fe1d00e8
1 changed files with 5 additions and 1 deletions

View File

@ -123,7 +123,11 @@ impl NativeLoader {
fn library_open(path: &Path) -> Result<Library, libloading::Error> {
unsafe {
// Linux tls bug can cause crash on dlclose(), workaround by never unloading
Library::open(Some(path), libc::RTLD_NODELETE | libc::RTLD_NOW)
#[cfg(target_os = "android")]
let flags = libc::RTLD_NOW;
#[cfg(not(target_os = "android"))]
let flags = libc::RTLD_NODELETE | libc::RTLD_NOW;
Library::open(Some(path), flags)
}
}