Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp2444121ybj; Mon, 23 Sep 2019 04:03:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7CAKWJWRsv4yrqD1Puph/E4VpY0+nK3ExDVLm0UtYiz4d+/C1rrHZDvQMbS6MIwoVWiYI X-Received: by 2002:a50:af26:: with SMTP id g35mr17173568edd.129.1569236592739; Mon, 23 Sep 2019 04:03:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569236592; cv=none; d=google.com; s=arc-20160816; b=N341+JjXAfsiWq0Hgsda5Z2LIU1YaH6ZFIpNYkigsde3HBsTswW5znZ9DYBHex+FKr A3S7suXaEbhq06jAOy+WoBNQg1a8WI/wtoU13Jgj0uhR/wdEDEMlvQSspsjMUD+kM0Fg TuI7ExPeTHYzgxxEhDJYKnMHlgtctCX+lkPQiiSfn6k5AdR9XSH6sQPHdULBKHwC77X5 F54ke0aX4zDW7l4NaoiwrNvtFf29HLwP1aULcyz7uTbsadzo0yTE7Zjp7ifHiu+F7q/C q1+hBeHw+ijgKbN07xZYgFQwvqDxBLqD4/HQoIXgCz3tjzx4KURYz6O5sO8gXvtyS3nk 6eBQ== 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:to:from:date:dkim-signature; bh=T8An8FHblE+kDgtVFHSjYWnPaCBxTzDv21Ur6auB05g=; b=UWIfJcKIrfDrUYfqZmmiQJO1T5sm1Ih4F8LAQN3XLRf25BeW6qx2+8HwPSN9EQwueJ ULueBE8RLiY2r4aPZJ0VN90LkQpRQkF9De2GXOPxx3aalbjx7qBQqCR2s3by2lBGF08I p/1fWVQas16IxqrQwChQmv6YuVTZgSxzZxP7UlMqmakaWi2CkFU49y3U264sn6ZgAjxx vCVkzvOo5LILvz8S+D+bQTZUcwVpp11JzsypP0cebrN63wbyMhPU0i91Szo0ey7e/bTe KdeojmbYhSmI6ybrzX3yR3Yq2of6ENekiWGlqM9sueft9g5XpfrE3t8Cs2jcZyK3aXKH lJlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qG1PAZcU; 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 s1si4764846ejf.305.2019.09.23.04.02.47; Mon, 23 Sep 2019 04:03:12 -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=qG1PAZcU; 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 S2387515AbfITUsb (ORCPT + 99 others); Fri, 20 Sep 2019 16:48:31 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:39991 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387435AbfITUsb (ORCPT ); Fri, 20 Sep 2019 16:48:31 -0400 Received: by mail-lj1-f194.google.com with SMTP id 7so8324925ljw.7 for ; Fri, 20 Sep 2019 13:48:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=T8An8FHblE+kDgtVFHSjYWnPaCBxTzDv21Ur6auB05g=; b=qG1PAZcUe75GcJB6L6hYulpGLwTWOINwYP/XeLJ2PZIWPE6tjn1V6g7SGVJ9mA7BWp fSIPDrfKR8KVHg/ApCo7JRdi8DMZrx+ieKnZWjvqiSC3rJIRq4u5end22mYU5trW1kX1 Av+5sj+GOgzHMDlET8a33+HOP1glQl3smTYMOdQH4K6GdEo6aoUB1mAownQ2PUlGaWIo t2bO+/4d4AKV0AH2vKbT+aZ6qHkz7ZDdgiYmGh3XpzevEHUbvy8aGAxF4Bu1/H1xBuDX K4+mzsERfl1RWb06AOCtL+IsN4bXKUDlUUAV/SJOIKdF/tnITfxBKXgfZauS4xC6qQ3R 5OQQ== 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:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=T8An8FHblE+kDgtVFHSjYWnPaCBxTzDv21Ur6auB05g=; b=WGsoloRMa8Q7cBtT4i6mBrvHimAzc9Nhwr74HzZX8FMhJTT+gUvBF3xbBA2gy9zE4+ DZSFlhERODPLwd17Bc7krEZ7cR7ntvnGLd6MbDHHZAae3XZNqIKpi3u4OHTVPwx7jsvr N6SBqmZ+wpsvtmoATNvn7OF2po0pT1fzSML1tUeuxx3ZH06rOfgRCDsgbo9ylYqIyKPx KjM2C0/YOd6djrAxhm7kQXFW0GtE6adJneHYtl4Pc7mjeZjmN3nbYVjNAjiYUoAgGDzs 0bHwKs1A38rJ8c0WsfqhO55xmvZVwbxPK1NcpNia0awTyQcYRFTppxnLxeuxsDpVkXmT wxBA== X-Gm-Message-State: APjAAAVU5ILCs3mbojmDJckszFNrCcX35aIlzdvq1gczekm0lywgfPyI l7Mcs40YkqS4aqRA6E0wiqd4Ig== X-Received: by 2002:a2e:9081:: with SMTP id l1mr10283633ljg.33.1569012508896; Fri, 20 Sep 2019 13:48:28 -0700 (PDT) Received: from khorivan (168-200-94-178.pool.ukrtel.net. [178.94.200.168]) by smtp.gmail.com with ESMTPSA id e21sm714873lfj.10.2019.09.20.13.48.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Sep 2019 13:48:28 -0700 (PDT) Date: Fri, 20 Sep 2019 23:48:26 +0300 From: Ivan Khoronzhuk To: Andrii Nakryiko , 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: <20190920204824.GC2760@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> <20190920183449.GA2760@khorivan> <20190920191941.GB2760@khorivan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20190920191941.GB2760@khorivan> 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 10:19:43PM +0300, Ivan Khoronzhuk wrote: >On Fri, Sep 20, 2019 at 09:34:51PM +0300, Ivan Khoronzhuk wrote: >>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. > >It actually works for any numbs of X1.X2...X100 >but not when you have couple kindof: >X1.X2.X3 >and >X1.X2.X3.X4 > >But, no absolutely any problem to extend this solution to handle all cases, >by just adding leading 0 to every "transformed version", say limit it to 10 >possible 'dots' (%5*10d) and it will work as clocks. Advantage - mostly make >functions. _LBPFLIST := $(subst ;,,$(patsubst LIBBPF_%,%,$(filter LIBBPF_%, \ $(shell cat libbpf.map)))) _LBPF2 := $(foreach v,$(_LBPFLIST), \ $(subst $() $(),,$(foreach n,$(subst ., ,$(v)), \ $(shell printf "%05d" $(n))))) _LBPF2 := $(foreach v,$(_LBPF2), $(shell printf "%050s" $(v))) _LBPF_VER := $(word $(words $(sort $(_LBPF2))), $(sort $(_LBPF2))) LIBBPF_VERSION := $(patsubst %_$(_LBPF_VER),%,$(filter %_$(_LBPF_VER), \ $(join $(addsuffix _, $(_LBPFLIST)),$(_LBPF2)))) > >Here can be couple more solutions with sed, not sure it can look less maniac. > >> >>>fetching the last version in libbpf.map file. See >>>https://www.spinics.net/lists/netdev/msg592703.html. > >Yes it's nice but, no sort, no X1.X2.X3....XN > >Main is to solve it for a long time. > >>> >>>>> >>>>>> LIBBPF_MAJOR_VERSION := $(firstword $(subst ., ,$(LIBBPF_VERSION))) >>>>>> >>>>>> MAKEFLAGS += --no-print-directory >>>>>>-- >>>>>>2.17.1 >>>>>> >>>> >>>>-- >>>>Regards, >>>>Ivan Khoronzhuk >> >>-- >>Regards, >>Ivan Khoronzhuk > >-- >Regards, >Ivan Khoronzhuk -- Regards, Ivan Khoronzhuk