Skip to content

Commit f0868a9

Browse files
Merge #1595: build: 45839th attempt to fix symbol visibility on Windows
447334c include: Avoid visibility("default") on Windows (Tim Ruffing) Pull request description: Fixes #1421. See code comments for rationale. Related meta-bug: #1181. This reminds me that we should move forward with #1359. ACKs for top commit: fanquake: ACK 447334c hebasto: ACK 447334c, tested on Ubuntu 24.04 using the following commands: theuni: ACK 447334c Tree-SHA512: aaa47d88fd1b1f85c3e879a2b288c0eb3beebad0cc89e85f05d0b631f83e58d5a324fb441911970865eaa292f6820d03a1b516d6e8de37a87510e2082acc6e28
2 parents 1fae76f + 447334c commit f0868a9

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

include/secp256k1.h

+12-2
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,15 @@ typedef int (*secp256k1_nonce_function)(
134134
* 1. If using Libtool, it defines DLL_EXPORT automatically.
135135
* 2. In other cases, SECP256K1_DLL_EXPORT must be defined. */
136136
# define SECP256K1_API extern __declspec (dllexport)
137+
# else
138+
/* Building libsecp256k1 as a static library on Windows.
139+
* No declspec is needed, and so we would want the non-Windows-specific
140+
* logic below take care of this case. However, this may result in setting
141+
* __attribute__ ((visibility("default"))), which is supposed to be a noop
142+
* on Windows but may trigger warnings when compiling with -flto due to a
143+
* bug in GCC, see
144+
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116478 . */
145+
# define SECP256K1_API extern
137146
# endif
138147
/* The user must define SECP256K1_STATIC when consuming libsecp256k1 as a static
139148
* library on Windows. */
@@ -143,11 +152,12 @@ typedef int (*secp256k1_nonce_function)(
143152
# endif
144153
#endif
145154
#ifndef SECP256K1_API
155+
/* All cases not captured by the Windows-specific logic. */
146156
# if defined(__GNUC__) && (__GNUC__ >= 4) && defined(SECP256K1_BUILD)
147-
/* Building libsecp256k1 on non-Windows using GCC or compatible. */
157+
/* Building libsecp256k1 using GCC or compatible. */
148158
# define SECP256K1_API extern __attribute__ ((visibility ("default")))
149159
# else
150-
/* All cases not captured above. */
160+
/* Fall back to standard C's extern. */
151161
# define SECP256K1_API extern
152162
# endif
153163
#endif

0 commit comments

Comments
 (0)