Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meson: Do not export private headers in libzstd_dep to avoid name clash #4153

Merged
merged 2 commits into from
Oct 2, 2024
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
2 changes: 1 addition & 1 deletion build/meson/contrib/pzstd/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ pzstd = executable('pzstd',
pzstd_sources,
cpp_args: pzstd_warning_flags,
include_directories: pzstd_includes,
dependencies: [ libzstd_dep, thread_dep ],
dependencies: [ libzstd_internal_dep, thread_dep ],
override_options: ['b_ndebug=true'],
install: true)
11 changes: 7 additions & 4 deletions build/meson/lib/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ libzstd = library('zstd',
version: zstd_libversion)

libzstd_dep = declare_dependency(link_with: libzstd,
include_directories: libzstd_includes)
include_directories: join_paths(zstd_rootdir,'lib')) # Do not expose private headers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me. It corresponds to the only 3 headers that get installed, and libzstd_dep is supposed to be equivalent to the installed zstd library.

It's still possible for people to do something filthy like #include <common/xxhash.h> but if they do then they broke it themselves, so they get to keep both pieces.


# we link to both:
# - the shared library (for public symbols)
Expand All @@ -134,7 +134,8 @@ libzstd_dep = declare_dependency(link_with: libzstd,
# -fvisibility=hidden means those cannot be found
if get_option('default_library') == 'static'
libzstd_static = libzstd
libzstd_internal_dep = libzstd_dep
libzstd_internal_dep = declare_dependency(link_with: libzstd,
include_directories: libzstd_includes)
else
if get_option('default_library') == 'shared'
libzstd_static = static_library('zstd_objlib',
Expand All @@ -147,11 +148,13 @@ else
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)
libzstd_internal_dep = declare_dependency(link_with: libzstd_static,
include_directories: libzstd_includes)
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))
dependencies: declare_dependency(link_with: libzstd_static),
include_directories: libzstd_includes)
endif
endif

Expand Down
2 changes: 1 addition & 1 deletion build/meson/tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ roundTripCrash = executable('roundTripCrash',
longmatch_sources = [join_paths(zstd_rootdir, 'tests/longmatch.c')]
longmatch = executable('longmatch',
longmatch_sources,
dependencies: [ libzstd_dep ],
dependencies: [ libzstd_internal_dep ],
install: false)

invalidDictionaries_sources = [join_paths(zstd_rootdir, 'tests/invalidDictionaries.c')]
Expand Down