All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] erofs-utils: build: link tools with liberofs dependencies
@ 2026-05-29  7:17 Yifan Zhao
  2026-06-01 12:52 ` Guo Xuenan
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Yifan Zhao @ 2026-05-29  7:17 UTC (permalink / raw)
  To: linux-erofs; +Cc: guoxuenan, zhukeqian1, zhaoyifan28

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 <guoxuenan@huawei.com>
Fixes: 6c2a000782b2 ("erofs-utils: lib: add test for s3erofs_prepare_url()")
Assisted-by: Codex:GPT-5.5
Signed-off-by: Yifan Zhao <zhaoyifan28@huawei.com>
---
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}"
+])
+AC_SUBST([LIBEROFS_LIBS])
+
 if test "x$have_uuid" = "xyes"; then
   AC_DEFINE([HAVE_LIBUUID], 1, [Define to 1 if libuuid is found])
 fi
diff --git a/dump/Makefile.am b/dump/Makefile.am
index 2611fd2..5d908b4 100644
--- a/dump/Makefile.am
+++ b/dump/Makefile.am
@@ -6,4 +6,4 @@ bin_PROGRAMS     = dump.erofs
 AM_CPPFLAGS = ${libuuid_CFLAGS}
 dump_erofs_SOURCES = main.c
 dump_erofs_CFLAGS = -Wall -I$(top_srcdir)/include
-dump_erofs_LDADD = $(top_builddir)/lib/liberofs.la
+dump_erofs_LDADD = $(top_builddir)/lib/liberofs.la $(LIBEROFS_LIBS)
diff --git a/fsck/Makefile.am b/fsck/Makefile.am
index 8eebadd..461eb88 100644
--- a/fsck/Makefile.am
+++ b/fsck/Makefile.am
@@ -6,12 +6,12 @@ bin_PROGRAMS     = fsck.erofs
 AM_CPPFLAGS = ${libuuid_CFLAGS}
 fsck_erofs_SOURCES = main.c
 fsck_erofs_CFLAGS = -Wall -I$(top_srcdir)/include
-fsck_erofs_LDADD = $(top_builddir)/lib/liberofs.la
+fsck_erofs_LDADD = $(top_builddir)/lib/liberofs.la $(LIBEROFS_LIBS)
 
 if ENABLE_FUZZING
 noinst_PROGRAMS   = fuzz_erofsfsck
 fuzz_erofsfsck_SOURCES = main.c
 fuzz_erofsfsck_CFLAGS = -Wall -I$(top_srcdir)/include -DFUZZING
 fuzz_erofsfsck_LDFLAGS = -fsanitize=address,fuzzer
-fuzz_erofsfsck_LDADD = $(top_builddir)/lib/liberofs.la
+fuzz_erofsfsck_LDADD = $(top_builddir)/lib/liberofs.la $(LIBEROFS_LIBS)
 endif
diff --git a/fuse/Makefile.am b/fuse/Makefile.am
index 9fe5608..b72e065 100644
--- a/fuse/Makefile.am
+++ b/fuse/Makefile.am
@@ -6,12 +6,13 @@ bin_PROGRAMS     = erofsfuse
 erofsfuse_SOURCES = main.c
 erofsfuse_CFLAGS = -Wall -I$(top_srcdir)/include
 erofsfuse_CFLAGS += ${libfuse2_CFLAGS} ${libfuse3_CFLAGS} ${libselinux_CFLAGS}
-erofsfuse_LDADD = $(top_builddir)/lib/liberofs.la ${libfuse2_LIBS} ${libfuse3_LIBS}
+erofsfuse_LDADD = $(top_builddir)/lib/liberofs.la $(LIBEROFS_LIBS) \
+	${libfuse2_LIBS} ${libfuse3_LIBS}
 
 if ENABLE_STATIC_FUSE
 lib_LTLIBRARIES = liberofsfuse.la
 liberofsfuse_la_SOURCES = main.c
 liberofsfuse_la_CFLAGS  = -Wall -I$(top_srcdir)/include
 liberofsfuse_la_CFLAGS += -Dmain=erofsfuse_main ${libfuse2_CFLAGS} ${libfuse3_CFLAGS} ${libselinux_CFLAGS}
-liberofsfuse_la_LIBADD  = $(top_builddir)/lib/liberofs.la
+liberofsfuse_la_LIBADD  = $(top_builddir)/lib/liberofs.la $(LIBEROFS_LIBS)
 endif
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 27bf710..25ad79d 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -48,9 +48,7 @@ liberofs_la_SOURCES = config.c io.c cache.c super.c inode.c xattr.c exclude.c \
 		      vmdk.c metabox.c global.c importer.c base64.c
 
 liberofs_la_CFLAGS = -Wall ${libuuid_CFLAGS} -I$(top_srcdir)/include
-liberofs_la_LDFLAGS = ${libselinux_LIBS} ${libuuid_LIBS} ${liblz4_LIBS} \
-	${liblzma_LIBS} ${zlib_LIBS} ${libdeflate_LIBS} ${libzstd_LIBS} \
-	${libqpl_LIBS}
+liberofs_la_LIBADD = $(LIBEROFS_LIBS)
 if ENABLE_LZ4
 liberofs_la_CFLAGS += ${liblz4_CFLAGS}
 liberofs_la_SOURCES += compressor_lz4.c
@@ -74,23 +72,18 @@ liberofs_la_SOURCES += compressor_libzstd.c
 endif
 if ENABLE_XXHASH
 liberofs_la_CFLAGS += ${libxxhash_CFLAGS}
-liberofs_la_LDFLAGS += ${libxxhash_LIBS}
 else
 liberofs_la_SOURCES += xxhash.c
 endif
 liberofs_la_CFLAGS += ${libcurl_CFLAGS} ${openssl_CFLAGS} ${libxml2_CFLAGS}
-liberofs_la_LDFLAGS += ${libcurl_LIBS} ${openssl_LIBS}
 if ENABLE_S3
 liberofs_la_SOURCES += remotes/s3.c
-liberofs_la_LDFLAGS += ${libxml2_LIBS}
 endif
 if ENABLE_EROFS_MT
-liberofs_la_LDFLAGS += -lpthread
 liberofs_la_SOURCES += workqueue.c
 endif
 if OS_LINUX
 liberofs_la_CFLAGS += ${libnl3_CFLAGS}
-liberofs_la_LDFLAGS += ${libnl3_LIBS}
 liberofs_la_SOURCES += backends/nbd.c
 if ENABLE_FANOTIFY
 liberofs_la_SOURCES += backends/fanotify.c
@@ -98,19 +91,18 @@ endif
 endif
 liberofs_la_SOURCES += remotes/oci.c remotes/docker_config.c
 liberofs_la_CFLAGS += ${json_c_CFLAGS}
-liberofs_la_LDFLAGS += ${json_c_LIBS}
 liberofs_la_SOURCES += gzran.c
 
 if ENABLE_S3
 noinst_PROGRAMS = s3erofs_test
 s3erofs_test_SOURCES = remotes/s3.c
 s3erofs_test_CFLAGS = -Wall -I$(top_srcdir)/include ${libxml2_CFLAGS} ${openssl_CFLAGS} -DTEST
-s3erofs_test_LDADD = liberofs.la
+s3erofs_test_LDADD = liberofs.la $(LIBEROFS_LIBS)
 endif
 
 if ENABLE_OCI
 noinst_PROGRAMS = ocierofs_test
 ocierofs_test_SOURCES = remotes/oci.c
 ocierofs_test_CFLAGS = -Wall -I$(top_srcdir)/include ${json_c_CFLAGS} -DTEST
-ocierofs_test_LDADD = liberofs.la
+ocierofs_test_LDADD = liberofs.la $(LIBEROFS_LIBS)
 endif
diff --git a/mkfs/Makefile.am b/mkfs/Makefile.am
index 386455a..f511a09 100644
--- a/mkfs/Makefile.am
+++ b/mkfs/Makefile.am
@@ -5,4 +5,4 @@ bin_PROGRAMS     = mkfs.erofs
 AM_CPPFLAGS = ${libselinux_CFLAGS}
 mkfs_erofs_SOURCES = main.c
 mkfs_erofs_CFLAGS = -Wall -I$(top_srcdir)/include
-mkfs_erofs_LDADD = $(top_builddir)/lib/liberofs.la
+mkfs_erofs_LDADD = $(top_builddir)/lib/liberofs.la $(LIBEROFS_LIBS)
diff --git a/mount/Makefile.am b/mount/Makefile.am
index 637029d..189dbaf 100644
--- a/mount/Makefile.am
+++ b/mount/Makefile.am
@@ -7,5 +7,5 @@ sbin_PROGRAMS    = mount.erofs
 AM_CPPFLAGS = ${libuuid_CFLAGS}
 mount_erofs_SOURCES = main.c
 mount_erofs_CFLAGS = -Wall -I$(top_srcdir)/include
-mount_erofs_LDADD = $(top_builddir)/lib/liberofs.la
+mount_erofs_LDADD = $(top_builddir)/lib/liberofs.la $(LIBEROFS_LIBS)
 endif
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] erofs-utils: build: link tools with liberofs dependencies
  2026-05-29  7:17 [PATCH] erofs-utils: build: link tools with liberofs dependencies Yifan Zhao
@ 2026-06-01 12:52 ` Guo Xuenan
  2026-06-03 14:36 ` Gao Xiang
  2026-06-09  9:04 ` [PATCH v2] " Yifan Zhao
  2 siblings, 0 replies; 6+ messages in thread
