Re: [PATCH] erofs-utils: build: link tools with liberofs dependencies

Gao Xiang <[email protected]>
Newsgroups org.ozlabs.lists.linux-erofs
Message-ID <aiA8AhQvFtK_QMwb@debian>
Hi Yifan,

On Fri, May 29, 2026 at 03:17:02PM +0800, Yifan Zhao wrote:
> liberofs.la is a noinst libtool archive, so relying on its
> dependency_libs to carry external libraries is not enough for
> static-only dependencies.
> 
> For example, when liblzma is installed as a static libtool archive,
> libtool consumes -llzma while creating liberofs.la but does not record it
> in dependency_libs.  The final tools then link only with liberofs.la and
> fail with undefined lzma_* references.
> 
> Collect liberofs external libraries in LIBEROFS_LIBS and use it for both
> liberofs.la and the final tools, so final executable links see the
> pkg-config supplied liblzma flags directly.
> 
> Reported-by: Guo Xuenan <[email protected]>
> Fixes: 6c2a000782b2 ("erofs-utils: lib: add test for s3erofs_prepare_url()")
> Assisted-by: Codex:GPT-5.5
> Signed-off-by: Yifan Zhao <[email protected]>
> ---
> To reproduce link error:
> 
>     ./autogen.sh
>     PKG_CONFIG_PATH=/path/to/xz-static/lib/pkgconfig ./configure
>     make -j
> 
> Then {mkfs,dump,fsck}.erofs reports missing lzma_* symbol as `-llzma`
> missing in ld flags.
> 
>  configure.ac      | 17 +++++++++++++++++
>  dump/Makefile.am  |  2 +-
>  fsck/Makefile.am  |  4 ++--
>  fuse/Makefile.am  |  5 +++--
>  lib/Makefile.am   | 14 +++-----------
>  mkfs/Makefile.am  |  2 +-
>  mount/Makefile.am |  2 +-
>  7 files changed, 28 insertions(+), 18 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index f68bb74..17b4856 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -790,6 +790,23 @@ AM_CONDITIONAL([ENABLE_STATIC_FUSE], [test "x${enable_static_fuse}" = "xyes"])
>  AM_CONDITIONAL([ENABLE_OCI], [test "x${have_oci}" = "xyes"])
>  AM_CONDITIONAL([ENABLE_FANOTIFY], [test "x${have_fanotify}" = "xyes"])
>  
> +LIBEROFS_LIBS="${libselinux_LIBS} ${libuuid_LIBS} ${liblz4_LIBS} \
> +${liblzma_LIBS} ${zlib_LIBS} ${libdeflate_LIBS} ${libzstd_LIBS} \
> +${libqpl_LIBS} ${libcurl_LIBS} ${openssl_LIBS} ${json_c_LIBS}"
> +AS_IF([test "x${have_xxhash}" = "xyes"], [
> +  LIBEROFS_LIBS="${LIBEROFS_LIBS} ${libxxhash_LIBS}"
> +])
> +AS_IF([test "x${have_s3}" = "xyes"], [
> +  LIBEROFS_LIBS="${LIBEROFS_LIBS} ${libxml2_LIBS}"
> +])
> +AS_IF([test "x${enable_multithreading}" != "xno"], [
> +  LIBEROFS_LIBS="${LIBEROFS_LIBS} -lpthread"
> +])
> +AS_IF([test "x${build_linux}" = "xyes"], [
> +  LIBEROFS_LIBS="${LIBEROFS_LIBS} ${libnl3_LIBS}"
> +])

Although I admit that I'm not super happy with this approach, but it
seems that we have to do like this.

My only question here is that why  ${libxxhash_LIBS},  ${libxml2_LIBS}
and ${libnl3_LIBS} cannot be appended directly to LIBEROFS_LIBS as
others.

But I think it's fine to guard `-lpthread` with enable_multithreading
tho.

Thanks,
Gao Xiang
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.