From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7FF8EA034F; Wed, 6 May 2020 17:42:00 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8FA181D9C9; Wed, 6 May 2020 17:41:59 +0200 (CEST) Received: from relay0171.mxlogin.com (relay0171.mxlogin.com [199.181.239.171]) by dpdk.org (Postfix) with ESMTP id F00D11D904 for ; Wed, 6 May 2020 17:41:57 +0200 (CEST) Received: from filter003.mxroute.com ([168.235.111.26] 168-235-111-26.cloud.ramnode.com) (Authenticated sender: mN4UYu2MZsgR) by relay0171.mxlogin.com (ZoneMTA) with ESMTPSA id 171eaa68400000167e.001 for (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Wed, 06 May 2020 15:41:53 +0000 X-Zone-Loop: 8e4967814d06a5d86b7e1b98fe8b4b7087fadfff8520 X-Originating-IP: [168.235.111.26] Received: from galaxy.mxroute.com (unknown [23.92.70.113]) by filter003.mxroute.com (Postfix) with ESMTPS id 825E66000E; Wed, 6 May 2020 15:41:52 +0000 (UTC) Received: from irdmzpr01-ext.ir.intel.com ([192.198.151.36] helo=localhost) by galaxy.mxroute.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.91) (envelope-from ) id 1jWLkS-0005b0-A3; Wed, 06 May 2020 11:14:12 -0400 From: Ray Kinsella To: dev@dpdk.org Cc: arkadiuszx.kusztal@intel.com, bruce.richardson@intel.com, Ray Kinsella , Neil Horman , John McNamara , Marko Kovacevic Date: Wed, 6 May 2020 16:41:05 +0100 Message-Id: <1588779668-1522-1-git-send-email-mdr@ashroe.eu> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1588700970-1481-1-git-send-email-mdr@ashroe.eu> References: <1588700970-1481-1-git-send-email-mdr@ashroe.eu> X-AuthUser: mdr@ashroe.eu Subject: [dpdk-dev] [PATCH v3] doc: fix references to bind_default_symbol X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The document abi_versioning.rst incorrectly instructs the developer to add BIND_DEFAULT_SYMBOL to the public header, not the source file. This commit fixes the issue and adds some clarifications. The commit also clarifies the use of use_function_versioning in the meson/ninja build system, and does some minor re-organization of the document. Signed-off-by: Ray Kinsella --- v3: * added a note to ask contributors to ensure they review the meson/ninja section when adding "rte_function_versioning.h". doc/guides/contributing/abi_versioning.rst | 131 +++++++++++++++++++---------- 1 file changed, 87 insertions(+), 44 deletions(-) diff --git a/doc/guides/contributing/abi_versioning.rst b/doc/guides/contributing/abi_versioning.rst index a21f4e7..7065979 100644 --- a/doc/guides/contributing/abi_versioning.rst +++ b/doc/guides/contributing/abi_versioning.rst @@ -200,7 +200,7 @@ private, is safe), but it also requires modifying the code as follows Note also that, being a public function, the header file prototype must also be changed, as must all the call sites, to reflect the new ABI footprint. We will maintain previous ABI versions that are accessible only to previously compiled -binaries +binaries. The addition of a parameter to the function is ABI breaking as the function is public, and existing application may use it in its current form. However, the @@ -266,12 +266,12 @@ This file needs to be modified as follows } DPDK_20; -The addition of the new block tells the linker that a new version node is -available (DPDK_21), which contains the symbol rte_acl_create, and inherits -the symbols from the DPDK_20 node. This list is directly translated into a -list of exported symbols when DPDK is compiled as a shared library +The addition of the new block tells the linker that a new version node +``DPDK_21`` is available, which contains the symbol rte_acl_create, and inherits +the symbols from the DPDK_20 node. This list is directly translated into a list +of exported symbols when DPDK is compiled as a shared library. -Next, we need to specify in the code which function map to the rte_acl_create +Next, we need to specify in the code which function maps to the rte_acl_create symbol at which versions. First, at the site of the initial symbol definition, we need to update the function so that it is uniquely named, and not in conflict with the public symbol name @@ -288,24 +288,29 @@ with the public symbol name ... Note that the base name of the symbol was kept intact, as this is conducive to -the macros used for versioning symbols and we have annotated the function as an -implementation of versioned symbol. That is our next step, mapping this new -symbol name to the initial symbol name at version node 20. Immediately after -the function, we add this line of code +the macros used for versioning symbols and we have annotated the function as +``__vsym``, an implementation of a versioned symbol . That is our next step, +mapping this new symbol name to the initial symbol name at version node 20. +Immediately after the function, we add the VERSION_SYMBOL macro. .. code-block:: c + #include ; + + ... VERSION_SYMBOL(rte_acl_create, _v20, 20); Remembering to also add the rte_function_versioning.h header to the requisite c -file where these changes are being made. The above macro instructs the linker to +file where these changes are being made. The macro instructs the linker to create a new symbol ``rte_acl_create@DPDK_20``, which matches the symbol created in older builds, but now points to the above newly named function. We have now mapped the original rte_acl_create symbol to the original function (but with a new name). -Next, we need to create the 21 version of the symbol. We create a new function -name, with a different suffix, and implement it appropriately +Please see the section :ref:`Enabling versioning macros +` to enable this macro in the meson/ninja build. +Next, we need to create the new ``v21`` version of the symbol. We create a new +function name, with the ``v21`` suffix, and implement it appropriately .. code-block:: c @@ -320,35 +325,57 @@ name, with a different suffix, and implement it appropriately } This code serves as our new API call. Its the same as our old call, but adds the -new parameter in place. Next we need to map this function to the symbol -``rte_acl_create@DPDK_21``. To do this, we modify the public prototype of the -call in the header file, adding the macro there to inform all including -applications, that on re-link, the default rte_acl_create symbol should point to -this function. Note that we could do this by simply naming the function above -rte_acl_create, and the linker would chose the most recent version tag to apply -in the version script, but we can also do this in the header file +new parameter in place. Next we need to map this function to the new default +symbol ``rte_acl_create@DPDK_21``. To do this, immediately after the function, +we add the BIND_DEFAULT_SYMBOL macro. + +.. code-block:: c + + #include ; + + ... + BIND_DEFAULT_SYMBOL(rte_acl_create, _v21, 21); + +The macro instructs the linker to create the new default symbol +``rte_acl_create@DPDK_21``, which points to the above newly named function. + +We finally modify the prototype of the call in the public header file, +such that it contains both versions of the symbol and the public api. .. code-block:: c struct rte_acl_ctx * - -rte_acl_create(const struct rte_acl_param *param); - +rte_acl_create_v21(const struct rte_acl_param *param, int debug); - +BIND_DEFAULT_SYMBOL(rte_acl_create, _v21, 21); - -The BIND_DEFAULT_SYMBOL macro explicitly tells applications that include this -header, to link to the rte_acl_create_v21 function and apply the DPDK_21 -version node to it. This method is more explicit and flexible than just -re-implementing the exact symbol name, and allows for other features (such as -linking to the old symbol version by default, when the new ABI is to be opt-in -for a period. - -One last thing we need to do. Note that we've taken what was a public symbol, -and duplicated it into two uniquely and differently named symbols. We've then -mapped each of those back to the public symbol ``rte_acl_create`` with different -version tags. This only applies to dynamic linking, as static linking has no -notion of versioning. That leaves this code in a position of no longer having a -symbol simply named ``rte_acl_create`` and a static build will fail on that -missing symbol. + rte_acl_create(const struct rte_acl_param *param); + + struct rte_acl_ctx * __vsym + rte_acl_create_v20(const struct rte_acl_param *param); + + struct rte_acl_ctx * __vsym + rte_acl_create_v21(const struct rte_acl_param *param, int debug); + + +And that's it, on the next shared library rebuild, there will be two versions of +rte_acl_create, an old DPDK_20 version, used by previously built applications, +and a new DPDK_21 version, used by future built applications. + +.. note:: + + **Before you leave**, please take care to the review the sections on + :ref:`Mapping static symbols `, :ref:`Enabling + versioning macros ` and :ref:`ABI deprecation + `. + +.. _mapping_static_symbols: + +Mapping static symbols +______________________ + +Now we've taken what was a public symbol, and duplicated it into two uniquely +and differently named symbols. We've then mapped each of those back to the +public symbol ``rte_acl_create`` with different version tags. This only applies +to dynamic linking, as static linking has no notion of versioning. That leaves +this code in a position of no longer having a symbol simply named +``rte_acl_create`` and a static build will fail on that missing symbol. To correct this, we can simply map a function of our choosing back to the public symbol in the static build with the ``MAP_STATIC_SYMBOL`` macro. Generally the @@ -369,15 +396,31 @@ defined, we add this That tells the compiler that, when building a static library, any calls to the symbol ``rte_acl_create`` should be linked to ``rte_acl_create_v21`` -That's it, on the next shared library rebuild, there will be two versions of -rte_acl_create, an old DPDK_20 version, used by previously built applications, -and a new DPDK_21 version, used by future built applications. +.. _enabling_versioning_macros: + +Enabling versioning macros +__________________________ + +Finally, we need to indicate to the :doc:`meson/ninja build system +<../prog_guide/build-sdk-meson>` to enable versioning macros when building the +library or driver. In the libraries or driver where we have added symbol +versioning, in the ``meson.build`` file we add the following + +.. code-block:: + + use_function_versioning = true + +at the start of the head of the file. This will indicate to the tool-chain to +enable the function version macros when building. There is no corresponding +directive required for the ``make`` build system. + +.. _abi_decprecation: Deprecating part of a public API ________________________________ -Lets assume that you've done the above update, and in preparation for the next +Lets assume that you've done the above updates, and in preparation for the next major ABI version you decide you would like to retire the old version of the function. After having gone through the ABI deprecation announcement process, removal is easy. Start by removing the symbol from the requisite version map @@ -421,8 +464,8 @@ Next remove the corresponding versioned export. Note that the internal function definition could also be removed, but its used -in our example by the newer version v21, so we leave it in place and declare it -as static. This is a coding style choice. +in our example by the newer version ``v21``, so we leave it in place and declare +it as static. This is a coding style choice. .. _deprecating_entire_abi: -- 2.7.4