DPDK patches and discussions
 help / color / mirror / Atom feed
From: Neil Horman <nhorman@tuxdriver.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v3 1/4] compat: Add infrastructure to support symbol versioning
Date: Tue, 23 Dec 2014 10:51:50 -0500	[thread overview]
Message-ID: <1419349913-21674-1-git-send-email-nhorman@tuxdriver.com> (raw)
In-Reply-To: <1419109299-9603-1-git-send-email-nhorman@tuxdriver.com>

Add initial pass header files to support symbol versioning.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: Thomas Monjalon <thomas.monjalon@6wind.com>
CC: "Richardson, Bruce" <bruce.richardson@intel.com>
CC: "Gonzalez Monroy, Sergio" <sergio.gonzalez.monroy@intel.com>

Change Notes:
V2)
	Moved ifeq to _INSTALL target

V3)
	Undo V2 changes and make librte_compat use the rte.install.mk file
instead
---
 lib/Makefile                   |  1 +
 lib/librte_compat/Makefile     | 38 +++++++++++++++++
 lib/librte_compat/rte_compat.h | 96 ++++++++++++++++++++++++++++++++++++++++++
 mk/rte.lib.mk                  |  4 ++
 4 files changed, 139 insertions(+)
 create mode 100644 lib/librte_compat/Makefile
 create mode 100644 lib/librte_compat/rte_compat.h

diff --git a/lib/Makefile b/lib/Makefile
index 0ffc982..d617d81 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -31,6 +31,7 @@
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
+DIRS-y += librte_compat
 DIRS-$(CONFIG_RTE_LIBRTE_EAL) += librte_eal
 DIRS-$(CONFIG_RTE_LIBRTE_MALLOC) += librte_malloc
 DIRS-$(CONFIG_RTE_LIBRTE_RING) += librte_ring
diff --git a/lib/librte_compat/Makefile b/lib/librte_compat/Makefile
new file mode 100644
index 0000000..46d5905
--- /dev/null
+++ b/lib/librte_compat/Makefile
@@ -0,0 +1,38 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2010-2014 Neil Horman <nhorman@tuxdriver.com>
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above copyright
+#       notice, this list of conditions and the following disclaimer in
+#       the documentation and/or other materials provided with the
+#       distribution.
+#     * Neither the name of Intel Corporation nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+
+# install includes
+SYMLINK-y-include := rte_compat.h
+
+include $(RTE_SDK)/mk/rte.install.mk
diff --git a/lib/librte_compat/rte_compat.h b/lib/librte_compat/rte_compat.h
new file mode 100644
index 0000000..d99e362
--- /dev/null
+++ b/lib/librte_compat/rte_compat.h
@@ -0,0 +1,96 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2014 Neil Horman <nhorman@tuxdriver.com>.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Intel Corporation nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _RTE_COMPAT_H_
+#define _RTE_COMPAT_H_
+
+/*
+ * This is just a stringification macro for use below.
+ */
+#define SA(x) #x
+
+#ifdef RTE_BUILD_SHARED_LIB
+
+/*
+ * Provides backwards compatibility when updating exported functions.
+ * When a symol is exported from a library to provide an API, it also provides a
+ * calling convention (ABI) that is embodied in its name, return type,
+ * arguments, etc.  On occasion that function may need to change to accomodate
+ * new functionality, behavior, etc.  When that occurs, it is desireable to
+ * allow for backwards compatibility for a time with older binaries that are
+ * dynamically linked to the dpdk.  to support that the __vsym and
+ * VERSION_SYMBOL macros are created.  They, in conjunction with the
+ * <library>_version.map file for a given library allow for multiple versions of
+ * a symbol to exist in a shared library so that older binaries need not be
+ * immediately recompiled. Their use is outlined in the following example:
+ * Assumptions: DPDK 1.(X) contains a function int foo(char *string)
+ *              DPDK 1.(X+1) needs to change foo to be int foo(int index)
+ *
+ * To accomplish this:
+ * 1) Edit lib/<library>/library_version.map to add a DPDK_1.(X+1) node, in which
+ * foo is exported as a global symbol.
+ *
+ * 2) rename the existing function int foo(char *string) to 
+ * 	int __vsym foo_v18(char *string)
+ *
+ * 3) Add this macro immediately below the function
+ * 	VERSION_SYMBOL(foo, _v18, 1.8);
+ *
+ * 4) Implement a new version of foo.
+ * 	char foo(int value, int otherval) { ...}
+ *
+ * 5) Mark the newest version as the default version
+ * 	BIND_DEFAULT_SYMBOL(foo, 1.9);
+ *
+ */
+#define VERSION_SYMBOL(b, e, v) __asm__(".symver " SA(b) SA(e) ", "SA(b)"@DPDK_"SA(v))
+#define BASE_SYMBOL(b, n) __asm__(".symver " SA(n) ", "SA(b)"@")
+#define BIND_DEFAULT_SYMBOL(b, v) __asm__(".symver " SA(b) ", "SA(b)"@@DPDK_"SA(v))
+#define __vsym __attribute__((used))
+
+#else
+/*
+ * No symbol versioning in use
+ */
+#define VERSION_SYMBOL(b, e, v)
+#define __vsym
+#define BASE_SYMBOL(b, n)
+#define BIND_DEFAULT_SYMBOL(b, v)
+
+/*
+ * RTE_BUILD_SHARED_LIB
+ */
+#endif
+
+
+#endif /* _RTE_COMPAT_H_ */
diff --git a/mk/rte.lib.mk b/mk/rte.lib.mk
index 81bf8e1..75e3652 100644
--- a/mk/rte.lib.mk
+++ b/mk/rte.lib.mk
@@ -40,8 +40,12 @@ VPATH += $(SRCDIR)
 
 ifeq ($(RTE_BUILD_SHARED_LIB),y)
 LIB := $(patsubst %.a,%.so,$(LIB))
