From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 05DF2A00C2; Thu, 21 Jul 2022 14:14:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8437841614; Thu, 21 Jul 2022 14:14:35 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id E1178400D7 for ; Thu, 21 Jul 2022 14:14:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658405674; x=1689941674; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9GXkUq+K/PGqakh9IBNeX0Q0akkfzQVWQJTrlWUDBFE=; b=QJXsNZ8MFgVfjPESj7iqROPAoudCrTT+QPdfv/bPGzeo3G2K+KFKWuj7 /VbOwJDyj+bX4WU9dQGk2PJTfhYi79AAv1mdbzWs71awJ34FwQ21UxFGA JFhwCFojt1qM2fs/9V5BWGPDj8s6sdt6FeRh2Za83hQne+lLKm7ONMtVd eSGVVt6FEbuBO5vBjGNX0FsfJDoV23WiBEysVNS7/lL2RqSQAPUXwtqDR bzD2EirowomFVx2Wv5h4pBLFofNKumBsqhsHdSE2QQBMCMFaQowaoHCba VFzQuIup7OmC6vQzalXw8Qx0m01MUQO1tPhNyE687oVStkTZpjncgRRZI w==; X-IronPort-AV: E=McAfee;i="6400,9594,10414"; a="351017359" X-IronPort-AV: E=Sophos;i="5.92,289,1650956400"; d="scan'208";a="351017359" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2022 05:14:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,289,1650956400"; d="scan'208";a="573715909" Received: from silpixa00401086.ir.intel.com (HELO localhost.localdomain) ([10.55.128.124]) by orsmga006.jf.intel.com with ESMTP; 21 Jul 2022 05:14:28 -0700 From: Ciara Loftus To: dev@dpdk.org Cc: andrew.rybchenko@oktetlabs.ru, Ciara Loftus Subject: [RFC PATCH 2/3] net/af_xdp: determine libbpf version by checking for symbols Date: Thu, 21 Jul 2022 12:14:14 +0000 Message-Id: <20220721121415.1709202-2-ciara.loftus@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220721121415.1709202-1-ciara.loftus@intel.com> References: <20220721121415.1709202-1-ciara.loftus@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Instead of using pkg-config to query the version of the libbpf library, search for symbols in the library and use their presence or absence to determine what version of the library is being linked. Suggested-by: Andrew Rybchenko Signed-off-by: Ciara Loftus --- drivers/net/af_xdp/meson.build | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/net/af_xdp/meson.build b/drivers/net/af_xdp/meson.build index c90ab10a7b..d91545f9c3 100644 --- a/drivers/net/af_xdp/meson.build +++ b/drivers/net/af_xdp/meson.build @@ -15,8 +15,12 @@ xdp_dep = dependency('libxdp', version : '>=1.2.2', required: false, method: 'pk bpf_dep = dependency('libbpf', required: false, method: 'pkg-config') if not bpf_dep.found() bpf_dep = cc.find_library('bpf', required: false) -else - bpf_ver_dep = dependency('libbpf', version : '>=0.7.0', required: false, method: 'pkg-config') +endif + +libbpf070 = false + +if bpf_dep.found() and cc.has_header('bpf/bpf.h') and cc.has_header_symbol('bpf/bpf.h', 'bpf_btf_load') + libbpf070 = true endif if cc.has_header('linux/if_xdp.h') @@ -26,7 +30,7 @@ if cc.has_header('linux/if_xdp.h') cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM'] ext_deps += xdp_dep ext_deps += bpf_dep - if bpf_ver_dep.found() + if libbpf070 cflags += ['-DRTE_NET_AF_XDP_LIBBPF_OBJ_OPEN'] endif else @@ -36,11 +40,10 @@ if cc.has_header('linux/if_xdp.h') elif bpf_dep.found() and cc.has_header('bpf/xsk.h') and cc.has_header('bpf/bpf.h') # libxdp not found. Rely solely on libbpf for xsk functionality # which is only available in versions < v0.7.0. - if not bpf_ver_dep.found() + if not libbpf070 ext_deps += bpf_dep - bpf_shumem_ver_dep = dependency('libbpf', version : '>=0.2.0', - required: false, method: 'pkg-config') - if bpf_shumem_ver_dep.found() + bpf_shumem_ver_dep = cc.has_header_symbol('bpf/bpf.h', 'bpf_prog_bind_map') + if bpf_shumem_ver_dep cflags += ['-DRTE_NET_AF_XDP_SHARED_UMEM'] endif else -- 2.25.1