From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id A8F091B104 for ; Wed, 10 Apr 2019 16:07:35 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 04101C0220; Wed, 10 Apr 2019 14:07:35 +0000 (UTC) Received: from dhcp-25.97.bos.redhat.com (unknown [10.18.25.61]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 862795D722; Wed, 10 Apr 2019 14:07:34 +0000 (UTC) From: Aaron Conole To: Bruce Richardson Cc: konstantin.ananyev@intel.com, dev@dpdk.org References: <20190410134517.63896-1-bruce.richardson@intel.com> <20190410134517.63896-3-bruce.richardson@intel.com> Date: Wed, 10 Apr 2019 10:07:33 -0400 In-Reply-To: <20190410134517.63896-3-bruce.richardson@intel.com> (Bruce Richardson's message of "Wed, 10 Apr 2019 14:45:17 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 10 Apr 2019 14:07:35 +0000 (UTC) Subject: Re: [dpdk-dev] [PATCH 2/2] bpf: remove use of weak functions 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: , X-List-Received-Date: Wed, 10 Apr 2019 14:07:36 -0000 Bruce Richardson writes: > Weak functions don't work well with static libraries and require the use of > "whole-archive" flag to ensure that the correct function is used when > linking. Since the weak function is only used as a placeholder within this > library alone, we can replace it with a non-weak version protected using > preprocessor ifdefs. > > Signed-off-by: Bruce Richardson > --- I agree with dropping the weak implementations. But, can't we adjust the order of objects when building with multiple strong definitions and the linker will choose the first? I know this works for the GNU linker. I do find this information to help support this statement: https://stackoverflow.com/questions/51656838/attribute-weak-and-static-libraries Unfortunately, I don't find anything in the C standard to govern entity precedence. This means it isn't something that works across linker implementations (but compatible implementations like clang will maintain that behavior). > lib/librte_bpf/bpf_load.c | 4 +++- > lib/librte_bpf/meson.build | 1 + > 2 files changed, 4 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_bpf/bpf_load.c b/lib/librte_bpf/bpf_load.c > index d9d163b7d..194103ec7 100644 > --- a/lib/librte_bpf/bpf_load.c > +++ b/lib/librte_bpf/bpf_load.c > @@ -131,7 +131,8 @@ rte_bpf_load(const struct rte_bpf_prm *prm) > return bpf; > } > > -__rte_experimental __rte_weak struct rte_bpf * > +#ifndef RTE_LIBRTE_BPF_ELF > +__rte_experimental struct rte_bpf * > rte_bpf_elf_load(const struct rte_bpf_prm *prm, const char *fname, > const char *sname) > { > @@ -146,3 +147,4 @@ rte_bpf_elf_load(const struct rte_bpf_prm *prm, const char *fname, > rte_errno = ENOTSUP; > return NULL; > } > +#endif > diff --git a/lib/librte_bpf/meson.build b/lib/librte_bpf/meson.build > index 8a79878ff..11c1fb558 100644 > --- a/lib/librte_bpf/meson.build > +++ b/lib/librte_bpf/meson.build > @@ -20,6 +20,7 @@ deps += ['mbuf', 'net', 'ethdev'] > > dep = dependency('libelf', required: false) > if dep.found() > + dpdk_conf.set('RTE_LIBRTE_BPF_ELF', 1) > sources += files('bpf_load_elf.c') > ext_deps += dep > endif From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 90345A0096 for ; Wed, 10 Apr 2019 16:07:37 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4CBC91B105; Wed, 10 Apr 2019 16:07:37 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id A8F091B104 for ; Wed, 10 Apr 2019 16:07:35 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 04101C0220; Wed, 10 Apr 2019 14:07:35 +0000 (UTC) Received: from dhcp-25.97.bos.redhat.com (unknown [10.18.25.61]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 862795D722; Wed, 10 Apr 2019 14:07:34 +0000 (UTC) From: Aaron Conole To: Bruce Richardson Cc: konstantin.ananyev@intel.com, dev@dpdk.org References: <20190410134517.63896-1-bruce.richardson@intel.com> <20190410134517.63896-3-bruce.richardson@intel.com> Date: Wed, 10 Apr 2019 10:07:33 -0400 In-Reply-To: <20190410134517.63896-3-bruce.richardson@intel.com> (Bruce Richardson's message of "Wed, 10 Apr 2019 14:45:17 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 10 Apr 2019 14:07:35 +0000 (UTC) Subject: Re: [dpdk-dev] [PATCH 2/2] bpf: remove use of weak functions 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" Message-ID: <20190410140733.tubZ3rRyqe2uoPMS83s5I4F5oZ9soU6O7ZpWaRuecdg@z> Bruce Richardson writes: > Weak functions don't work well with static libraries and require the use of > "whole-archive" flag to ensure that the correct function is used when > linking. Since the weak function is only used as a placeholder within this > library alone, we can replace it with a non-weak version protected using > preprocessor ifdefs. > > Signed-off-by: Bruce Richardson > --- I agree with dropping the weak implementations. But, can't we adjust the order of objects when building with multiple strong definitions and the linker will choose the first? I know this works for the GNU linker. I do find this information to help support this statement: https://stackoverflow.com/questions/51656838/attribute-weak-and-static-libraries Unfortunately, I don't find anything in the C standard to govern entity precedence. This means it isn't something that works across linker implementations (but compatible implementations like clang will maintain that behavior). > lib/librte_bpf/bpf_load.c | 4 +++- > lib/librte_bpf/meson.build | 1 + > 2 files changed, 4 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_bpf/bpf_load.c b/lib/librte_bpf/bpf_load.c > index d9d163b7d..194103ec7 100644 > --- a/lib/librte_bpf/bpf_load.c > +++ b/lib/librte_bpf/bpf_load.c > @@ -131,7 +131,8 @@ rte_bpf_load(const struct rte_bpf_prm *prm) > return bpf; > } > > -__rte_experimental __rte_weak struct rte_bpf * > +#ifndef RTE_LIBRTE_BPF_ELF > +__rte_experimental struct rte_bpf * > rte_bpf_elf_load(const struct rte_bpf_prm *prm, const char *fname, > const char *sname) > { > @@ -146,3 +147,4 @@ rte_bpf_elf_load(const struct rte_bpf_prm *prm, const char *fname, > rte_errno = ENOTSUP; > return NULL; > } > +#endif > diff --git a/lib/librte_bpf/meson.build b/lib/librte_bpf/meson.build > index 8a79878ff..11c1fb558 100644 > --- a/lib/librte_bpf/meson.build > +++ b/lib/librte_bpf/meson.build > @@ -20,6 +20,7 @@ deps += ['mbuf', 'net', 'ethdev'] > > dep = dependency('libelf', required: false) > if dep.found() > + dpdk_conf.set('RTE_LIBRTE_BPF_ELF', 1) > sources += files('bpf_load_elf.c') > ext_deps += dep > endif