Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions build/meson/lib/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,35 @@ libzstd = library('zstd',
libzstd_dep = declare_dependency(link_with: libzstd,
include_directories: libzstd_includes)

# we link to both:
# - the shared library (for public symbols)
# - the static library (for private symbols)
#
# this is needed because internally private symbols are used all the time, and
# -fvisibility=hidden means those cannot be found
if get_option('default_library') == 'static'
libzstd_static = libzstd
libzstd_internal_dep = libzstd_dep
else
if get_option('default_library') == 'shared'
libzstd_static = static_library('zstd_objlib',
objects: libzstd.extract_all_objects(recursive: true),
build_by_default: false)
else
libzstd_static = libzstd.get_static_lib()
endif

if cc_id == compiler_msvc
# msvc does not actually support linking to both, but errors out with:
# error LNK2005: ZSTD_<foo> already defined in zstd.lib(zstd-1.dll)
libzstd_internal_dep = declare_dependency(link_with: libzstd_static)
else
libzstd_internal_dep = declare_dependency(link_with: libzstd,
# the static library must be linked after the shared one
dependencies: declare_dependency(link_with: libzstd_static))
endif
endif

pkgconfig.generate(libzstd,
name: 'libzstd',
filebase: 'libzstd',
Expand Down
18 changes: 5 additions & 13 deletions build/meson/programs/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,12 @@ zstd_programs_sources = [join_paths(zstd_rootdir, 'programs/zstdcli.c'),
join_paths(zstd_rootdir, 'programs/benchzstd.c'),
join_paths(zstd_rootdir, 'programs/datagen.c'),
join_paths(zstd_rootdir, 'programs/dibio.c'),
join_paths(zstd_rootdir, 'programs/zstdcli_trace.c'),
# needed due to use of private symbol + -fvisibility=hidden
join_paths(zstd_rootdir, 'lib/common/xxhash.c'),
join_paths(zstd_rootdir, 'lib/common/pool.c'),
join_paths(zstd_rootdir, 'lib/common/zstd_common.c'),
join_paths(zstd_rootdir, 'lib/common/error_private.c')]

zstd_deps = [ libzstd_dep ]
join_paths(zstd_rootdir, 'programs/zstdcli_trace.c')]

zstd_deps = [ libzstd_internal_dep ]
zstd_c_args = libzstd_debug_cflags

zstd_frugal_deps = [ libzstd_dep ]
zstd_frugal_deps = [ libzstd_internal_dep ]
zstd_frugal_c_args = [ '-DZSTD_NOBENCH', '-DZSTD_NODICT', '-DZSTD_NOTRACE' ]

if use_multi_thread
Expand Down Expand Up @@ -82,10 +77,7 @@ zstd_frugal_sources = [join_paths(zstd_rootdir, 'programs/zstdcli.c'),
join_paths(zstd_rootdir, 'programs/timefn.c'),
join_paths(zstd_rootdir, 'programs/util.c'),
join_paths(zstd_rootdir, 'programs/fileio.c'),
join_paths(zstd_rootdir, 'programs/fileio_asyncio.c'),
join_paths(zstd_rootdir, 'lib/common/pool.c'),
join_paths(zstd_rootdir, 'lib/common/zstd_common.c'),
join_paths(zstd_rootdir, 'lib/common/error_private.c')]
join_paths(zstd_rootdir, 'programs/fileio_asyncio.c')]

# Minimal target, with only zstd compression and decompression.
# No bench. No legacy.
Expand Down
8 changes: 2 additions & 6 deletions build/meson/tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ testcommon_sources = [join_paths(zstd_rootdir, 'programs/datagen.c'),
testcommon = static_library('testcommon',
testcommon_sources,
# needed due to use of private symbol + -fvisibility=hidden
objects: libzstd.extract_all_objects(recursive: false))
link_with: libzstd_static)

testcommon_dep = declare_dependency(link_with: testcommon,
dependencies: libzstd_deps,
Expand Down Expand Up @@ -116,11 +116,7 @@ decodecorpus = executable('decodecorpus',
dependencies: [ testcommon_dep, libm_dep ],
install: false)

poolTests_sources = [join_paths(zstd_rootdir, 'tests/poolTests.c'),
join_paths(zstd_rootdir, 'lib/common/pool.c'),
join_paths(zstd_rootdir, 'lib/common/threading.c'),
join_paths(zstd_rootdir, 'lib/common/zstd_common.c'),
join_paths(zstd_rootdir, 'lib/common/error_private.c')]
poolTests_sources = [join_paths(zstd_rootdir, 'tests/poolTests.c')]
poolTests = executable('poolTests',
poolTests_sources,
include_directories: test_includes,
Expand Down