From 98689d0ffb0a0e218d3b32201df59be9fa771830 Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Sun, 3 Jan 2021 11:26:01 -0800 Subject: [PATCH] libprivatezstd: Restrict symbol visibility similar to upstream We have to relax three symbols to dynamically link zstd(1), but the rest are the same. --- lib/libzstd/Makefile | 2 +- sys/contrib/zstd/lib/common/xxhash.h | 3 +++ sys/contrib/zstd/lib/dictBuilder/zdict.c | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/libzstd/Makefile b/lib/libzstd/Makefile index dcf6cd3c0281..5f7cd8248d88 100644 --- a/lib/libzstd/Makefile +++ b/lib/libzstd/Makefile @@ -36,7 +36,7 @@ SRCS= entropy_common.c \ WARNS?= 2 INCS= zstd.h CFLAGS+= -I${ZSTDDIR}/lib -I${ZSTDDIR}/lib/common -DXXH_NAMESPACE=ZSTD_ \ - -DZSTD_MULTITHREAD=1 + -DZSTD_MULTITHREAD=1 -fvisibility=hidden LIBADD= pthread PRIVATELIB= yes diff --git a/sys/contrib/zstd/lib/common/xxhash.h b/sys/contrib/zstd/lib/common/xxhash.h index eceb55d5e071..ff1fafe4cd22 100644 --- a/sys/contrib/zstd/lib/common/xxhash.h +++ b/sys/contrib/zstd/lib/common/xxhash.h @@ -141,6 +141,9 @@ typedef unsigned int XXH32_hash_t; typedef unsigned long long XXH64_hash_t; XXH_PUBLIC_API XXH32_hash_t XXH32 (const void* input, size_t length, unsigned int seed); +/* Begin FreeBSD - This symbol is needed by dll-linked CLI zstd(1). */ +__attribute__((visibility ("default"))) +/* End FreeBSD */ XXH_PUBLIC_API XXH64_hash_t XXH64 (const void* input, size_t length, unsigned long long seed); /*! diff --git a/sys/contrib/zstd/lib/dictBuilder/zdict.c b/sys/contrib/zstd/lib/dictBuilder/zdict.c index 79c522ef3679..057ff3f16da4 100644 --- a/sys/contrib/zstd/lib/dictBuilder/zdict.c +++ b/sys/contrib/zstd/lib/dictBuilder/zdict.c @@ -968,6 +968,9 @@ static size_t ZDICT_addEntropyTablesFromBuffer_advanced( } /* Hidden declaration for dbio.c */ +/* Begin FreeBSD - This symbol is needed by dll-linked CLI zstd(1). */ +ZSTDLIB_API +/* End FreeBSD */ size_t ZDICT_trainFromBuffer_unsafe_legacy( void* dictBuffer, size_t maxDictSize, const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples,