Merged
Conversation
Even with -fvisibility=hidden added to CFLAGS, any symbol which is given a default visibility attribute ends up exported in the dynamic library. This happens through zstd_internal.h which defines ..._STATIC_LINKING_ONLY before including various header files, and is included for example in lib/common/pool.c. To avoid this, this patch distinguishes static and non-static APIs, by using ZSTDLIB_API only for the latter, and introducing ZSTDLIB_STATIC_API for the former. For now, both are exported, but non-static APIs can be hidden by overriding the definition ZSTDLIB_STATIC_API. lib/Makefile is modified to allow this using make CPPFLAGS_DYNLIB=-DZSTDLIB_STATIC_API=ZSTDLIB_HIDDEN In addition, API declarations are dropped from zstd_compress.c (they aren't needed there). Signed-off-by: Stephen Kitt <[email protected]>
Explicitly hide static symbols
now included from libzstd.mk
terrelln
approved these changes
Dec 2, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merge #2051 by @skitt after rebasing it.
The PR makes it possible to selectively disable
staticsymbols from the list of exposed symbols in the dynamic library.Static symbols remain exposed by
libzstdby default, as it's the historical policy.