From: Guo Xuenan @ 2026-06-01 12:52 UTC (permalink / raw)
  To: zhaoyifan28; +Cc: guoxuenan, linux-erofs, zhukeqian1, Guo Xuenan

It works perfectly,Thx.

Tested-by: Guo Xuenan <gxnorz@yeah.net>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] erofs-utils: build: link tools with liberofs dependencies
  2026-05-29  7:17 [PATCH] erofs-utils: build: link tools with liberofs dependencies Yifan Zhao
  2026-06-01 12:52 ` Guo Xuenan
@ 2026-06-03 14:36 ` Gao Xiang
  2026-06-07 11:29   ` zhaoyifan (H)
  2026-06-09  9:04 ` [PATCH v2] " Yifan Zhao
  2 siblings, 1 reply; 6+ messages in thread
From: Gao Xiang @ 2026-06-03 14:36 UTC (permalink / raw)
  To: Yifan Zhao; +Cc: linux-erofs, guoxuenan, zhukeqian1

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 <guoxuenan@huawei.com>
> Fixes: 6c2a000782b2 ("erofs-utils: lib: add test for s3erofs_prepare_url()")
> Assisted-by: Codex:GPT-5.5
> Signed-off-by: Yifan Zhao <zhaoyifan28@huawei.com>
> ---
> 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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] erofs-utils: build: link tools with liberofs dependencies
  2026-06-03 14:36 ` Gao Xiang
@ 2026-06-07 11:29   ` zhaoyifan (H)
  2026-06-08  5:46     ` Gao Xiang
  0 siblings, 1 reply; 6+ messages in thread
From: zhaoyifan (H) @ 2026-06-07 11:29 UTC (permalink / raw)
  To: linux-erofs, guoxuenan, zhukeqian1


On 2026/6/3 22:36, Gao Xiang wrote:
> 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 <guoxuenan@huawei.com>
>> Fixes: 6c2a000782b2 ("erofs-utils: lib: add test for s3erofs_prepare_url()")
>> Assisted-by: Codex:GPT-5.5
>> Signed-off-by: Yifan Zhao <zhaoyifan28@huawei.com>
>> ---
>> 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.

As these flags were conditionally appended to liberofs_la_LDFLAGS in the 
original lib/Makefile.am code path.


Thanks,

Yifan

> But I think it's fine to guard `-lpthread` with enable_multithreading
> tho.
>
> Thanks,
> Gao Xiang
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] erofs-utils: build: link tools with liberofs dependencies
  2026-06-07 11:29   ` zhaoyifan (H)
