Skip to content

Commit 6157556

Browse files
committed
lib: zstd: hide all sysbols to avoid conflicts
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
1 parent 2a64814 commit 6157556

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/zstd-1.5.7/build/cmake/lib/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,23 @@ if (ZSTD_BUILD_SHARED)
137137
endif ()
138138
if (ZSTD_BUILD_STATIC)
139139
add_library(libzstd_static STATIC ${Sources} ${Headers})
140+
#
141+
# Fluent Bit links libzstd statically while also loading libsystemd at
142+
# runtime. On platforms such as RHEL10, libsystemd itself links against
143+
# the system's shared libzstd. When our binary exports the bundled zstd
144+
# symbols with default visibility the dynamic linker may resolve
145+
# libsystemd's zstd calls to the bundled implementation instead of the
146+
# system one. The ABI between the two releases is not compatible which
147+
# ultimately leads to crashes when libsystemd frees its own ZSTD
148+
# structures via our symbols.
149+
#
150+
# Hide all symbols from the static archive so that the bundled library
151+
# cannot interpose the system copy used by libsystemd (or any other
152+
# consumer). This mirrors how we build the static archive on other
153+
# platforms and keeps the symbols internal to fluent-bit.
154+
set_target_properties(libzstd_static PROPERTIES
155+
C_VISIBILITY_PRESET hidden
156+
VISIBILITY_INLINES_HIDDEN YES)
140157
target_include_directories(libzstd_static INTERFACE $<BUILD_INTERFACE:${PUBLIC_INCLUDE_DIRS}>)
141158
list(APPEND library_targets libzstd_static)
142159
if (ZSTD_MULTITHREAD_SUPPORT)

0 commit comments

Comments
 (0)