diff --git a/runtime/src/native_loader.rs b/runtime/src/native_loader.rs index 9234968a86..bd0b8cb930 100644 --- a/runtime/src/native_loader.rs +++ b/runtime/src/native_loader.rs @@ -55,6 +55,17 @@ fn create_path(name: &str) -> PathBuf { } } +#[cfg(windows)] +fn library_open(path: &PathBuf) -> std::io::Result { + Library::new(path) +} + +#[cfg(not(windows))] +fn library_open(path: &PathBuf) -> std::io::Result { + // TODO linux tls bug can cause crash on dlclose(), workaround by never unloading + Library::open(Some(path), libc::RTLD_NODELETE | libc::RTLD_NOW) +} + pub fn entrypoint( program_id: &Pubkey, keyed_accounts: &mut [KeyedAccount], @@ -79,8 +90,7 @@ pub fn entrypoint( }; trace!("Call native {:?}", name); let path = create_path(&name); - // TODO linux tls bug can cause crash on dlclose(), workaround by never unloading - match Library::open(Some(&path), libc::RTLD_NODELETE | libc::RTLD_NOW) { + match library_open(&path) { Ok(library) => unsafe { let entrypoint: Symbol = match library.get(instruction_processor_utils::ENTRYPOINT.as_bytes()) {