@ 2026-06-08  5:46     ` Gao Xiang
  0 siblings, 0 replies; 6+ messages in thread
From: Gao Xiang @ 2026-06-08  5:46 UTC (permalink / raw)
  To: zhaoyifan (H), linux-erofs, guoxuenan, zhukeqian1



On 2026/6/7 19:29, zhaoyifan (H) wrote:
> 
> On 2026/6/3 22:36, Gao Xiang wrote:

...

>>> +])
>> 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.
> 
> As these flags were conditionally appended to liberofs_la_LDFLAGS in the original lib/Makefile.am code path.

Can we append them into LIBEROFS_LIBS directly?

Thanks,
Gao Xiang

> 
> 
> Thanks,
> 
> Yifan
> 
>> But I think it's fine to guard `-lpthread` with enable_multithreading
>> tho.
>>
>> Thanks,
>> Gao Xiang
>>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] erofs-utils: build: link tools with liberofs dependencies
  2026-05-29  7:17 [PATCH] erofs-utils: build: link tools with liberofs dependencies Yifan Zhao
  2026-06-01 12:52 ` Guo Xuenan
  2026-06-03 14:36 ` Gao Xiang
@ 2026-06-09  9:04 ` Yifan Zhao
  2 siblings, 0 replies; 6+ messages in thread
