From 82bd2df98657bfcacc4eed99ebd59f838be5a483 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Tue, 4 Jun 2019 21:49:05 -0700 Subject: [PATCH] Use Library::new() for windows (#4544) --- runtime/src/native_loader.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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()) {