From d026b1b226f97991cbf1994521fd1260eb27a762 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Thu, 3 Aug 2017 12:52:39 -0500 Subject: Fix weak linking of getentropy when compiling on older macOS (#3841) * Fix weak linking of getentropy when compiling on older macOS We use weak linking in macOS to determine if the getentropy symbol is available. However, to do that we need to have a declaration that states the function is __attribute((weak_import)) at compile time. On macOS 10.12 this is provided in sys/random.h, but on older macOS the declaration doesn't exist at all, so we need to forward declare it ourselves. * update a comment and a style nit --- src/_cffi_src/openssl/src/osrandom_engine.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/_cffi_src') diff --git a/src/_cffi_src/openssl/src/osrandom_engine.h b/src/_cffi_src/openssl/src/osrandom_engine.h index c400ea3e..077046d9 100644 --- a/src/_cffi_src/openssl/src/osrandom_engine.h +++ b/src/_cffi_src/openssl/src/osrandom_engine.h @@ -13,6 +13,9 @@ #ifdef __APPLE__ #include + /* To support weak linking we need to declare this as a weak import even if + * it's not present in sys/random (e.g. macOS < 10.12). */ + extern int getentropy(void *buffer, size_t size) __attribute((weak_import)); #endif #ifdef __linux__ -- cgit v1.2.3