From: Yifan Zhao @ 2026-06-09  9:04 UTC (permalink / raw)
  To: hsiangkao, linux-erofs; +Cc: guoxuenan, zhukeqian1, zhaoyifan28

From: Yifan Zhao <yifan.yfzhao@foxmail.com>

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 <guoxuenan@huawei.com>
Fixes: 6c2a000782b2 ("erofs-utils: lib: add test for s3erofs_prepare_url()")
Assisted-by: Codex:GPT-5.5
Signed-off-by: Yifan Zhao <zhaoyifan28@huawei.com>
---
 configure.ac      |  9 +++++++++
 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, 20 insertions(+), 18 deletions(-)

diff --git a/configure.ac b/configure.ac
index f68bb74..392d931 100644
--- a/configure.ac
+++ b/configure.ac
@@ -790,6 +790,15 @@ 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} ${libxxhash_LIBS} ${libcurl_LIBS} ${openssl_LIBS} \
+${libxml2_LIBS} ${json_c_LIBS} ${libnl3_LIBS}"
+AS_IF([test "x${enable_multithreading}" != "xno"], [
+  LIBEROFS_LIBS="${LIBEROFS_LIBS} -lpthread"
+])
+AC_SUBST([LIBEROFS_LIBS])
+
 if test "x$have_uuid" = "xyes"; then
   AC_DEFINE([HAVE_LIBUUID], 1, [Define to 1 if libuuid is found])
 fi
diff --git a/dump/Makefile.am b/dump/Makefile.am
index 2611fd2..5d908b4 100644
--- a/dump/Makefile.am
+++ b/dump/Makefile.am
@@ -6,4 +6,4 @@ bin_PROGRAMS     = dump.erofs
 AM_CPPFLAGS = ${libuuid_CFLAGS}
 dump_erofs_SOURCES = main.c
 dump_erofs_CFLAGS = -Wall -I$(top_srcdir)/include
-dump_erofs_LDADD = $(top_builddir)/lib/liberofs.la
+dump_erofs_LDADD = $(top_builddir)/lib/liberofs.la $(LIBEROFS_LIBS)
diff --git a/fsck/Makefile.am b/fsck/Makefile.am
index 8eebadd..461eb88 100644
--- a/fsck/Makefile.am
+++ b/fsck/Makefile.am
@@ -6,12 +6,12 @@ bin_PROGRAMS     = fsck.erofs
 AM_CPPFLAGS = ${libuuid_CFLAGS}
 fsck_erofs_SOURCES = main.c
 fsck_erofs_CFLAGS = -Wall -I$(top_srcdir)/include
