From 1cedbaf13778de02e38b5dc80a7af246b7ec83e5 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 29 Mar 2021 21:46:12 +0200 Subject: configure: support builds without versioning Not all libc (like musl, uclibc dietlibc) libraries support full symbol version resolution in runtime like glibc. Add support to not generate symbol versions when compiling against them. Additionally libdevmapper.so was broken when compiled against uclibc. Runtime linker loader caused calling dm_task_get_info_base() function recursively, leading to segmentation fault. Introduce --with-symvers=STYLE option, which allows to choose between gnu and disabled symbol versioning. By default gnu symbol versioning is used. __GNUC__ check is replaced now with GNU_SYMVER. Additionally ld version script is included only in case of gnu option, which slightly reduces output size. Providing --without-symvers to configure script when building against uclibc library fixes segmentation fault error described above, due to lack of several versions of the same symbol in libdevmapper.so library. Based on: https://patchwork.kernel.org/project/dm-devel/patch/20180831144817.31207-1-m.niestroj@grinn-global.com/ Suggested-by: Marcin Niestroj --- configure.ac | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index b92be0db3..21a1d311e 100644 --- a/configure.ac +++ b/configure.ac @@ -30,13 +30,11 @@ AC_CANONICAL_TARGET([]) AS_IF([test -z "$CFLAGS"], [COPTIMISE_FLAG="-O2"]) case "$host_os" in linux*) - CLDFLAGS="${CLDFLAGS-"$LDFLAGS"} -Wl,--version-script,.export.sym" # equivalent to -rdynamic ELDFLAGS="-Wl,--export-dynamic" # FIXME Generate list and use --dynamic-list=.dlopen.sym CLDWHOLEARCHIVE="-Wl,-whole-archive" CLDNOWHOLEARCHIVE="-Wl,-no-whole-archive" - LDDEPS="$LDDEPS .export.sym" LIB_SUFFIX=so DEVMAPPER=yes BUILD_LVMPOLLD=no @@ -51,7 +49,6 @@ case "$host_os" in ;; darwin*) CFLAGS="$CFLAGS -no-cpp-precomp -fno-common" - CLDFLAGS="${CLDFLAGS-"$LDFLAGS"}" ELDFLAGS= CLDWHOLEARCHIVE="-all_load" CLDNOWHOLEARCHIVE= @@ -825,6 +822,29 @@ AC_ARG_WITH(optimisation, COPTIMISE_FLAG=$withval) AC_MSG_RESULT($COPTIMISE_FLAG) +################################################################################ +dnl -- Symbol versioning +AC_MSG_CHECKING(whether to use symbol versioning) +AC_ARG_WITH(symvers, + AC_HELP_STRING([--with-symvers=STYLE], + [use symbol versioning of the shared library [default=gnu]]), + [ case "$withval" in + gnu|no) symvers=$withval ;; + *) AC_MSG_ERROR(Unknown argument to with-symvers) ;; + esac], symvers=gnu) +AC_MSG_RESULT($symvers) + +if test "$GCC" = "yes" && test "$symvers" = "gnu" ; then + AC_DEFINE(GNU_SYMVER, 1, + [Define to use GNU versioning in the shared library.]) + case "$host_os" in + linux*) + CLDFLAGS="${CLDFLAGS-"$LDFLAGS"} -Wl,--version-script,.export.sym" + LDDEPS="$LDDEPS .export.sym" + ;; + esac +fi + ################################################################################ dnl -- Enable profiling AC_MSG_CHECKING(whether to gather gcov profiling data) -- cgit v1.2.1