-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Symbol visibility #1181
Comments
The reason is that these three variables are not in the main translation unit, in which they're merely declared There's no generic C language feature to fix this. But we can fix this in both GCC and clang by any of the following (in descending order of my personal preference).
In any case, |
I'm afraid you're chasing after some ghosts here because as far as I can tell from my tests it's perfectly possible to use the Notice that these exports aren't present in the linux shared libraries, only mingw. The problem as I see it is that mingw is currently using For me, making that switch (along with #1242) solves all current export problems that I'm aware of. diff --git a/include/secp256k1.h b/include/secp256k1.h
index 325f35eb..ed5bbc9a 100644
--- a/include/secp256k1.h
+++ b/include/secp256k1.h
@@ -148,3 +148,3 @@ typedef int (*secp256k1_nonce_function)(
/* Symbol visibility. See libtool manual, section "Windows DLLs". */
-#if defined(_WIN32) && !defined(__GNUC__)
+#if defined(_WIN32)
# ifdef SECP256K1_BUILD (Note that I haven't tested for Darwin though, it's possible that export visibility is different there) |
Hmm, it definitely does for me. The difference is more clear with Before:
After the patch:
Where the missing 3 are: |
Confirming that it works for me as well. And the |
Introduced in #1209. |
Nice. https://gcc.gnu.org/wiki/Visibility#How_to_use_the_new_C.2B-.2B-_visibility_support also suggests this. It would be nice to document this deviation from the libtool recommendation in the comment. Interestingly the gcc man page says
Yep, almost identical... |
Heh, I guess this is why:
Yeah, it would seem those docs are wrong, given that we're seeing obvious differences in behavior. It may be that default visibility is intended to be an alias for dllexport on windows, but if that's the case and this is a bug I doubt they'd change the behavior now. So I'd guess the best approach would be to submit an upstream PR to remove that line in the docs. |
Will do. I'll PR this as a fix, but I'll wait until the current PR onslaught slows down a bit to avoid piling on :) |
fd2a408 Set ARM ASM symbol visibility to `hidden` (Hennadii Stepanov) Pull request description: Solves one item in #1181. To test on arm-32bit hardware, run: ``` $ ./autogen.sh && ./configure --enable-experimental --with-asm=arm && make ``` On master branch (427bc3c): ``` $ nm -D .libs/libsecp256k1.so | grep secp256k1_fe 0000e2bc T secp256k1_fe_mul_inner 0000e8dc T secp256k1_fe_sqr_inner ``` With this PR: ``` $ nm -D .libs/libsecp256k1.so | grep secp256k1_fe | wc -l 0 ``` For reference, see https://sourceware.org/binutils/docs/as/Hidden.html. ACKs for top commit: theuni: ACK fd2a408. sipa: ACK fd2a408 Tree-SHA512: abf8ad332631672c036844f69c5599917c49e12c4402bf9066f93a692d3007b1914bd3eea8f83f0141c1b09d5c88ebc5e6c8bfbb5444b7b3471749f7b901ca59
bc7c8db abi: Use dllexport for mingw builds (Cory Fields) Pull request description: Addresses the first part of #1181. See the discussion there for more context and history. After this, all that remains is a (platform-independent) exports checker for c-i. Or perhaps a linker script or .def file could be tricked into testing as a side-effect. This should fix mingw exports, specifically hiding the following: `secp256k1_pre_g_128` `secp256k1_pre_g` `secp256k1_ecmult_gen_prec_table` This changes our visibility macros to look more like [gcc's recommendation](https://gcc.gnu.org/wiki/Visibility#How_to_use_the_new_C.2B-.2B-_visibility_support). Edit: Note that we could further complicate this by supporting `__attribute__ ((dllexport))` as well, though I didn't bother as I'm not sure what compiler combo would accept that but not the bare dllexport syntax. Edit2: As the title implies, this affects this ABI and could affect downstream libs/apps in unintended ways (though it's hard to imagine any real downside). Though because it's win32 only, I'm imagining very little real-world impact at all. ACKs for top commit: hebasto: re-ACK bc7c8db, only a comment has been adjusted since my recent [review](#1295 (review)), real-or-random: utACK bc7c8db Tree-SHA512: 378e15556da49494f551bdf4f7b41304db9d03a435f21fcc947c9520aa43e3c655cfe216fba57a5179a871c975c806460eef7c33b105f2726e1de0937ff2444e
Are we happy with a non-macOS solution? UPD. It seems, there is a solution... |
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
In certain cases, we export too many symbols:
CFLAGS=-fvisibility=default
, there's a few exported variables :secp256k1_ecmult_gen_prec_table
,secp256k1_pre_g
,secp256k1_pre_g_128
.s
assembly files are visible but none should be visible (solved by Set ARM ASM symbol visibility tohidden
#1242)tools/symbol-check.py
#1135)The text was updated successfully, but these errors were encountered: