]> git.ipfire.org Git - thirdparty/zstd.git/commit
Distinguish static symbols, allow hiding them 2501/head
authorStephen Kitt <steve@sk2.org>
Wed, 17 Feb 2021 19:24:21 +0000 (20:24 +0100)
committerStephen Kitt <steve@sk2.org>
Fri, 14 May 2021 17:41:59 +0000 (19:41 +0200)
commite81d5675479016e43ef410082df53c2d589615cf
treef948f118eca3464b12eafcef4de544d72c4663ab
parent06718087f816a705aa40820715d40b540dbe3575
Distinguish static symbols, allow hiding them

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 <steve@sk2.org>
lib/Makefile
lib/compress/zstd_compress.c
lib/zstd.h