mirror of
https://git.tukaani.org/xz.git
synced 2025-05-24 07:06:39 +00:00
Build: With symbol versioning, try to pass --undefined-version to linker
Fixes: https://github.com/tukaani-project/xz/issues/180 Fixes: https://bugs.gentoo.org/956119
This commit is contained in:
parent
ff49c82176
commit
377be0ea7a
23
configure.ac
23
configure.ac
@ -758,6 +758,7 @@ fi
|
|||||||
# --with-pic and --without-pic though. As long as neither --with-pic nor
|
# --with-pic and --without-pic though. As long as neither --with-pic nor
|
||||||
# --without-pic is used then we can use #ifdef PIC to detect if the file is
|
# --without-pic is used then we can use #ifdef PIC to detect if the file is
|
||||||
# being built for a shared library.
|
# being built for a shared library.
|
||||||
|
LINKER_FLAG_UNDEFINED_VERSION=
|
||||||
AS_IF([test "x$enable_symbol_versions" = xno], [
|
AS_IF([test "x$enable_symbol_versions" = xno], [
|
||||||
enable_symbol_versions=no
|
enable_symbol_versions=no
|
||||||
AC_MSG_RESULT([no])
|
AC_MSG_RESULT([no])
|
||||||
@ -831,12 +832,34 @@ AS_IF([test "x$enable_symbol_versions" = xno], [
|
|||||||
AC_MSG_ERROR([unknown symbol versioning variant '$enable_symbol_versions'])
|
AC_MSG_ERROR([unknown symbol versioning variant '$enable_symbol_versions'])
|
||||||
fi
|
fi
|
||||||
AC_MSG_RESULT([yes ($enable_symbol_versions)])
|
AC_MSG_RESULT([yes ($enable_symbol_versions)])
|
||||||
|
|
||||||
|
# If features are disabled in liblzma, some symbols may be missing.
|
||||||
|
# LLVM's lld defaults to --no-undefined-version and the build breaks
|
||||||
|
# if not all symbols in the version script exist. That is good for
|
||||||
|
# catching errors like typos, but in our case the downside is too big.
|
||||||
|
# Avoid the problem by using --undefined-version if the linker
|
||||||
|
# supports it.
|
||||||
|
#
|
||||||
|
# GNU ld has had --no-undefined-version for a long time but it's not
|
||||||
|
# the default. The opposite option --undefined-version was only added
|
||||||
|
# in 2022, thus we must use --undefined-version conditionally.
|
||||||
|
AC_MSG_CHECKING([if linker supports --undefined-version])
|
||||||
|
OLD_LDFLAGS=$LDFLAGS
|
||||||
|
LDFLAGS="$LDFLAGS -Wl,--undefined-version"
|
||||||
|
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void) { return 0; }]])], [
|
||||||
|
LINKER_FLAG_UNDEFINED_VERSION=-Wl,--undefined-version
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
], [
|
||||||
|
AC_MSG_RESULT([no])
|
||||||
|
])
|
||||||
|
LDFLAGS=$OLD_LDFLAGS
|
||||||
])
|
])
|
||||||
|
|
||||||
AM_CONDITIONAL([COND_SYMVERS_LINUX],
|
AM_CONDITIONAL([COND_SYMVERS_LINUX],
|
||||||
[test "x$enable_symbol_versions" = xlinux])
|
[test "x$enable_symbol_versions" = xlinux])
|
||||||
AM_CONDITIONAL([COND_SYMVERS_GENERIC],
|
AM_CONDITIONAL([COND_SYMVERS_GENERIC],
|
||||||
[test "x$enable_symbol_versions" = xgeneric])
|
[test "x$enable_symbol_versions" = xgeneric])
|
||||||
|
AC_SUBST([LINKER_FLAG_UNDEFINED_VERSION])
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -25,10 +25,12 @@ liblzma_la_LDFLAGS = -no-undefined -version-info 13:1:8
|
|||||||
EXTRA_DIST += liblzma_generic.map liblzma_linux.map validate_map.sh
|
EXTRA_DIST += liblzma_generic.map liblzma_linux.map validate_map.sh
|
||||||
if COND_SYMVERS_GENERIC
|
if COND_SYMVERS_GENERIC
|
||||||
liblzma_la_LDFLAGS += \
|
liblzma_la_LDFLAGS += \
|
||||||
|
$(LINKER_FLAG_UNDEFINED_VERSION) \
|
||||||
-Wl,--version-script=$(top_srcdir)/src/liblzma/liblzma_generic.map
|
-Wl,--version-script=$(top_srcdir)/src/liblzma/liblzma_generic.map
|
||||||
endif
|
endif
|
||||||
if COND_SYMVERS_LINUX
|
if COND_SYMVERS_LINUX
|
||||||
liblzma_la_LDFLAGS += \
|
liblzma_la_LDFLAGS += \
|
||||||
|
$(LINKER_FLAG_UNDEFINED_VERSION) \
|
||||||
-Wl,--version-script=$(top_srcdir)/src/liblzma/liblzma_linux.map
|
-Wl,--version-script=$(top_srcdir)/src/liblzma/liblzma_linux.map
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user