+
+CPU_LDFLAGS += --version-script=$(EXPORT_MAP)
+
 endif
 
+
 _BUILD = $(LIB)
 _INSTALL = $(INSTALL-FILES-y) $(SYMLINK-FILES-y) $(RTE_OUTPUT)/lib/$(LIB)
 _CLEAN = doclean
-- 
1.9.3

  parent reply	other threads:[~2014-12-23 15:52 UTC|newest]

Thread overview: 99+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-20 21:01 [dpdk-dev] Add DSO symbol versioning to supportbackwards compatibility Neil Horman
2014-12-20 21:01 ` [dpdk-dev] [PATCH 1/4] compat: Add infrastructure to support symbol versioning Neil Horman
2014-12-22 14:01   ` Gonzalez Monroy, Sergio
2014-12-22 16:22     ` Neil Horman
2014-12-22 16:34     ` Neil Horman
2014-12-22 17:09       ` Gonzalez Monroy, Sergio
2014-12-22 19:00         ` Neil Horman
2014-12-22 20:04           ` Neil Horman
2014-12-20 21:01 ` [dpdk-dev] [PATCH 2/4] Provide initial versioning for all DPDK libraries Neil Horman
2014-12-20 21:01 ` [dpdk-dev] [PATCH 3/4] Add library version extenstion Neil Horman
2014-12-20 21:01 ` [dpdk-dev] [PATCH 4/4] docs: Add ABI documentation Neil Horman
2014-12-22 20:24 ` [dpdk-dev] [PATCH v2 1/4] compat: Add infrastructure to support symbol versioning Neil Horman
2014-12-22 20:24   ` [dpdk-dev] [PATCH v2 2/4] Provide initial versioning for all DPDK libraries Neil Horman
2014-12-22 20:24   ` [dpdk-dev] [PATCH v2 3/4] Add library version extenstion Neil Horman
2014-12-23 13:05     ` Gonzalez Monroy, Sergio
2014-12-23 15:50       ` Neil Horman
2014-12-22 20:24   ` [dpdk-dev] [PATCH v2 4/4] docs: Add ABI documentation Neil Horman
2014-12-23  9:48     ` Iremonger, Bernard
2014-12-23 13:01       ` Neil Horman
2014-12-23 13:27   ` [dpdk-dev] [PATCH v2 1/4] compat: Add infrastructure to support symbol versioning Gonzalez Monroy, Sergio
2014-12-23 15:50     ` Neil Horman
2014-12-23 15:51 ` Neil Horman [this message]
2014-12-23 15:51   ` [dpdk-dev] [PATCH v3 2/4] Provide initial versioning for all DPDK libraries Neil Horman
2014-12-29 16:21     ` Sergio Gonzalez Monroy
2015-01-14 15:29     ` Thomas Monjalon
2015-01-14 16:24       ` Neil Horman
2014-12-23 15:51   ` [dpdk-dev] [PATCH v3 3/4] Add library version extenstion Neil Horman
2014-12-23 16:44     ` Gonzalez Monroy, Sergio
2014-12-23 17:08       ` Neil Horman
2014-12-29 16:23     ` Sergio Gonzalez Monroy
2015-01-14 15:48     ` Thomas Monjalon
2014-12-23 15:51   ` [dpdk-dev] [PATCH v3 4/4] docs: Add ABI documentation Neil Horman
2014-12-29 16:24     ` Sergio Gonzalez Monroy
2015-01-14 15:59     ` Thomas Monjalon
2015-01-14 20:07       ` Neil Horman
2015-01-16 13:34         ` Thomas Monjalon
2014-12-29 16:20   ` [dpdk-dev] [PATCH v3 1/4] compat: Add infrastructure to support symbol versioning Sergio Gonzalez Monroy
2015-01-14 15:25   ` Thomas Monjalon
2015-01-14 20:29     ` Neil Horman
2015-01-09 12:35 ` [dpdk-dev] Add DSO symbol versioning to supportbackwards compatibility Neil Horman
2015-01-15 19:35 ` [dpdk-dev] [PATCH v4 1/4] compat: Add infrastructure to support symbol versioning Neil Horman
2015-01-15 19:35   ` [dpdk-dev] [PATCH v4 2/4] Provide initial versioning for all DPDK libraries Neil Horman
2015-01-15 19:35   ` [dpdk-dev] [PATCH v4 3/4] Add library version extenstion Neil Horman
2015-01-15 19:35   ` [dpdk-dev] [PATCH v4 4/4] docs: Add ABI documentation Neil Horman
2015-01-30 17:13   ` [dpdk-dev] [PATCH v4 1/4] compat: Add infrastructure to support symbol versioning Gray, Mark D
2015-01-16 15:33 ` [dpdk-dev] [PATCH v5 " Neil Horman
2015-01-16 15:33   ` [dpdk-dev] [PATCH v5 2/4] Provide initial versioning for all DPDK libraries Neil Horman
2015-01-16 15:33   ` [dpdk-dev] [PATCH v5 3/4] Add library version extenstion Neil Horman
2015-01-16 15:33   ` [dpdk-dev] [PATCH v5 4/4] docs: Add ABI documentation Neil Horman
2015-01-20  7:14     ` Thomas Monjalon
2015-01-20 10:47       ` Bruce Richardson
2015-01-20 13:37       ` Iremonger, Bernard
2015-01-20 13:46         ` Thomas Monjalon
2015-01-20 14:24         ` Neil Horman
2015-01-20 14:29           ` Butler, Siobhan A
2015-01-20 14:41             ` Neil Horman
2015-01-20 14:50               ` Butler, Siobhan A
2015-01-20 15:30                 ` Neil Horman
2015-01-20 14:32           ` O'driscoll, Tim
2015-01-20 14:00     ` Thomas Monjalon
2015-01-20 14:37       ` Neil Horman
2015-01-20 15:06         ` Thomas Monjalon
2015-01-20 15:35           ` Neil Horman
2015-01-20 21:17 ` [dpdk-dev] [PATCH v6 1/4] compat: Add infrastructure to support symbol versioning Neil Horman
2015-01-20 21:17   ` [dpdk-dev] [PATCH v6 2/4] Provide initial versioning for all DPDK libraries Neil Horman
2015-01-20 21:17   ` [dpdk-dev] [PATCH v6 3/4] Add library version extenstion Neil Horman
2015-01-20 21:17   ` [dpdk-dev] [PATCH v6 4/4] docs: Add ABI documentation Neil Horman
2015-01-21 10:13     ` Iremonger, Bernard
2015-01-21 10:25     ` Thomas Monjalon
2015-01-21 14:59       ` Neil Horman
2015-01-21 16:05         ` Thomas Monjalon
2015-01-21 19:43           ` Neil Horman
2015-01-21 22:24             ` Thomas Monjalon
2015-01-22 19:21               ` Neil Horman
2015-01-21 20:57 ` [dpdk-dev] [PATCH v7 01/26] version: 2.0.0-rc0 Neil Horman
2015-01-21 20:57   ` [dpdk-dev] [PATCH v7 02/26] mk: fix link to static combined library Neil Horman
2015-01-21 20:57   ` [dpdk-dev] [PATCH v7 03/26] eal: fix check for power of 2 in 0 case Neil Horman
2015-01-21 20:57   ` [dpdk-dev] [PATCH v7 04/26] ethdev: fix missing parenthesis in mac check Neil Horman
2015-01-21 20:57   ` [dpdk-dev] [PATCH v7 05/26] mem: search only dpdk hugetlbfs maps Neil Horman
2015-01-21 20:57   ` [dpdk-dev] [PATCH v7 06/26] log: remove unnecessary stubs Neil Horman
2015-01-21 20:57   ` [dpdk-dev] [PATCH v7 07/26] vfio: avoid enabling while the module is not loaded Neil Horman
2015-01-21 20:57   ` [dpdk-dev] [PATCH v7 08/26] bond: fix vlan flag interpretation Neil Horman
2015-01-21 20:57   ` [dpdk-dev] [PATCH v7 09/26] app/testpmd: remove duplicated function for list parsing Neil Horman
2015-01-21 20:57   ` [dpdk-dev] [PATCH v7 10/26] nic_uio: fix thread structure compatibility for future FreeBSD Neil Horman
2015-01-21 20:58   ` [dpdk-dev] [PATCH v7 01/26] version: 2.0.0-rc0 Neil Horman
2015-01-21 20:59 ` [dpdk-dev] [PATCH v7 1/4] compat: Add infrastructure to support symbol versioning Neil Horman
2015-01-21 20:59   ` [dpdk-dev] [PATCH v7 2/4] Provide initial versioning for all DPDK libraries Neil Horman
2015-01-21 20:59   ` [dpdk-dev] [PATCH v7 3/4] Add library version extenstion Neil Horman
2015-01-21 20:59   ` [dpdk-dev] [PATCH v7 4/4] docs: Add ABI documentation Neil Horman
2015-01-22 10:56     ` Iremonger, Bernard
2015-01-22 15:37       ` Neil Horman
2015-01-22 15:49 ` [dpdk-dev] [PATCH v8 1/4] compat: Add infrastructure to support symbol versioning Neil Horman
2015-01-22 15:49   ` [dpdk-dev] [PATCH v8 2/4] Provide initial versioning for all DPDK libraries Neil Horman
2015-01-22 15:49   ` [dpdk-dev] [PATCH v8 3/4] Add library version extenstion Neil Horman
2015-01-22 15:49   ` [dpdk-dev] [PATCH v8 4/4] docs: Add ABI documentation Neil Horman
2015-01-22 16:46     ` Butler, Siobhan A
     [not found] ` <1422898822-16422-1-git-send-email-nhorman@tuxdriver.com>
     [not found]   ` <1422898822-16422-4-git-send-email-nhorman@tuxdriver.com>
2015-02-03 15:24     ` [dpdk-dev] [PATCH v9 " Thomas Monjalon
2015-02-03 16:01 ` [dpdk-dev] Add DSO symbol versioning to supportbackwards compatibility Thomas Monjalon
2015-02-03 20:20   ` Neil Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1419349913-21674-1-git-send-email-nhorman@tuxdriver.com \
    --to=nhorman@tuxdriver.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).