Skip to content
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

Missing symbols when built with Clang -fvisibility=hidden #8

Closed
JamiKettunen opened this issue Nov 24, 2023 · 4 comments
Closed

Missing symbols when built with Clang -fvisibility=hidden #8

JamiKettunen opened this issue Nov 24, 2023 · 4 comments

Comments

@JamiKettunen
Copy link
Contributor

Building libglibutil 1.0.74 with LTO and -fvisibility=hidden (pre-requisite of CFI which I filed another issue about already and skipped all broken tests for the moment) I see libgbinder 1.1.35 failing to build due to various undefined symbols from libglibutil which were not marked as part of public API with a __attribute__((visibility("default"))) macro or similar:

ld: error: undefined symbol: gutil_log
>>> referenced by test_binder.c:367 (./unit/unit_bridge/../common/test_binder.c:367)
>>>               lto.tmp:(test_binder_node_unref.llvm.18437551932447681344)
>>> referenced by test_binder.c:336 (./unit/unit_bridge/../common/test_binder.c:336)
>>>               lto.tmp:(test_binder_node_unref.llvm.18437551932447681344)
>>> referenced by gbinder_client.c:210 (./src/gbinder_client.c:210)
>>>               lto.tmp:(gbinder_client_transact_sync_reply2)
>>> referenced 251 more times

Which for example this could be a naïve fix to:

--- a/include/gutil_log.h
+++ b/include/gutil_log.h
@@ -125,6 +125,7 @@ gutil_log_description(
     int count);                     /* Number of known modules */
 
 /* Logging function */
+__attribute__((visibility("default")))
 void
 gutil_log(
     const GLogModule* module,       /* Calling module (NULL for default) */

A bunch more can be seen in the full build log: https://paste.c-net.org/x0nhhzxganl3

https://clang.llvm.org/docs/LTOVisibility.html and https://gcc.gnu.org/wiki/Visibility could be of interest

@monich
Copy link
Member

monich commented Nov 24, 2023

I wonder if a linker script would help to remedy that and at the same time keep public headers clean 🤔

@monich
Copy link
Member

monich commented Nov 25, 2023

No, the version script doesn't seem to override the visibility 😐

@monich
Copy link
Member

monich commented Nov 27, 2023

PR #10 should take care of that.

@JamiKettunen
Copy link
Contributor Author

Seems to work for my purposes now; as I mentioned on the other issue same could now be done for libgbinder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants