Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2507673pxb; Mon, 11 Jan 2021 11:23:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxEuYD3ibLAcVDqEbYoOsPJpd5hPj0l9l24FJ5FurP11KMSd4sPBUeIYifBEXfcf6iXaIsj X-Received: by 2002:a50:e845:: with SMTP id k5mr656940edn.35.1610393031558; Mon, 11 Jan 2021 11:23:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610393031; cv=none; d=google.com; s=arc-20160816; b=A/Q11B6JfZEPuuBcV1kziKvOCW3y3kOV8cJKW/lJcqVb6wHoUUtHOLrCpLt4uiyheY nNbThyOmPd8q3mKn2BZ45LOEsTFIGaagaL3VEcFeFmffgQ4+9oAqGDlJmeiao6nyKAJa 2g8URgKoU30RnOx7viNe/OmXq9DJIpEegVCyUhy+0RQ+i8daDFp1bytpReqHenpRRK+x t6wfjLj/O2mHxIYJkE3NlQsruJRMs9socUnaXuCQqzkqASsVhjRVTqdo7N8Cc4UAv4rV NseQAUIru+Fb/s1N41h3LSwwTAbayz/6fFqyN9vQpUQeq7p+leWHlWlRKvrYDFVpPChG +x5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature:dkim-filter; bh=pHi7+gSVpF90pPM2Xy2bn15uah7SVIhPfi3n/QhRCHU=; b=yE/F2eqbSsGZ55UDVPVJEsVEXfxGQ2bV4HTfxAAu1TOzpoKYAqOwAMgaDx1N8Ud3Ww StHLoNJa9vMKzFfiSb0KmTp065hNYwNenunKXzU1avglW3+BnbPsA2IMy8O/dVszFvpr PjGAUlu8ril6dd9nncPgcebAQpM7b7N/ANydojQ5zIl6qiTVg1L6viLSZW0wcj9hAbN8 X8CwvCgjY4yYxQiXYbeyIEPBsarU9YY2TcFHFkfNlnEhqQmOL6uoSdwbetgsxJzaXYNY jGogdipUe8BmJQtkFCHbSQydoIu7bwczHVrtjL4SxLNptpeE4HXPqVEB87aee09tdv0j BE5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=njSIvSgo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qh17si138856ejb.115.2021.01.11.11.23.27; Mon, 11 Jan 2021 11:23:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=njSIvSgo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403852AbhAKTVA (ORCPT + 99 others); Mon, 11 Jan 2021 14:21:00 -0500 Received: from conssluserg-01.nifty.com ([210.131.2.80]:63858 "EHLO conssluserg-01.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403793AbhAKTU5 (ORCPT ); Mon, 11 Jan 2021 14:20:57 -0500 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (authenticated) by conssluserg-01.nifty.com with ESMTP id 10BJJcUA008023; Tue, 12 Jan 2021 04:19:39 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-01.nifty.com 10BJJcUA008023 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1610392779; bh=pHi7+gSVpF90pPM2Xy2bn15uah7SVIhPfi3n/QhRCHU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=njSIvSgoXx2FlpZ0es+iD3fdlv1FktyD02kl0QVCAUPHvh+sUf7L2ytXBu2BODRh+ 7b1QUp6fO4KxiiaqJCtlv/qdJCFvi7ByBlqRDVt5oS8sTDIC73wb4i4I1uRRpjWSeO BlEaU9PeyxkiBQLd+qlDxIUeiDDscoK5x7l8RZnXsziUXS2Y20EW8xffGxngkzVYfM tUUA85Nz5jIYFGR2naHwbq9LeivdDmJtDFtsqpEEGntfUabR2U0cKMIf2B8AbDNhph IOqhUWVgES4GGtVe8W5rQBTfh4YYOZrn/XDd5lVsZklJdqeBbzYlNgllBCW9TYfV6c ub2tLhEJ0GaMA== X-Nifty-SrcIP: [209.85.215.181] Received: by mail-pg1-f181.google.com with SMTP id n25so318933pgb.0; Mon, 11 Jan 2021 11:19:39 -0800 (PST) X-Gm-Message-State: AOAM530nvfkWDPIyZNGBbjm/I1FjtYsv8u0qDFQLIJJMQvbeuqbTP6lE XNKX6jODCdEUrBIPEx9zdSc6tnUIw83B8viFIac= X-Received: by 2002:a63:1f1d:: with SMTP id f29mr988794pgf.47.1610392778340; Mon, 11 Jan 2021 11:19:38 -0800 (PST) MIME-Version: 1.0 References: <20210111180609.713998-1-natechancellor@gmail.com> In-Reply-To: <20210111180609.713998-1-natechancellor@gmail.com> From: Masahiro Yamada Date: Tue, 12 Jan 2021 04:19:01 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] bpf: Hoise pahole version checks into Kconfig To: Nathan Chancellor Cc: Michal Marek , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Linux Kernel Mailing List , Linux Kbuild mailing list , Networking , bpf , Sedat Dilek Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 12, 2021 at 3:06 AM Nathan Chancellor wrote: > > After commit da5fb18225b4 ("bpf: Support pre-2.25-binutils objcopy for > vmlinux BTF"), having CONFIG_DEBUG_INFO_BTF enabled but lacking a valid > copy of pahole results in a kernel that will fully compile but fail to > link. The user then has to either install pahole or disable > CONFIG_DEBUG_INFO_BTF and rebuild the kernel but only after their build > has failed, which could have been a significant amount of time depending > on the hardware. > > Avoid a poor user experience and require pahole to be installed with an > appropriate version to select and use CONFIG_DEBUG_INFO_BTF, which is > standard for options that require a specific tools version. > > Suggested-by: Sedat Dilek > Signed-off-by: Nathan Chancellor I am not sure if this is the right direction. I used to believe moving any tool test to the Kconfig was the right thing to do. For example, I tried to move the libelf test to Kconfig, and make STACK_VALIDATION depend on it. https://patchwork.kernel.org/project/linux-kbuild/patch/1531186516-15764-1-git-send-email-yamada.masahiro@socionext.com/ It was rejected. In my understanding, it is good to test target toolchains in Kconfig (e.g. cc-option, ld-option, etc). As for host tools, in contrast, it is better to _intentionally_ break the build in order to let users know that something needed is missing. Then, they will install necessary tools or libraries. It is just a one-time setup, in most cases, just running 'apt install' or 'dnf install'. Recently, a similar thing happened to GCC_PLUGINS https://patchwork.kernel.org/project/linux-kbuild/patch/20201203125700.161354-1-masahiroy@kernel.org/#23855673 Following this pattern, if a new pahole is not installed, it might be better to break the build instead of hiding the CONFIG option. In my case, it is just a matter of 'apt install pahole'. On some distributions, the bundled pahole is not new enough, and people may end up with building pahole from the source code. > --- > MAINTAINERS | 1 + > init/Kconfig | 4 ++++ > lib/Kconfig.debug | 6 ++---- > scripts/link-vmlinux.sh | 13 ------------- > scripts/pahole-version.sh | 16 ++++++++++++++++ > 5 files changed, 23 insertions(+), 17 deletions(-) > create mode 100755 scripts/pahole-version.sh > > diff --git a/MAINTAINERS b/MAINTAINERS > index b8db7637263a..6f6e24285a94 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -3282,6 +3282,7 @@ F: net/core/filter.c > F: net/sched/act_bpf.c > F: net/sched/cls_bpf.c > F: samples/bpf/ > +F: scripts/pahole-version.sh > F: tools/bpf/ > F: tools/lib/bpf/ > F: tools/testing/selftests/bpf/ > diff --git a/init/Kconfig b/init/Kconfig > index b77c60f8b963..872c61b5d204 100644 > --- a/init/Kconfig > +++ b/init/Kconfig > @@ -74,6 +74,10 @@ config TOOLS_SUPPORT_RELR > config CC_HAS_ASM_INLINE > def_bool $(success,echo 'void foo(void) { asm inline (""); }' | $(CC) -x c - -c -o /dev/null) > > +config PAHOLE_VERSION > + int > + default $(shell,$(srctree)/scripts/pahole-version.sh $(PAHOLE)) > + > config CONSTRUCTORS > bool > depends on !UML > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > index 7937265ef879..70c446af9664 100644 > --- a/lib/Kconfig.debug > +++ b/lib/Kconfig.debug > @@ -267,6 +267,7 @@ config DEBUG_INFO_DWARF4 > > config DEBUG_INFO_BTF > bool "Generate BTF typeinfo" > + depends on PAHOLE_VERSION >= 116 > depends on !DEBUG_INFO_SPLIT && !DEBUG_INFO_REDUCED > depends on !GCC_PLUGIN_RANDSTRUCT || COMPILE_TEST > help > @@ -274,12 +275,9 @@ config DEBUG_INFO_BTF > Turning this on expects presence of pahole tool, which will convert > DWARF type info into equivalent deduplicated BTF type info. > > -config PAHOLE_HAS_SPLIT_BTF > - def_bool $(success, test `$(PAHOLE) --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/'` -ge "119") > - > config DEBUG_INFO_BTF_MODULES > def_bool y > - depends on DEBUG_INFO_BTF && MODULES && PAHOLE_HAS_SPLIT_BTF > + depends on DEBUG_INFO_BTF && MODULES && PAHOLE_VERSION >= 119 > help > Generate compact split BTF type information for kernel modules. > > diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh > index 6eded325c837..eef40fa9485d 100755 > --- a/scripts/link-vmlinux.sh > +++ b/scripts/link-vmlinux.sh > @@ -139,19 +139,6 @@ vmlinux_link() > # ${2} - file to dump raw BTF data into > gen_btf() > { > - local pahole_ver > - > - if ! [ -x "$(command -v ${PAHOLE})" ]; then > - echo >&2 "BTF: ${1}: pahole (${PAHOLE}) is not available" > - return 1 > - fi > - > - pahole_ver=$(${PAHOLE} --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/') > - if [ "${pahole_ver}" -lt "116" ]; then > - echo >&2 "BTF: ${1}: pahole version $(${PAHOLE} --version) is too old, need at least v1.16" > - return 1 > - fi > - > vmlinux_link ${1} > > info "BTF" ${2} > diff --git a/scripts/pahole-version.sh b/scripts/pahole-version.sh > new file mode 100755 > index 000000000000..6de6f734a345 > --- /dev/null > +++ b/scripts/pahole-version.sh > @@ -0,0 +1,16 @@ > +#!/bin/sh > +# SPDX-License-Identifier: GPL-2.0 > +# > +# Usage: $ ./scripts/pahole-version.sh pahole > +# > +# Print the pahole version as a three digit string > +# such as `119' for pahole v1.19 etc. > + > +pahole="$*" > + > +if ! [ -x "$(command -v $pahole)" ]; then > + echo 0 > + exit 1 > +fi > + > +$pahole --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/' > > base-commit: e22d7f05e445165e58feddb4e40cc9c0f94453bc > -- > 2.30.0 > -- Best Regards Masahiro Yamada