diff options
author | Gao Xiang <hsiangkao@redhat.com> | 2020-05-31 11:45:10 +0800 |
---|---|---|
committer | Gao Xiang <hsiangkao@redhat.com> | 2020-06-08 21:15:34 +0800 |
commit | c497d89e5eac58580ab20648783762c5cdde8de0 (patch) | |
tree | 6acb70d084e7b50afcbb8f91f77a14a27075ed60 | |
parent | 3e52a3337f8e63bf40dbda7a8f3269026681e883 (diff) |
erofs-utils: enhance static linking for lz4 1.8.x
Since LZ4_compress_HC_destSize is static linking only on lz4 < 1.9.0,
but usually both lz4 static and dynamic libraries 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
Reviewed-and-tested-by: Li Guifu <bluce.lee@aliyun.com>
Link: https://lore.kernel.org/r/20200531034510.5019-1-hsiangkao@aol.com
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
-rw-r--r-- | configure.ac | 9 | ||||
-rw-r--r-- | 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} |