Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp197477ybj; Fri, 20 Sep 2019 23:05:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqyO6vwVPs+Bp0Sj00NhsbOCdw9UM0JXTzzjeEAyXOpP0UOfvRGTGclQflr1hVqnNsdKsfLe X-Received: by 2002:a50:a57d:: with SMTP id z58mr25905641edb.115.1569045913102; Fri, 20 Sep 2019 23:05:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569045913; cv=none; d=google.com; s=arc-20160816; b=nUGHKo5B+bbGbbTmtmvzzhtWti7QmxNYXxjFPRXWXH94oQAOfeDWqKWYJ/JO95J4IK mXP7swYvBAPASCyat34nvC3o3HakXb0VSCNCgk3uLjawXRVJ8BI3Xk0LxNOukSAovHG0 /qyX2mVYOX253ZVuI4aaONy6E8sNjdSFrJmZ+lZfhH75A/6fUA3X+SQHXNbigOQ7pHnG lO3s/PwIAINE0bEAR6CctgutfyiiI2ee2dwVU7344VHVHT4c2QFgQAYsBrybPZGdDzxQ dqeIuZoRmAPBFxje1CVuIMWKW+l4mvTXKIl7t6O2SToiDp9pi+XOldbkSz5Gd6ozy1s+ yrqQ== 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=hOm0RSVxiN9cy/2zlDkuDpGL5XVU330++py7GJHjAx0=; b=zn1sA8HDz5I3f4LWFZvxjybzIlFxL6hSJ8/+9XFz3xsBd90NEenahDizA6Uvw6nWfj xFOYJVri0GigPWTSJXfl48stL/DeNDYGDtYOS6NDrH4uQQeGwcJU261nqTTU7NtSxs8B EvkOvSTrARWeAFP/ANeSWC4RKOBz/ile1fPjBP9AbJOmnrRtMFah/qcw65hqEw+elkt+ NUiXko9E/XqNgSGS2t93otz/prU7oVTo56wvXMDRbZ0sp4pTympQAhktPLNkccvBQBj6 S637Bse10BxmBSnA7SGrouIZOR6r5X6bCnG3m0Zw1zviaRz6zVipKGyCl+6+uYWD2YZm +7KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gpxypbyV; 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 c4si2757404edy.388.2019.09.20.23.04.13; Fri, 20 Sep 2019 23:05:13 -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=gpxypbyV; 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 S2395202AbfITIWM (ORCPT + 99 others); Fri, 20 Sep 2019 04:22:12 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:44063 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393179AbfITIWL (ORCPT ); Fri, 20 Sep 2019 04:22:11 -0400 Received: by mail-lj1-f195.google.com with SMTP id m13so6167580ljj.11 for ; Fri, 20 Sep 2019 01:22:10 -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=hOm0RSVxiN9cy/2zlDkuDpGL5XVU330++py7GJHjAx0=; b=gpxypbyVCKkOGbVW+Afzq0G0SijqxBGhC3HHNQu38FBsCf3mjnrrXApKO4u8mD5Ge3 zA04+tnmTerkM4T1RJ7krUmnB+9hTEFLGJXEb12Rj7tOexqvl+NS34gitG6WfSllFUWh 4jKwiMG6K5ttmC0iW8Q0blWchaToknxTaq+xx5nUNjEIhDlZ7S96cWZ1yNPU3qPe62aT INq3V5DtnKDJFTpcH19QS0y3kVdWHtz23xRU/H+KEZJ7m5AG/GrfFIJPrCDg5eZ8ICEB RG4tAhxqXtZROOpeRHPk9By6C7D7GJeujMxAGxPFpnXTUGQimTyzigJgMQ//nJSFb65u p+7g== 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=hOm0RSVxiN9cy/2zlDkuDpGL5XVU330++py7GJHjAx0=; b=sJP5/vBI+82dxOgOfolm8n5iuVZZ0UVhqjw4cWAS5wSv+Jx0QcMazhIRc8jAVICTin 7ZdTyxmsfFaQR3R8gegytmlL9B8YZMUIxYxp7nVyIDmVcp8W61Wa8R7Lvd0wRkkyjECQ SkauTPAtqBqVobCMbjrpRQ74s7CyNWGFAuKVtDwzNAqbVTJa2iLhpq9TJ1eqabfE2lUI FVV2MzK0h3NZMawjVTSCc8+l4tF40AWpdfCE74AS1zpVR5qlczvXGc5ZnRo3K0PD5JdV MBiQ4LadCaXntpai1u9cCdPDwR2ra+7whAALiZUKr8L/m9QLwvIyT4coy0wZfWw8K8mE HxJg== X-Gm-Message-State: APjAAAVLhmc61YqOSnx6Ukxfl2TVfHgDHN/+lTDRTnazSx6JDNJJ95eP gwY/0u8G8EzE00zauPqfFC+AGQ== X-Received: by 2002:a05:651c:c4:: with SMTP id 4mr6073391ljr.111.1568967729239; Fri, 20 Sep 2019 01:22:09 -0700 (PDT) Received: from khorivan (168-200-94-178.pool.ukrtel.net. [178.94.200.168]) by smtp.gmail.com with ESMTPSA id k15sm270207ljg.65.2019.09.20.01.22.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Sep 2019 01:22:08 -0700 (PDT) Date: Fri, 20 Sep 2019 11:22:06 +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: <20190920082204.GC8870@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> 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 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. > >> LIBBPF_MAJOR_VERSION := $(firstword $(subst ., ,$(LIBBPF_VERSION))) >> >> MAKEFLAGS += --no-print-directory >> -- >> 2.17.1 >> -- Regards, Ivan Khoronzhuk