-fsck_erofs_LDADD = $(top_builddir)/lib/liberofs.la
+fsck_erofs_LDADD = $(top_builddir)/lib/liberofs.la $(LIBEROFS_LIBS)
 
 if ENABLE_FUZZING
 noinst_PROGRAMS   = fuzz_erofsfsck
 fuzz_erofsfsck_SOURCES = main.c
 fuzz_erofsfsck_CFLAGS = -Wall -I$(top_srcdir)/include -DFUZZING
 fuzz_erofsfsck_LDFLAGS = -fsanitize=address,fuzzer
-fuzz_erofsfsck_LDADD = $(top_builddir)/lib/liberofs.la
+fuzz_erofsfsck_LDADD = $(top_builddir)/lib/liberofs.la $(LIBEROFS_LIBS)
 endif
diff --git a/fuse/Makefile.am b/fuse/Makefile.am
index 9fe5608..b72e065 100644
--- a/fuse/Makefile.am
+++ b/fuse/Makefile.am
@@ -6,12 +6,13 @@ bin_PROGRAMS     = erofsfuse
 erofsfuse_SOURCES = main.c
 erofsfuse_CFLAGS = -Wall -I$(top_srcdir)/include
 erofsfuse_CFLAGS += ${libfuse2_CFLAGS} ${libfuse3_CFLAGS} ${libselinux_CFLAGS}
-erofsfuse_LDADD = $(top_builddir)/lib/liberofs.la ${libfuse2_LIBS} ${libfuse3_LIBS}
+erofsfuse_LDADD = $(top_builddir)/lib/liberofs.la $(LIBEROFS_LIBS) \
+	${libfuse2_LIBS} ${libfuse3_LIBS}
 
 if ENABLE_STATIC_FUSE
 lib_LTLIBRARIES = liberofsfuse.la
 liberofsfuse_la_SOURCES = main.c
 liberofsfuse_la_CFLAGS  = -Wall -I$(top_srcdir)/include
 liberofsfuse_la_CFLAGS += -Dmain=erofsfuse_main ${libfuse2_CFLAGS} ${libfuse3_CFLAGS} ${libselinux_CFLAGS}
-liberofsfuse_la_LIBADD  = $(top_builddir)/lib/liberofs.la
+liberofsfuse_la_LIBADD  = $(top_builddir)/lib/liberofs.la $(LIBEROFS_LIBS)
 endif
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 27bf710..25ad79d 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -48,9 +48,7 @@ liberofs_la_SOURCES = config.c io.c cache.c super.c inode.c xattr.c exclude.c \
 		      vmdk.c metabox.c global.c importer.c base64.c
 
 liberofs_la_CFLAGS = -Wall ${libuuid_CFLAGS} -I$(top_srcdir)/include
-liberofs_la_LDFLAGS = ${libselinux_LIBS} ${libuuid_LIBS} ${liblz4_LIBS} \
-	${liblzma_LIBS} ${zlib_LIBS} ${libdeflate_LIBS} ${libzstd_LIBS} \
-	${libqpl_LIBS}
+liberofs_la_LIBADD = $(LIBEROFS_LIBS)
 if ENABLE_LZ4
 liberofs_la_CFLAGS += ${liblz4_CFLAGS}
 liberofs_la_SOURCES += compressor_lz4.c
@@ -74,23 +72,18 @@ liberofs_la_SOURCES += compressor_libzstd.c
 endif
 if ENABLE_XXHASH
 liberofs_la_CFLAGS += ${libxxhash_CFLAGS}
