Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp2317274ybj; Mon, 23 Sep 2019 01:30:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwRf4VMXw76NpymMvH0gIXYPX0gpDlB0ph76kKwJtGjNYt892Mnt4PUSbSgC+qnErCKbPqz X-Received: by 2002:a50:8b61:: with SMTP id l88mr12893518edl.244.1569227427725; Mon, 23 Sep 2019 01:30:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569227427; cv=none; d=google.com; s=arc-20160816; b=pOgxMFqFDHMAb+HtESn+R4CaxSMIE1sEkuxztjxwGk6t2UnPe37UOx3l8FUp8PzqDy qwL5jP8VdFiuvknQnWa4QKnsKPVlnWDuyRjFazpmvRtPV2N7qBkI/N86+OyAsHIiwnTs VCtSDf6cjcicRmx6kzL/2T/YoqS6qoS7dKo7BVFPZO5ldNk2Hvyhs4dHZyn/Ui/0uO3I Zba44JED7QcOXdEMDsfh+VosklnzugaBCqOzGmFC6d/evZbj3m3GRQfwcpl5T0sG6IUG gB/4FSH7ojuAoebmILs1LnNXdAPYL1VrGJmvOf9Tc+UNGnH2xAVzx+ub6YwPcv/4EV0Z Sv3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=pnD+O0ovrq1F6qN8k3Y2ZgHyJhSBoQdXb5evY3Rg4Cc=; b=pnpm4ycTAgKTbSgdx+yJu7R/ktKfjVOWNkv8iEZxKRKqgwNRmvw3Uzzt0wujBtkhJJ xoczVCVrRRVjKjtc1YwUPzZ0cr/q4WvG56NryMD/vD9AeGpOLkPbjypylfg/IytdBv1Y LkOVWAXr+Hd/Q4YGDuq5A6yVJMSGYVCzPRuBE80YWI8KHYvF03ykX1kMIO7gPrrhZbMD dLd3IE81Ja1KbdltDRRoQvg18S/ErrJD3yiS28HekCnGkCPUaDZoBwLZ0R1NDNboIX6z /vpkZvePgFGn1q9q60v/FJrM9tTequxsSS+tnNL+VWYlJVZGf+Jim20u7vb6OWwEVy0l 1Q4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bqY8uKMY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o17si4583462ejm.261.2019.09.23.01.30.04; Mon, 23 Sep 2019 01:30:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bqY8uKMY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406439AbfITSe7 (ORCPT + 99 others); Fri, 20 Sep 2019 14:34:59 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:45652 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405396AbfITSe6 (ORCPT ); Fri, 20 Sep 2019 14:34:58 -0400 Received: by mail-lj1-f195.google.com with SMTP id q64so7971544ljb.12 for ; Fri, 20 Sep 2019 11:34:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=pnD+O0ovrq1F6qN8k3Y2ZgHyJhSBoQdXb5evY3Rg4Cc=; b=bqY8uKMYN5NCM6qjXOyTo3GavIiiiafNBzRaCqO4/1LIT9iV6hBLBucLJ/HZJ0OgZD thKmQSPWYASptQ6dsQG3Gy+Mdy4QNYH6K4cmbCjPhmxQKKUrInjNLD3TPtvAfPfvqS5K q7PX3cVnCzRyAjngm6osaoQej4LjswgsZCxIfa1fBukdORMQe3f9qPTu0BSpFBPONZnR 6hpPHBSMQoNREbN2MI2EzZSa4MUlvIZ6CpspsjwL0UBJKXK/X3EvVG818MW67iWDk7HD sJrgaFZBw7vcxrXUuQ/6n7DmBSZGus02ZPGRZ+eqido3MD4dUxMb9gqBD+RbsTD8Tfaj zn9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=pnD+O0ovrq1F6qN8k3Y2ZgHyJhSBoQdXb5evY3Rg4Cc=; b=cafqKYH7G6lhhjCeErmjHhwF/5Rk+uT1iPAm07DUfLhocSg9vAUlKOfmzJgF/D74LI WpbO4vZvqf1UhVCYYDCa6my5CsOzfeov4tDr1CfPWAg4yP/KXZd5ubI6nE8NVzUUVcS1 h6MunlWBDMlDlYjXw03euIm6II3K4QadEez1LacHtjG94ri7oBEqpbr6AtOCVSlAIr/B xpovVd8XU1OxRfi6xQ5LzaZAro8ni8nRaH4zSXW23DZm3GrMpm6sW4dTEtNsLKHEhTyY TSkFSZaBxQrU0xJl4jjhM4nDjWWmAjlAAANhGP4yNUx8EPlXp9xV9YYKg/YYXe892Afa f5+w== X-Gm-Message-State: APjAAAXeI+AzRK42mLwKR+HW0/5ylLu+LtDzQ7crlA7yaJbu2LGOg5NX qLdfiRxRLh+occ/YqKFXAZciNQ== X-Received: by 2002:a2e:a0c5:: with SMTP id f5mr3903494ljm.114.1569004493847; Fri, 20 Sep 2019 11:34:53 -0700 (PDT) Received: from khorivan (168-200-94-178.pool.ukrtel.net. [178.94.200.168]) by smtp.gmail.com with ESMTPSA id 77sm603953ljj.84.2019.09.20.11.34.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Sep 2019 11:34:53 -0700 (PDT) Date: Fri, 20 Sep 2019 21:34:51 +0300 From: Ivan Khoronzhuk To: Andrii Nakryiko Cc: Alexei Starovoitov , Daniel Borkmann , Martin Lau , Andrii Nakryiko , Yonghong Song , Networking , bpf , open list Subject: Re: [PATCH bpf] libbpf: fix version identification on busybox Message-ID: <20190920183449.GA2760@khorivan> Mail-Followup-To: Andrii Nakryiko , Alexei Starovoitov , Daniel Borkmann , Martin Lau , Andrii Nakryiko , Yonghong Song , Networking , bpf , open list References: <20190919160518.25901-1-ivan.khoronzhuk@linaro.org> <20190920082204.GC8870@khorivan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 20, 2019 at 09:41:54AM -0700, Andrii Nakryiko wrote: >On Fri, Sep 20, 2019 at 1:22 AM Ivan Khoronzhuk > wrote: >> >> On Thu, Sep 19, 2019 at 01:02:40PM -0700, Andrii Nakryiko wrote: >> >On Thu, Sep 19, 2019 at 11:22 AM Ivan Khoronzhuk >> > wrote: >> >> >> >> It's very often for embedded to have stripped version of sort in >> >> busybox, when no -V option present. It breaks build natively on target >> >> board causing recursive loop. >> >> >> >> BusyBox v1.24.1 (2019-04-06 04:09:16 UTC) multi-call binary. \ >> >> Usage: sort [-nrugMcszbdfimSTokt] [-o FILE] [-k \ >> >> start[.offset][opts][,end[.offset][opts]] [-t CHAR] [FILE]... >> >> >> >> Lets modify command a little to avoid -V option. >> >> >> >> Fixes: dadb81d0afe732 ("libbpf: make libbpf.map source of truth for libbpf version") >> >> >> >> Signed-off-by: Ivan Khoronzhuk >> >> --- >> >> >> >> Based on bpf/master >> >> >> >> tools/lib/bpf/Makefile | 2 +- >> >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> >> >> diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile >> >> index c6f94cffe06e..a12490ad6215 100644 >> >> --- a/tools/lib/bpf/Makefile >> >> +++ b/tools/lib/bpf/Makefile >> >> @@ -3,7 +3,7 @@ >> >> >> >> LIBBPF_VERSION := $(shell \ >> >> grep -oE '^LIBBPF_([0-9.]+)' libbpf.map | \ >> >> - sort -rV | head -n1 | cut -d'_' -f2) >> >> + cut -d'_' -f2 | sort -r | head -n1) >> > >> >You can't just sort alphabetically, because: >> > >> >1.2 >> >1.11 >> > >> >should be in that order. See discussion on mailing thread for original commit. >> >> if X1.X2.X3, where X = {0,1,....99999} >> Then it can be: >> >> -LIBBPF_VERSION := $(shell \ >> - grep -oE '^LIBBPF_([0-9.]+)' libbpf.map | \ >> - sort -rV | head -n1 | cut -d'_' -f2) >> +_LBPFLIST := $(patsubst %;,%,$(patsubst LIBBPF_%,%,$(filter LIBBPF_%, \ >> + $(shell cat libbpf.map)))) >> +_LBPFLIST2 := $(foreach v,$(_LBPFLIST), \ >> + $(subst $() $(),,$(foreach n,$(subst .,$() $(),$(v)), \ >> + $(shell printf "%05d" $(n))))) >> +_LBPF_VER := $(word $(words $(sort $(_LBPFLIST2))), $(sort $(_LBPFLIST2))) >> +LIBBPF_VERSION := $(patsubst %_$(_LBPF_VER),%,$(filter %_$(_LBPF_VER), \ >> + $(join $(addsuffix _, $(_LBPFLIST)),$(_LBPFLIST2)))) >> >> It's bigger but avoids invocations of grep/sort/cut/head, only cat/printf >> , thus -V option also. >> > >No way, this is way too ugly (and still unreliable, if we ever have >X.Y.Z.W or something). I'd rather go with my original approach of Yes, forgot to add X1,X2,X3,...XN, where X = {0,1,....99999} and N = const for all versions. But frankly, 1.0.0 looks too far. >fetching the last version in libbpf.map file. See >https://www.spinics.net/lists/netdev/msg592703.html. > >> > >> >> LIBBPF_MAJOR_VERSION := $(firstword $(subst ., ,$(LIBBPF_VERSION))) >> >> >> >> MAKEFLAGS += --no-print-directory >> >> -- >> >> 2.17.1 >> >> >> >> -- >> Regards, >> Ivan Khoronzhuk -- Regards, Ivan Khoronzhuk