From: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>, Martin Lau <kafai@fb.com>,
Andrii Nakryiko <andriin@fb.com>, Yonghong Song <yhs@fb.com>,
Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH bpf] libbpf: fix version identification on busybox
Date: Fri, 20 Sep 2019 11:22:06 +0300 [thread overview]
Message-ID: <20190920082204.GC8870@khorivan> (raw)
In-Reply-To: <CAEf4BzbCjCYr5NMPctDkUggwpehnqZPVBSqZOsd9MvSq6WmnZQ@mail.gmail.com>
On Thu, Sep 19, 2019 at 01:02:40PM -0700, Andrii Nakryiko wrote:
>On Thu, Sep 19, 2019 at 11:22 AM Ivan Khoronzhuk
><ivan.khoronzhuk@linaro.org> 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 <ivan.khoronzhuk@linaro.org>
>> ---
>>
>> 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.
>
>> LIBBPF_MAJOR_VERSION := $(firstword $(subst ., ,$(LIBBPF_VERSION)))
>>
>> MAKEFLAGS += --no-print-directory
>> --
>> 2.17.1
>>
--
Regards,
Ivan Khoronzhuk
next prev parent reply other threads:[~2019-09-20 8:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-19 16:05 [PATCH bpf] libbpf: fix version identification on busybox Ivan Khoronzhuk
2019-09-19 18:45 ` Ivan Khoronzhuk
2019-09-19 20:02 ` Andrii Nakryiko
2019-09-20 8:22 ` Ivan Khoronzhuk [this message]
2019-09-20 16:41 ` Andrii Nakryiko
2019-09-20 18:34 ` Ivan Khoronzhuk
2019-09-20 19:19 ` Ivan Khoronzhuk
2019-09-20 20:48 ` Ivan Khoronzhuk
2019-09-20 21:51 ` Andrii Nakryiko
2019-09-20 22:14 ` Ivan Khoronzhuk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190920082204.GC8870@khorivan \
--to=ivan.khoronzhuk@linaro.org \
--cc=andrii.nakryiko@gmail.com \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kafai@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.