From: Nicolas Schier <nicolas@fjasle.eu>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: Miguel Ojeda <ojeda@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>,
bpf@vger.kernel.org, Nathan Chancellor <nathan@kernel.org>,
linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
patches@lists.linux.dev
Subject: Re: [PATCH] kbuild: pahole-version: avoid errors if executing fails
Date: Fri, 23 Aug 2024 15:59:46 +0200 [thread overview]
Message-ID: <ZsiV0V5-UYFGkxPE@bergen> (raw)
In-Reply-To: <CAK7LNARhR=GGZ2Vr-SSog1yjnjh6iT7cCEe4mpYg889GhJnO9g@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2840 bytes --]
On Fri 23 Aug 2024 02:28:28 GMT, Masahiro Yamada wrote:
> Date: Fri, 23 Aug 2024 02:28:28 +0900
> From: Masahiro Yamada <masahiroy@kernel.org>
> To: Miguel Ojeda <ojeda@kernel.org>
> Cc: Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann
> <daniel@iogearbox.net>, Andrii Nakryiko <andrii@kernel.org>, Martin KaFai
> Lau <martin.lau@linux.dev>, Eduard Zingerman <eddyz87@gmail.com>, Song Liu
> <song@kernel.org>, Yonghong Song <yonghong.song@linux.dev>, John Fastabend
> <john.fastabend@gmail.com>, KP Singh <kpsingh@kernel.org>, Stanislav
> Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>, Jiri Olsa
> <jolsa@kernel.org>, bpf@vger.kernel.org, Nathan Chancellor
> <nathan@kernel.org>, Nicolas Schier <nicolas@fjasle.eu>,
> linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
> patches@lists.linux.dev
> Subject: Re: [PATCH] kbuild: pahole-version: avoid errors if executing fails
> X-Mailing-List: linux-kbuild@vger.kernel.org
> Message-ID: <CAK7LNARhR=GGZ2Vr-SSog1yjnjh6iT7cCEe4mpYg889GhJnO9g@mail.gmail.com>
>
> On Sun, Jul 28, 2024 at 9:55 PM Miguel Ojeda <ojeda@kernel.org> wrote:
> >
> > Like patch "rust: suppress error messages from
> > CONFIG_{RUSTC,BINDGEN}_VERSION_TEXT" [1], do not assume the file existing
> > and being executable implies executing it will succeed. Instead, bail
> > out if executing it fails for any reason.
> >
> > For instance, `pahole` may be built for another architecture, may be a
> > program we do not expect or may be completely broken:
> >
> > $ echo 'bad' > bad-pahole
> > $ chmod u+x bad-pahole
> > $ make PAHOLE=./bad-pahole defconfig
> > ...
> > ./bad-pahole: 1: bad: not found
> > init/Kconfig:112: syntax error
> > init/Kconfig:112: invalid statement
>
>
>
> Even with this patch applied, a syntax error can happen.
>
> $ git log --oneline -1
> dd1c54d77f11 kbuild: pahole-version: avoid errors if executing fails
> $ echo 'echo' > bad-pahole
> $ chmod u+x bad-pahole
> $ make PAHOLE=./bad-pahole defconfig
> *** Default configuration is based on 'x86_64_defconfig'
> init/Kconfig:114: syntax error
> init/Kconfig:114: invalid statement
> make[2]: *** [scripts/kconfig/Makefile:95: defconfig] Error 1
> make[1]: *** [/home/masahiro/workspace/linux-kbuild/Makefile:680:
> defconfig] Error 2
> make: *** [Makefile:224: __sub-make] Error 2
>
Do we have to catch all possibilities? Then, what about this:
#!/bin/sh
trap "echo 0; exit 1" EXIT
set -e
output=$("$@" --version 2>/dev/null)
output=$(echo "${output}" | sed -nE 's/^v([0-9]+)\.([0-9][0-9])$/\1\2/p')
if [ -z "${output}" ]; then
echo "warning: pahole binary '$1' outputs incompatible version number, pahole will not be used." >&2
exit 1
fi
echo "${output}"
trap EXIT
Kind regards,
Nicolas
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2024-08-23 14:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-28 12:55 [PATCH] kbuild: pahole-version: avoid errors if executing fails Miguel Ojeda
2024-08-02 23:34 ` Nicolas Schier
2024-08-22 17:28 ` Masahiro Yamada
2024-08-23 13:59 ` Nicolas Schier [this message]
2024-08-23 18:47 ` Miguel Ojeda
2024-09-02 2:15 ` Masahiro Yamada
2024-09-02 16:11 ` Miguel Ojeda
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=ZsiV0V5-UYFGkxPE@bergen \
--to=nicolas@fjasle.eu \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=masahiroy@kernel.org \
--cc=nathan@kernel.org \
--cc=ojeda@kernel.org \
--cc=patches@lists.linux.dev \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox