From patchwork Fri Aug 31 14:48:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Niestroj X-Patchwork-Id: 10583965 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 44D2C175A for ; Fri, 31 Aug 2018 14:48:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3438A2BA7B for ; Fri, 31 Aug 2018 14:48:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 27F4F2BB84; Fri, 31 Aug 2018 14:48:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0511A2BA7B for ; Fri, 31 Aug 2018 14:48:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 83ABE81102; Fri, 31 Aug 2018 14:48:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6D68575527; Fri, 31 Aug 2018 14:48:50 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 828A84BB75; Fri, 31 Aug 2018 14:48:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7VEmjYO003309 for ; Fri, 31 Aug 2018 10:48:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id 28D30611B4; Fri, 31 Aug 2018 14:48:45 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1F4A960D29 for ; Fri, 31 Aug 2018 14:48:41 +0000 (UTC) Received: from smtp.megiteam.pl (smtp.megiteam.pl [31.186.83.105]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 535963086250 for ; Fri, 31 Aug 2018 14:48:37 +0000 (UTC) Received: from [95.143.241.142] (helo=localhost.localdomain) by smtp.megiteam.pl with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1fvkin-0007Q8-G9; Fri, 31 Aug 2018 16:48:33 +0200 From: Marcin Niestroj To: dm-devel@redhat.com Date: Fri, 31 Aug 2018 16:48:17 +0200 Message-Id: <20180831144817.31207-1-m.niestroj@grinn-global.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 212 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 31 Aug 2018 14:48:38 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 31 Aug 2018 14:48:38 +0000 (UTC) for IP:'31.186.83.105' DOMAIN:'smtp.megiteam.pl' HELO:'smtp.megiteam.pl' FROM:'m.niestroj@grinn-global.com' RCPT:'' X-RedHat-Spam-Score: -0.012 (RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS) 31.186.83.105 smtp.megiteam.pl 31.186.83.105 smtp.megiteam.pl X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: dm-devel@redhat.com Cc: Marcin Niestroj Subject: [dm-devel] [RESEND PATCH v2] configure: Introduce --enable-symvers option X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 31 Aug 2018 14:48:55 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Only few libc (e.g. glibc) libraries support full symbol version resolution in runtime. There are lot of standard libraries that do not support that, such as dietlibc, musl and uclibc. Hence there is no reason to 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 --enable-symvers[=STYLE] option, which allows to choose between gnu and disabled symbol versioning. By default gnu symbol versioning is used to provide backward compatibility. __GNUC__ check is replaced now with GNU_SYMVER, which is generated by configure script. Additionally ld version script is included only in case of gnu option, which slightly reduces output size. Providing --disable-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. Signed-off-by: Marcin Niestroj --- Hi, I am resending rebased (on master) patch. Changes v1 -> v2: * Set LDDEPS only when --enable-symvers=gnu WHATS_NEW | 1 + configure | 36 +++++++++++++++++++++++++++++++++--- configure.ac | 28 +++++++++++++++++++++++++--- include/configure.h.in | 3 +++ lib/misc/lib.h | 10 +++++----- libdm/datastruct/bitset.c | 5 +---- libdm/ioctl/libdm-iface.c | 2 +- libdm/libdm-deptree.c | 2 +- libdm/libdm-stats.c | 2 +- 9 files changed, 71 insertions(+), 18 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 6003f0a1b..f49c1d298 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 3.0.0 ============= + Introduce --enable-symvers[=STYLE] switch. Add 'lvm2-activation-generator:' prefix for kmsg messages logged by generator. Add After=rbdmap.service to {lvm2-activation-net,blk-availability}.service. Reduce max concurrent aios to avoid EMFILE with many devices. diff --git a/configure b/configure index d6ddbc2fa..f0ac95d13 100755 --- a/configure +++ b/configure @@ -955,6 +955,7 @@ enable_fsadm enable_blkdeactivate enable_dmeventd enable_selinux +enable_symvers enable_nls with_localedir with_confdir @@ -1670,6 +1671,9 @@ Optional Features: --disable-blkdeactivate disable blkdeactivate --enable-dmeventd enable the device-mapper event daemon --disable-selinux disable selinux support + --enable-symvers[=STYLE] + enables symbol versioning of the shared library + [default=gnu] --enable-nls enable Native Language Support Optional Packages: @@ -3067,13 +3071,11 @@ if test -z "$CFLAGS"; then : fi case "$host_os" in linux*) - CLDFLAGS="$CLDFLAGS -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 @@ -3087,7 +3089,6 @@ case "$host_os" in ;; darwin*) CFLAGS="$CFLAGS -no-cpp-precomp -fno-common" - CLDFLAGS="$CLDFLAGS" ELDFLAGS= CLDWHOLEARCHIVE="-all_load" CLDNOWHOLEARCHIVE= @@ -12820,6 +12821,35 @@ done LIBS=$lvm_saved_libs fi +################################################################################ +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable symbol versioning" >&5 +$as_echo_n "checking whether to enable symbol versioning... " >&6; } +# Check whether --enable-symvers was given. +if test "${enable_symvers+set}" = set; then : + enableval=$enable_symvers; + case "$enableval" in + gnu|no) ;; + *) as_fn_error $? "Unknown argument to enable/disable symvers" "$LINENO" 5 ;; + esac +else + enable_symvers=gnu +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_symvers" >&5 +$as_echo "$enable_symvers" >&6; } + +if test x$GCC = xyes && test x$enable_symvers = xgnu ; then + +$as_echo "#define GNU_SYMVER 1" >>confdefs.h + + case "$host_os" in + linux*) + CLDFLAGS="$CLDFLAGS -Wl,--version-script,.export.sym" + LDDEPS="$LDDEPS .export.sym" + ;; + esac +fi + ################################################################################ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable internationalisation" >&5 $as_echo_n "checking whether to enable internationalisation... " >&6; } diff --git a/configure.ac b/configure.ac index 6d9308fec..0131664e2 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 -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 @@ -50,7 +48,6 @@ case "$host_os" in ;; darwin*) CFLAGS="$CFLAGS -no-cpp-precomp -fno-common" - CLDFLAGS="$CLDFLAGS" ELDFLAGS= CLDWHOLEARCHIVE="-all_load" CLDNOWHOLEARCHIVE= @@ -1359,6 +1356,31 @@ package as well (which may be called readline-devel or something similar).]) LIBS=$lvm_saved_libs fi +################################################################################ +dnl -- Symbol versioning +AC_MSG_CHECKING(whether to enable symbol versioning) +AC_ARG_ENABLE(symvers, + AC_HELP_STRING([--enable-symvers[[[=STYLE]]]], + [enables symbol versioning of the shared library [default=gnu]]), + [ + case "$enableval" in + gnu|no) ;; + *) AC_MSG_ERROR(Unknown argument to enable/disable symvers) ;; + esac], + enable_symvers=gnu) +AC_MSG_RESULT($enable_symvers) + +if test x$GCC = xyes && test x$enable_symvers = xgnu ; then + AC_DEFINE(GNU_SYMVER, 1, + [Define to use GNU versioning in the shared library.]) + case "$host_os" in + linux*) + CLDFLAGS="$CLDFLAGS -Wl,--version-script,.export.sym" + LDDEPS="$LDDEPS .export.sym" + ;; + esac +fi + ################################################################################ dnl -- Internationalisation stuff AC_MSG_CHECKING(whether to enable internationalisation) diff --git a/include/configure.h.in b/include/configure.h.in index f68b09238..15491a17b 100644 --- a/include/configure.h.in +++ b/include/configure.h.in @@ -135,6 +135,9 @@ /* Path to fsadm binary. */ #undef FSADM_PATH +/* Define to use GNU versioning in the shared library. */ +#undef GNU_SYMVER + /* Define to 1 if you have the `alarm' function. */ #undef HAVE_ALARM diff --git a/lib/misc/lib.h b/lib/misc/lib.h index f7baf9dba..0b4dfe911 100644 --- a/lib/misc/lib.h +++ b/lib/misc/lib.h @@ -41,16 +41,16 @@ * macro DM_EXPORT_SYMBOL to export the function and bind it to the * specified version string. * - * Since versioning is only available when compiling with GCC the entire - * compatibility version should be enclosed in '#if defined(__GNUC__)', - * for example: + * Since versioning is only available when compiling with GCC + * and GLIBC the entire compatibility version should be enclosed + * in '#if defined(GNU_SYMVER)', for example: * * int dm_foo(int bar) * { * return bar; * } * - * #if defined(__GNUC__) + * #if defined(GNU_SYMVER) * // Backward compatible dm_foo() version 1.02.104 * int dm_foo_v1_02_104(void); * int dm_foo_v1_02_104(void) @@ -67,7 +67,7 @@ * versions of library symbols prior to the introduction of symbol * versioning: it must never be used for new symbols. */ -#if defined(__GNUC__) +#if defined(GNU_SYMVER) #define DM_EXPORT_SYMBOL(func, ver) \ __asm__(".symver " #func "_v" #ver ", " #func "@DM_" #ver ) #define DM_EXPORT_SYMBOL_BASE(func) \ diff --git a/libdm/datastruct/bitset.c b/libdm/datastruct/bitset.c index 06bd31a9d..65ab5f184 100644 --- a/libdm/datastruct/bitset.c +++ b/libdm/datastruct/bitset.c @@ -242,7 +242,7 @@ bad: return NULL; } -#if defined(__GNUC__) +#if defined(GNU_SYMVER) /* * Maintain backward compatibility with older versions that did not * accept a 'min_num_bits' argument to dm_bitset_parse_list(). @@ -253,7 +253,4 @@ dm_bitset_t dm_bitset_parse_list_v1_02_129(const char *str, struct dm_pool *mem) return dm_bitset_parse_list(str, mem, 0); } DM_EXPORT_SYMBOL(dm_bitset_parse_list, 1_02_129); - -#else /* if defined(__GNUC__) */ - #endif diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c index e775da7d9..e224cf586 100644 --- a/libdm/ioctl/libdm-iface.c +++ b/libdm/ioctl/libdm-iface.c @@ -2145,7 +2145,7 @@ void dm_lib_exit(void) _version_checked = 0; } -#if defined(__GNUC__) +#if defined(GNU_SYMVER) /* * Maintain binary backward compatibility. * Version script mechanism works with 'gcc' compatible compilers only. diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c index 3e602e28b..9313af181 100644 --- a/libdm/libdm-deptree.c +++ b/libdm/libdm-deptree.c @@ -3797,7 +3797,7 @@ void dm_tree_node_set_callback(struct dm_tree_node *dnode, dnode->callback_data = data; } -#if defined(__GNUC__) +#if defined(GNU_SYMVER) /* * Backward compatible implementations. * diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c index e9bfa9de9..691938f2c 100644 --- a/libdm/libdm-stats.c +++ b/libdm/libdm-stats.c @@ -5065,7 +5065,7 @@ int dm_stats_start_filemapd(int fd, uint64_t group_id, const char *path, * current dm_stats_create_region() version. */ -#if defined(__GNUC__) +#if defined(GNU_SYMVER) int dm_stats_create_region_v1_02_106(struct dm_stats *dms, uint64_t *region_id, uint64_t start, uint64_t len, int64_t step, int precise, const char *program_id,