-liberofs_la_LDFLAGS += ${libxxhash_LIBS}
 else
 liberofs_la_SOURCES += xxhash.c
 endif
 liberofs_la_CFLAGS += ${libcurl_CFLAGS} ${openssl_CFLAGS} ${libxml2_CFLAGS}
-liberofs_la_LDFLAGS += ${libcurl_LIBS} ${openssl_LIBS}
 if ENABLE_S3
 liberofs_la_SOURCES += remotes/s3.c
-liberofs_la_LDFLAGS += ${libxml2_LIBS}
 endif
 if ENABLE_EROFS_MT
-liberofs_la_LDFLAGS += -lpthread
 liberofs_la_SOURCES += workqueue.c
 endif
 if OS_LINUX
 liberofs_la_CFLAGS += ${libnl3_CFLAGS}
-liberofs_la_LDFLAGS += ${libnl3_LIBS}
 liberofs_la_SOURCES += backends/nbd.c
 if ENABLE_FANOTIFY
 liberofs_la_SOURCES += backends/fanotify.c
@@ -98,19 +91,18 @@ endif
 endif
 liberofs_la_SOURCES += remotes/oci.c remotes/docker_config.c
 liberofs_la_CFLAGS += ${json_c_CFLAGS}
-liberofs_la_LDFLAGS += ${json_c_LIBS}
 liberofs_la_SOURCES += gzran.c
 
 if ENABLE_S3
 noinst_PROGRAMS = s3erofs_test
 s3erofs_test_SOURCES = remotes/s3.c
 s3erofs_test_CFLAGS = -Wall -I$(top_srcdir)/include ${libxml2_CFLAGS} ${openssl_CFLAGS} -DTEST
-s3erofs_test_LDADD = liberofs.la
+s3erofs_test_LDADD = liberofs.la $(LIBEROFS_LIBS)
 endif
 
 if ENABLE_OCI
 noinst_PROGRAMS = ocierofs_test
 ocierofs_test_SOURCES = remotes/oci.c
 ocierofs_test_CFLAGS = -Wall -I$(top_srcdir)/include ${json_c_CFLAGS} -DTEST
-ocierofs_test_LDADD = liberofs.la
+ocierofs_test_LDADD = liberofs.la $(LIBEROFS_LIBS)
 endif
diff --git a/mkfs/Makefile.am b/mkfs/Makefile.am
index 386455a..f511a09 100644
--- a/mkfs/Makefile.am
+++ b/mkfs/Makefile.am
@@ -5,4 +5,4 @@ bin_PROGRAMS     = mkfs.erofs
 AM_CPPFLAGS = ${libselinux_CFLAGS}
 mkfs_erofs_SOURCES = main.c
 mkfs_erofs_CFLAGS = -Wall -I$(top_srcdir)/include
-mkfs_erofs_LDADD = $(top_builddir)/lib/liberofs.la
+mkfs_erofs_LDADD = $(top_builddir)/lib/liberofs.la $(LIBEROFS_LIBS)
diff --git a/mount/Makefile.am b/mount/Makefile.am
index 637029d..189dbaf 100644
--- a/mount/Makefile.am
+++ b/mount/Makefile.am
@@ -7,5 +7,5 @@ sbin_PROGRAMS    = mount.erofs
 AM_CPPFLAGS = ${libuuid_CFLAGS}
 mount_erofs_SOURCES = main.c
 mount_erofs_CFLAGS = -Wall -I$(top_srcdir)/include
-mount_erofs_LDADD = $(top_builddir)/lib/liberofs.la
+mount_erofs_LDADD = $(top_builddir)/lib/liberofs.la $(LIBEROFS_LIBS)
 endif
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-06-09  9:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-29  7:17 [PATCH] erofs-utils: build: link tools with liberofs dependencies Yifan Zhao
2026-06-01 12:52 ` Guo Xuenan
2026-06-03 14:36 ` Gao Xiang
2026-06-07 11:29   ` zhaoyifan (H)
2026-06-08  5:46     ` Gao Xiang
2026-06-09  9:04 ` [PATCH v2] " Yifan Zhao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.