Message ID | 20190410134517.63896-1-bruce.richardson@intel.com (mailing list archive) |
---|---|
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 282D869D4; Wed, 10 Apr 2019 15:45:27 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 55C0A5F19 for <dev@dpdk.org>; Wed, 10 Apr 2019 15:45:25 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Apr 2019 06:45:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,332,1549958400"; d="scan'208";a="141569309" Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.222.236]) by orsmga003.jf.intel.com with ESMTP; 10 Apr 2019 06:45:23 -0700 From: Bruce Richardson <bruce.richardson@intel.com> To: konstantin.ananyev@intel.com, aconole@redhat.com Cc: dev@dpdk.org, Bruce Richardson <bruce.richardson@intel.com> Date: Wed, 10 Apr 2019 14:45:15 +0100 Message-Id: <20190410134517.63896-1-bruce.richardson@intel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 0/2] remove use of weak functions from libraries X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions <dev.dpdk.org> List-Unsubscribe: <https://mails.dpdk.org/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://mails.dpdk.org/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <https://mails.dpdk.org/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Series |
remove use of weak functions from libraries
|
|
Message
Bruce Richardson
April 10, 2019, 1:45 p.m. UTC
Weak functions don't work well with static library builds as the linker always picks the first version of a function irrespective of whether it is weak or not. The solution to this is to use the "whole-archive" flag when linking, but this has the nasty side-effect that it causes the resulting binary to be larger than it needs to be. A further problem with this approach of using "whole-archive" is that one either needs to link all libraries with this flag or track what libraries need it or not - the latter being especially a problem for apps not using the DPDK build system itself (i.e. most apps not shipped with DPDK itself). For meson builds this information needs to make its way all the way through to the pkgconfig file generated - not a trivial undertaking. Thankfully, though, the use of weak functions is limited to use for multiple functions within a single library, meaning that when the lib is being built, the build system itself can know whether the "weak" function is needed or not. This allows us to change the weak function to a conditionally compiled regular function used in fallback case. This makes the need for "whole-archive" flag, and any special linking measures for the library, go away. [This set does not touch the drivers, only the libraries, since there are other special linker flags needed for drivers in general, making the problem less severe for driver .a files.] Bruce Richardson (2): acl: remove use of weak functions bpf: remove use of weak functions lib/librte_acl/meson.build | 7 ++++++- lib/librte_acl/rte_acl.c | 18 ++++++++++++++---- lib/librte_bpf/bpf_load.c | 4 +++- lib/librte_bpf/meson.build | 1 + mk/rte.app.mk | 3 --- 5 files changed, 24 insertions(+), 9 deletions(-)
Comments
Hello, On Wed, Apr 10, 2019 at 3:45 PM Bruce Richardson <bruce.richardson@intel.com> wrote: > Weak functions don't work well with static library builds as the linker > always picks the first version of a function irrespective of whether it is > weak or not. The solution to this is to use the "whole-archive" flag when > linking, but this has the nasty side-effect that it causes the resulting > binary to be larger than it needs to be. > > > A further problem with this approach of using "whole-archive" is that one > either needs to link all libraries with this flag or track what libraries > need it or not - the latter being especially a problem for apps not using > the DPDK build system itself (i.e. most apps not shipped with DPDK itself). > For meson builds this information needs to make its way all the way through > to the pkgconfig file generated - not a trivial undertaking. > > Thankfully, though, the use of weak functions is limited to use for > multiple functions within a single library, meaning that when the lib is > being built, the build system itself can know whether the "weak" function > is needed or not. This allows us to change the weak function to a > conditionally compiled regular function used in fallback case. This makes > the need for "whole-archive" flag, and any special linking measures for the > library, go away. > > [This set does not touch the drivers, only the libraries, since there are > other special linker flags needed for drivers in general, making the > problem less severe for driver .a files.] > > Was there something preventing this patchset from getting merged ?
On Mon, May 27, 2019 at 04:13:53PM +0200, David Marchand wrote: > Hello, > On Wed, Apr 10, 2019 at 3:45 PM Bruce Richardson > <[1]bruce.richardson@intel.com> wrote: > > Weak functions don't work well with static library builds as the > linker > always picks the first version of a function irrespective of whether > it is > weak or not. The solution to this is to use the "whole-archive" flag > when > linking, but this has the nasty side-effect that it causes the > resulting > binary to be larger than it needs to be. > A further problem with this approach of using "whole-archive" is > that one > either needs to link all libraries with this flag or track what > libraries > need it or not - the latter being especially a problem for apps not > using > the DPDK build system itself (i.e. most apps not shipped with DPDK > itself). > For meson builds this information needs to make its way all the way > through > to the pkgconfig file generated - not a trivial undertaking. > Thankfully, though, the use of weak functions is limited to use for > multiple functions within a single library, meaning that when the > lib is > being built, the build system itself can know whether the "weak" > function > is needed or not. This allows us to change the weak function to a > conditionally compiled regular function used in fallback case. This > makes > the need for "whole-archive" flag, and any special linking measures > for the > library, go away. > [This set does not touch the drivers, only the libraries, since > there are > other special linker flags needed for drivers in general, making the > problem less severe for driver .a files.] > > Was there something preventing this patchset from getting merged ? > -- > David Marchand > I believe Aaron Conole had some changes in the same area and was looking to roll these changes into a bigger patchset of his. Aaron, can you please confirm? /Bruce
Bruce Richardson <bruce.richardson@intel.com> writes: > On Mon, May 27, 2019 at 04:13:53PM +0200, David Marchand wrote: >> Hello, >> On Wed, Apr 10, 2019 at 3:45 PM Bruce Richardson >> <[1]bruce.richardson@intel.com> wrote: >> >> Weak functions don't work well with static library builds as the >> linker >> always picks the first version of a function irrespective of whether >> it is >> weak or not. The solution to this is to use the "whole-archive" flag >> when >> linking, but this has the nasty side-effect that it causes the >> resulting >> binary to be larger than it needs to be. >> A further problem with this approach of using "whole-archive" is >> that one >> either needs to link all libraries with this flag or track what >> libraries >> need it or not - the latter being especially a problem for apps not >> using >> the DPDK build system itself (i.e. most apps not shipped with DPDK >> itself). >> For meson builds this information needs to make its way all the way >> through >> to the pkgconfig file generated - not a trivial undertaking. >> Thankfully, though, the use of weak functions is limited to use for >> multiple functions within a single library, meaning that when the >> lib is >> being built, the build system itself can know whether the "weak" >> function >> is needed or not. This allows us to change the weak function to a >> conditionally compiled regular function used in fallback case. This >> makes >> the need for "whole-archive" flag, and any special linking measures >> for the >> library, go away. >> [This set does not touch the drivers, only the libraries, since >> there are >> other special linker flags needed for drivers in general, making the >> problem less severe for driver .a files.] >> >> Was there something preventing this patchset from getting merged ? >> -- >> David Marchand >> > I believe Aaron Conole had some changes in the same area and was looking to > roll these changes into a bigger patchset of his. Aaron, can you please > confirm? Yes - Sorry the patches are in my queue. Maybe it just makes sense to merge these though? > /Bruce
On Mon, May 27, 2019 at 04:57:15PM -0400, Aaron Conole wrote: > Bruce Richardson <bruce.richardson@intel.com> writes: > > > On Mon, May 27, 2019 at 04:13:53PM +0200, David Marchand wrote: > >> Hello, > >> On Wed, Apr 10, 2019 at 3:45 PM Bruce Richardson > >> <[1]bruce.richardson@intel.com> wrote: > >> > >> Weak functions don't work well with static library builds as the > >> linker > >> always picks the first version of a function irrespective of whether > >> it is > >> weak or not. The solution to this is to use the "whole-archive" flag > >> when > >> linking, but this has the nasty side-effect that it causes the > >> resulting > >> binary to be larger than it needs to be. > >> A further problem with this approach of using "whole-archive" is > >> that one > >> either needs to link all libraries with this flag or track what > >> libraries > >> need it or not - the latter being especially a problem for apps not > >> using > >> the DPDK build system itself (i.e. most apps not shipped with DPDK > >> itself). > >> For meson builds this information needs to make its way all the way > >> through > >> to the pkgconfig file generated - not a trivial undertaking. > >> Thankfully, though, the use of weak functions is limited to use for > >> multiple functions within a single library, meaning that when the > >> lib is > >> being built, the build system itself can know whether the "weak" > >> function > >> is needed or not. This allows us to change the weak function to a > >> conditionally compiled regular function used in fallback case. This > >> makes > >> the need for "whole-archive" flag, and any special linking measures > >> for the > >> library, go away. > >> [This set does not touch the drivers, only the libraries, since > >> there are > >> other special linker flags needed for drivers in general, making the > >> problem less severe for driver .a files.] > >> > >> Was there something preventing this patchset from getting merged ? > >> -- > >> David Marchand > >> > > I believe Aaron Conole had some changes in the same area and was looking to > > roll these changes into a bigger patchset of his. Aaron, can you please > > confirm? > > Yes - Sorry the patches are in my queue. Maybe it just makes sense to > merge these though? > Funnily enough, I've no objections to that :-)
10/04/2019 15:45, Bruce Richardson: > Weak functions don't work well with static library builds as the linker > always picks the first version of a function irrespective of whether it is > weak or not. The solution to this is to use the "whole-archive" flag when > linking, but this has the nasty side-effect that it causes the resulting > binary to be larger than it needs to be. > > > A further problem with this approach of using "whole-archive" is that one > either needs to link all libraries with this flag or track what libraries > need it or not - the latter being especially a problem for apps not using > the DPDK build system itself (i.e. most apps not shipped with DPDK itself). > For meson builds this information needs to make its way all the way through > to the pkgconfig file generated - not a trivial undertaking. > > Thankfully, though, the use of weak functions is limited to use for > multiple functions within a single library, meaning that when the lib is > being built, the build system itself can know whether the "weak" function > is needed or not. This allows us to change the weak function to a > conditionally compiled regular function used in fallback case. This makes > the need for "whole-archive" flag, and any special linking measures for the > library, go away. > > [This set does not touch the drivers, only the libraries, since there are > other special linker flags needed for drivers in general, making the > problem less severe for driver .a files.] > > Bruce Richardson (2): > acl: remove use of weak functions > bpf: remove use of weak functions Applied, thanks