libarchive: zstd feature check via cc.has_header_symbol() fails with internal (subproject) dependency

Open Beginner friendly
#2,939 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Domain
build-system

Research direction

Start in meson.build around line 802 and compare the zstd block with the liblzma handling above it. Reproduce the configuration with zstd supplied through a subproject fallback; done means the build configures successfully and sets the zstd feature checks according to the dependency version.

Written by the indexing model from the issue text.

Description

Bug report

Line 802 of meson.build says:

we can't use cc.has_function() on dependencies since they might be
internal, so check headers instead

However, the zstd block just below does exactly what this comment warns
against, but with cc.has_header_symbol() instead of cc.has_function():

foreach sym : ['ZSTD_compressStream', 'ZSTD_minCLevel']
  if cc.has_header_symbol(
    'zstd.h',
    sym,
    dependencies: zstd_dep,
  )

cc.has_header_symbol() has the same limitation as cc.has_function():
it rejects internal dependencies in the dependencies: kwarg. This
fails with:

meson.build:347:10: ERROR: Dependencies must be external dependencies

To reproduce

Use zstd via a subproject fallback (i.e. dependency('libzstd', ...)
resolves through fallback:/wrap, not pkg-config/cmake), for example
when zstd isn't installed system-wide and libarchive is built as a
subproject with zstd=enabled.

Environment

  • Meson 1.12.0
  • libarchive 3.8.9

Suggested fix

Replace the has_header_symbol() calls with a version check, since
Dependency.version() works for both internal and external
dependencies (see liblzma handling a few lines above for a similar
pattern already in this file):

zstd_version = zstd_dep.version()
if zstd_version == 'unknown' or zstd_version.version_compare('>=1.0.0')
  cdata.set('HAVE_ZSTD_compressStream', 1)
endif
if zstd_version == 'unknown' or zstd_version.version_compare('>=1.4.0')
  cdata.set('HAVE_ZSTD_minCLevel', 1)
endif

I've tested this patch locally and it resolves the issue while keeping
zstd statically linked via a subproject.

Dominant language
Meson
Stars
118
Forks
298
Avg merge
2d 14m
Merged PRs (30d)
25

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mesonbuild/wrapdb

All issues in mesonbuild/wrapdb

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.