From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by dpdk.space (Postfix) with ESMTP id 3A845A0096
	for <public@inbox.dpdk.org>; Wed, 10 Apr 2019 15:45:48 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 0975E1B113;
	Wed, 10 Apr 2019 15:45:48 +0200 (CEST)
Received: from mga02.intel.com (mga02.intel.com [134.134.136.20])
 by dpdk.org (Postfix) with ESMTP id A664F1B111
 for <dev@dpdk.org>; Wed, 10 Apr 2019 15:45:46 +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:32 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.60,332,1549958400"; d="scan'208";a="141569368"
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:31 -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:17 +0100
Message-Id: <20190410134517.63896-3-bruce.richardson@intel.com>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20190410134517.63896-1-bruce.richardson@intel.com>
References: <20190410134517.63896-1-bruce.richardson@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [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 <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>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <20190410134517.hGPubP8Rern6Wm_C2vkSSipdUeLZLmUZOUfkcgbDGPI@z>

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 <bruce.richardson@intel.com>
---
 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
-- 
2.20.1