From 08c9ff730c649f88ae851ef7f5e1c3ff0298fa48 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sat, 17 Sep 2016 19:54:29 -0500 Subject: [PATCH] osx: link to dylib, windows: always return None --- gcc_s/src/lib.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/gcc_s/src/lib.rs b/gcc_s/src/lib.rs index b053a5b..fa034b0 100644 --- a/gcc_s/src/lib.rs +++ b/gcc_s/src/lib.rs @@ -8,17 +8,34 @@ use libloading::Library; static mut GCC_S: Option = None; +#[cfg(not(windows))] fn gcc_s() -> &'static Library { + #[cfg(not(target_os = "macos"))] + const LIBGCC_S: &'static str = "libgcc_s.so.1"; + + #[cfg(target_os = "macos")] + const LIBGCC_S: &'static str = "libgcc_s.1.dylib"; + unsafe { static INIT: Once = ONCE_INIT; INIT.call_once(|| { - GCC_S = Some(Library::new("libgcc_s.so.1").unwrap()); + GCC_S = Some(Library::new(LIBGCC_S).unwrap()); }); GCC_S.as_ref().unwrap() } } +#[cfg(windows)] +macro_rules! declare { + ($symbol:ident: fn($($i:ty),+) -> $o:ty) => { + pub fn $symbol() -> Option $o> { + None + } + } +} + +#[cfg(not(windows))] macro_rules! declare { ($symbol:ident: fn($($i:ty),+) -> $o:ty) => { pub fn $symbol() -> Option $o> {