build: Refactor visibility logic
This commit is contained in:
@@ -121,45 +121,38 @@ typedef int (*secp256k1_nonce_function)(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Symbol visibility. */
|
/* Symbol visibility. */
|
||||||
#if defined(_WIN32)
|
#if !defined(SECP256K1_API)
|
||||||
/* GCC for Windows (e.g., MinGW) accepts the __declspec syntax
|
# if defined(SECP256K1_BUILD)
|
||||||
* for MSVC compatibility. A __declspec declaration implies (but is not
|
/* On Windows, assume a shared library only if explicitly requested.
|
||||||
* exactly equivalent to) __attribute__ ((visibility("default"))), and so we
|
* 1. If using Libtool, it defines DLL_EXPORT automatically.
|
||||||
* actually want __declspec even on GCC, see "Microsoft Windows Function
|
* 2. In other cases, SECP256K1_DLL_EXPORT must be defined. */
|
||||||
* Attributes" in the GCC manual and the recommendations in
|
# if defined(_WIN32) && (defined(SECP256K1_DLL_EXPORT) || defined(DLL_EXPORT))
|
||||||
* https://gcc.gnu.org/wiki/Visibility. */
|
/* GCC for Windows (e.g., MinGW) accepts the __declspec syntax for
|
||||||
# if defined(SECP256K1_BUILD)
|
* MSVC compatibility. A __declspec declaration implies (but is not
|
||||||
# if defined(DLL_EXPORT) || defined(SECP256K1_DLL_EXPORT)
|
* exactly equivalent to) __attribute__ ((visibility("default"))),
|
||||||
/* Building libsecp256k1 as a DLL.
|
* and so we actually want __declspec even on GCC, see "Microsoft
|
||||||
* 1. If using Libtool, it defines DLL_EXPORT automatically.
|
* Windows Function Attributes" in the GCC manual and the
|
||||||
* 2. In other cases, SECP256K1_DLL_EXPORT must be defined. */
|
* recommendations in https://gcc.gnu.org/wiki/Visibility . */
|
||||||
# define SECP256K1_API extern __declspec (dllexport)
|
# define SECP256K1_API extern __declspec(dllexport)
|
||||||
# else
|
/* Avoid __attribute__ ((visibility("default"))) on Windows to get rid
|
||||||
/* Building libsecp256k1 as a static library on Windows.
|
* of warnings when compiling with -flto due to a bug in GCC, see
|
||||||
* No declspec is needed, and so we would want the non-Windows-specific
|
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116478 . */
|
||||||
* logic below take care of this case. However, this may result in setting
|
# elif !defined(_WIN32) && defined (__GNUC__) && (__GNUC__ >= 4)
|
||||||
* __attribute__ ((visibility("default"))), which is supposed to be a noop
|
# define SECP256K1_API extern __attribute__ ((visibility("default")))
|
||||||
* on Windows but may trigger warnings when compiling with -flto due to a
|
# else
|
||||||
* bug in GCC, see
|
# define SECP256K1_API extern
|
||||||
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116478 . */
|
# endif
|
||||||
# define SECP256K1_API extern
|
# else
|
||||||
# endif
|
/* On Windows, SECP256K1_STATIC must be defined when consuming
|
||||||
/* The user must define SECP256K1_STATIC when consuming libsecp256k1 as a static
|
* libsecp256k1 as a static library. Note that SECP256K1_STATIC is a
|
||||||
* library on Windows. */
|
* "consumer-only" macro, and it has no meaning when building
|
||||||
# elif !defined(SECP256K1_STATIC)
|
* libsecp256k1. */
|
||||||
/* Consuming libsecp256k1 as a DLL. */
|
# if defined(_WIN32) && !defined(SECP256K1_STATIC)
|
||||||
# define SECP256K1_API extern __declspec (dllimport)
|
# define SECP256K1_API extern __declspec(dllimport)
|
||||||
# endif
|
# else
|
||||||
#endif
|
# define SECP256K1_API extern
|
||||||
#ifndef SECP256K1_API
|
# endif
|
||||||
/* All cases not captured by the Windows-specific logic. */
|
# endif
|
||||||
# if defined(__GNUC__) && (__GNUC__ >= 4) && defined(SECP256K1_BUILD)
|
|
||||||
/* Building libsecp256k1 using GCC or compatible. */
|
|
||||||
# define SECP256K1_API extern __attribute__ ((visibility ("default")))
|
|
||||||
# else
|
|
||||||
/* Fall back to standard C's extern. */
|
|
||||||
# define SECP256K1_API extern
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Warning attributes
|
/* Warning attributes
|
||||||
|
|||||||
Reference in New Issue
Block a user