erofs-utils: enhance static linking for lz4 1.8.x
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 erofs-utils: enhance static linking for lz4 1.8.x
From: Gao Xiang <[email protected]>
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
--- configure.ac | 9 +++++---- mkfs/Makefile.am | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-)
configure.ac +5 -4
@@ -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
mkfs/Makefile.am +1 -1
@@ -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}
Signature · 1 line
2.24.0
Quoted 15 lines · Gao Xiang via Linux-erofs
From: Gao Xiang <[email protected]>
Since
LZ4_compress_HC_destSizeis 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 <[email protected]>---
It looks goodReviewed-by Li Guifu <[email protected]>Tested-by Li Guifu <[email protected]>