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

Don't specify visibility attributes for static libraries #2157

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

FooIbar
Copy link

@FooIbar FooIbar commented Apr 30, 2024

This was introduced in #1751 and will cause those symbols get exported when static libarchive is linked to a shared library.

@kientzle
Copy link
Contributor

kientzle commented May 5, 2024

CC: @evelikov

/*
* Static libraries on all platforms and shared libraries on non-Windows
* platforms that don't support visibility annotations.
*/
# define __LA_DECL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At a glance a few preexisting issues have contributed to this:

  • internal specifics __LA_DECL and by extension LIBARCHIVE_STATIC and __LIBARCHIVE_BUILD have made their way into the public headers

In one of my projects, I a) defined FOO_API symbol internally for non-win32 gnuc builds (stub elsewhere) and b) annotated the definition (aka c file). The windows (msvc or mingw) builds are using a .spec file listing the exported symbols.

This would be my top recommendation.

  • the existing if/else chain is borderline incomprehensive

If the above suggestion doesn't fly, something like the following should be much better IMHO.

#if defined foo_static
#define foo /* dummy */
#if defined _WIN32 // no need for __WIN32__ or cygwin
#elif defined libarchive_building
#define foo __declspec(dllexport) // no need for gnu variant, gcc 4.0 (and maybe earlier) supports the msvc syntax
#else
#define foo __declspec(dllimport) // ditto no need for gnuc/gcc check
#endif
#elif defined __GNUC__ && __GNUC__ >= 4 // this is the explicit recommendation by the GCC docs, over the manual in-configure checks 
#define foo __attribute...
#else
#define foo /* dummy */
#endif

Hope that helps.

@evelikov
Copy link
Contributor

evelikov commented May 7, 2024

@kientzle would love to hear you opinion if the former option is something the team is happy with.

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

Successfully merging this pull request may close these issues.

None yet

3 participants