* [PATCH] erofs-utils: enhance static linking for lz4 1.8.x
[not found] <20200531034510.5019-1-hsiangkao.ref@aol.com>
@ 2020-05-31 3:45 ` Gao Xiang via Linux-erofs
2020-06-07 14:54 ` Li Guifu
0 siblings, 1 reply; 2+ messages in thread
From: Gao Xiang via Linux-erofs @ 2020-05-31 3:45 UTC (permalink / raw)
To: linux-erofs
From: Gao Xiang <hsiangkao@redhat.com>
Since LZ4_compress_HC_destSize is static linking only on lz4 < 1.9.0,
but usually both lz4 static and dynamic library are available.
Previously, -all-static is used in erofs-utils compilation for such
lz4 versions, but it has conficts with libselinux linking. Use another
workable way [1] I've found instead.
[1] https://stackoverflow.com/questions/8045707/how-to-link-to-the-libabc-a-instead-of-libabc-so
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
---
configure.ac | 9 +++++----
mkfs/Makefile.am | 2 +-
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/configure.ac b/configure.ac
index 5145971..0f40a84 100644
--- a/configure.ac
+++ b/configure.ac
@@ -188,7 +188,6 @@ test -z $LZ4_LIBS && LZ4_LIBS='-llz4'
if test "x$enable_lz4" = "xyes"; then
test -z "${with_lz4_incdir}" || LZ4_CFLAGS="-I$with_lz4_incdir $LZ4_CFLAGS"
- test -z "${with_lz4_libdir}" || LZ4_LIBS="-L$with_lz4_libdir $LZ4_LIBS"
saved_CPPFLAGS=${CPPFLAGS}
CPPFLAGS="${LZ4_CFLAGS} ${CPPFLAGS}"
@@ -196,6 +195,7 @@ if test "x$enable_lz4" = "xyes"; then
AC_CHECK_HEADERS([lz4.h],[have_lz4h="yes"], [])
if test "x${have_lz4h}" = "xyes" ; then
+ saved_LIBS="$LIBS"
saved_LDFLAGS=${LDFLAGS}
test -z "${with_lz4_libdir}" || LDFLAGS="-L$with_lz4_libdir ${LDFLAGS}"
AC_CHECK_LIB(lz4, LZ4_compress_destSize, [
@@ -210,6 +210,7 @@ if test "x$enable_lz4" = "xyes"; then
])
], [AC_MSG_ERROR([Cannot find proper lz4 version (>= 1.8.0)])])
LDFLAGS=${saved_LDFLAGS}
+ LIBS="${saved_LIBS}"
fi
CPPFLAGS=${saved_CPPFLAGS}
fi
@@ -234,11 +235,11 @@ if test "x${have_lz4}" = "xyes"; then
fi
if test "x${lz4_force_static}" = "xyes"; then
- LDFLAGS="-all-static ${LDFLAGS}"
+ LZ4_LIBS="-Wl,-Bstatic -Wl,-whole-archive -Xlinker ${LZ4_LIBS} -Wl,-no-whole-archive -Wl,-Bdynamic"
+ test -z "${with_lz4_libdir}" || LZ4_LIBS="-L${with_lz4_libdir} $LZ4_LIBS"
else
- test -z "${with_lz4_libdir}" || LZ4_LIBS="-R ${with_lz4_libdir} $LZ4_LIBS"
+ test -z "${with_lz4_libdir}" || LZ4_LIBS="-R${with_lz4_libdir} $LZ4_LIBS"
fi
- LIBS="$LZ4_LIBS $LIBS"
fi
AC_CONFIG_FILES([Makefile
diff --git a/mkfs/Makefile.am b/mkfs/Makefile.am
index 97ba148..ecc468c 100644
--- a/mkfs/Makefile.am
+++ b/mkfs/Makefile.am
@@ -6,5 +6,5 @@ bin_PROGRAMS = mkfs.erofs
AM_CPPFLAGS = ${libuuid_CFLAGS} ${libselinux_CFLAGS}
mkfs_erofs_SOURCES = main.c
mkfs_erofs_CFLAGS = -Wall -Werror -I$(top_srcdir)/include
-mkfs_erofs_LDADD = $(top_builddir)/lib/liberofs.la ${libuuid_LIBS} ${libselinux_LIBS}
+mkfs_erofs_LDADD = ${libuuid_LIBS} $(top_builddir)/lib/liberofs.la ${libselinux_LIBS} ${LZ4_LIBS}
--
2.24.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] erofs-utils: enhance static linking for lz4 1.8.x
2020-05-31 3:45 ` [PATCH] erofs-utils: enhance static linking for lz4 1.8.x Gao Xiang via Linux-erofs
@ 2020-06-07 14:54 ` Li Guifu
0 siblings, 0 replies; 2+ messages in thread
From: Li Guifu @ 2020-06-07 14:54 UTC (permalink / raw)
To: linux-erofs
On 2020/5/31 11:45, Gao Xiang via Linux-erofs wrote:
> From: Gao Xiang <hsiangkao@redhat.com>
>
> Since LZ4_compress_HC_destSize is static linking only on lz4 < 1.9.0,
> but usually both lz4 static and dynamic library are available.
>
> Previously, -all-static is used in erofs-utils compilation for such
> lz4 versions, but it has conficts with libselinux linking. Use another
> workable way [1] I've found instead.
>
> [1] https://stackoverflow.com/questions/8045707/how-to-link-to-the-libabc-a-instead-of-libabc-so
> Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
> ---
> It looks good
> Reviewed-by: Li Guifu <bluce.lee@aliyun.com>
> Tested-by: Li Guifu <bluce.lee@aliyun.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-07 15:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20200531034510.5019-1-hsiangkao.ref@aol.com>
2020-05-31 3:45 ` [PATCH] erofs-utils: enhance static linking for lz4 1.8.x Gao Xiang via Linux-erofs
2020-06-07 14:54 ` Li Guifu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).