BPF List
 help / color / mirror / Atom feed
From: "Emil Tsalapatis" <emil@etsalapatis.com>
To: "Vineet Gupta" <vineet.gupta@linux.dev>, <dwarves@vger.kernel.org>
Cc: <bpf@vger.kernel.org>, "Andrii Nakryiko" <andrii@kernel.org>,
	<acme@kernel.org>, "Alan Maguire" <alan.maguire@oracle.com>,
	"Emil Tsalapatis" <emil@etsalapatis.com>,
	<jose.marchesi@oracle.com>,
	"David Faust" <david.faust@oracle.com>
Subject: Re: [PAHOLE v4 3/3] tests: Support GCC in pfunct-btf-decl-tags test
Date: Wed, 03 Jun 2026 16:44:23 -0400	[thread overview]
Message-ID: <DIZPH1MFO1TW.NPPNVHBBCMHT@etsalapatis.com> (raw)
In-Reply-To: <20260602195512.1511013-3-vineet.gupta@linux.dev>

On Tue Jun 2, 2026 at 3:55 PM EDT, Vineet Gupta wrote:
> GCC 16+ supports btf_decl_tag via DW_TAG_GNU_annotation. Update the
> test to run with both GCC (>= 16) and clang when available, instead
> of requiring clang only.
>
> Signed-off-by: Vineet Gupta <vineet.gupta@linux.dev>

Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>

> ---
>  tests/pfunct-btf-decl-tags.sh | 72 +++++++++++++++++++++++++++--------
>  1 file changed, 56 insertions(+), 16 deletions(-)
>
> diff --git a/tests/pfunct-btf-decl-tags.sh b/tests/pfunct-btf-decl-tags.sh
> index 35884b4e8687..a46aa1f3df55 100755
> --- a/tests/pfunct-btf-decl-tags.sh
> +++ b/tests/pfunct-btf-decl-tags.sh
> @@ -6,24 +6,36 @@
>  source test_lib.sh
>  
>  outdir=$(make_tmpdir)
> -tmpobj=$(make_tmpobj)
>  
>  # Comment this out to save test data.
>  trap cleanup EXIT
>  
>  title_log "Check that pfunct can print btf_decl_tags read from BTF."
>  
> -# gcc now also supports decl tags as of gcc commit 43dcea48b8c,
> -# in upstream version 16.
> -# UPTODO: add a check here for that.
> +# gcc 16+ supports decl tags via DW_TAG_GNU_annotation (gcc commit ac7027f180b).
>  
> +GCC=${GCC:-gcc}
>  CLANG=${CLANG:-clang}
> -if ! command -v $CLANG > /dev/null; then
> -	error_log "Need clang for test $0"
> +
> +use_gcc=0
> +if command -v $GCC > /dev/null; then
> +	gcc_ver=$($GCC -dumpversion 2>/dev/null | cut -d. -f1)
> +	if [ "$gcc_ver" -ge 16 ] 2>/dev/null; then
> +		use_gcc=1
> +	fi
> +fi
> +
> +use_clang=0
> +if command -v $CLANG > /dev/null; then
> +	use_clang=1
> +fi
> +
> +if [ "$use_gcc" -eq 0 ] && [ "$use_clang" -eq 0 ]; then
> +	error_log "Need gcc >= 16 or clang for test $0"
>  	test_fail
>  fi
>  
> -(cat <<EOF
> +src=$(cat <<EOF
>  #define __tag(x) __attribute__((btf_decl_tag(#x)))
>  
>  __tag(a) __tag(b) __tag(c) void foo(void) {}
> @@ -31,7 +43,7 @@ __tag(a) __tag(b)          void bar(void) {}
>  __tag(a)                   void buz(void) {}
>  
>  EOF
> -) | $CLANG --target=bpf -c -g -x c -o $tmpobj -
> +)
>  
>  # tags order is not guaranteed
>  sort_tags=$(cat <<EOF
> @@ -54,16 +66,44 @@ a void buz(void);
>  EOF
>  )
>  
> -out=$(pfunct -P -F btf $tmpobj | awk "$sort_tags" | sort)
> -d=$(diff -u <(echo "$expected") <(echo "$out"))
> +run_test() {
> +	local compiler=$1
> +	local tmpobj=$2
> +
> +	info_log "Testing with $compiler"
> +	out=$(pfunct -P -F btf $tmpobj | awk "$sort_tags" | sort)
> +	d=$(diff -u <(echo "$expected") <(echo "$out"))
> +
> +	if [[ "$d" == "" ]]; then
> +		info_log "  passed"
> +		return 0
> +	else
> +		error_log "pfunct output does not match expected ($compiler):"
> +		info_log "$d"
> +		info_log
> +		info_log "Complete output:"
> +		info_log "$out"
> +		return 1
> +	fi
> +}
> +
> +failed=0
> +
> +if [ "$use_gcc" -eq 1 ]; then
> +	tmpobj=$(make_tmpobj)
> +	echo "$src" | $GCC -c -g -x c -o $tmpobj - 2>/dev/null
> +	pahole -J $tmpobj 2>/dev/null
> +	run_test "$GCC (version $gcc_ver)" "$tmpobj" || failed=1
> +fi
> +
> +if [ "$use_clang" -eq 1 ]; then
> +	tmpobj=$(make_tmpobj)
> +	echo "$src" | $CLANG --target=bpf -c -g -x c -o $tmpobj -
> +	run_test "$CLANG" "$tmpobj" || failed=1
> +fi
>  
> -if [[ "$d" == "" ]]; then
> +if [ "$failed" -eq 0 ]; then
>  	test_pass
>  else
> -	error_log "pfunct output does not match expected:"
> -	info_log "$d"
> -	info_log
> -	info_log "Complete output:"
> -	info_log "$out"
>  	test_fail
>  fi


  reply	other threads:[~2026-06-03 20:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-02 19:55 [PAHOLE v4 1/3] dwarf_loader: Extract die__add_btf_type_tag() helper [NFC] Vineet Gupta
2026-06-02 19:55 ` [PAHOLE v4 2/3] dwarf_loader: Add support for DW_TAG_GNU_annotation Vineet Gupta
2026-06-03 20:08   ` Yonghong Song
2026-06-03 20:54     ` Vineet Gupta
2026-06-03 21:40       ` Yonghong Song
2026-06-17 18:18     ` Vineet Gupta
2026-06-03 20:42   ` Emil Tsalapatis
2026-06-03 21:41   ` Yonghong Song
2026-06-17 18:34     ` Vineet Gupta
2026-06-07  9:54   ` Alan Maguire
2026-06-17 20:08     ` Vineet Gupta
2026-06-02 19:55 ` [PAHOLE v4 3/3] tests: Support GCC in pfunct-btf-decl-tags test Vineet Gupta
2026-06-03 20:44   ` Emil Tsalapatis [this message]
2026-06-03 21:52   ` Yonghong Song
2026-06-03 20:18 ` [PAHOLE v4 1/3] dwarf_loader: Extract die__add_btf_type_tag() helper [NFC] Yonghong Song
2026-06-03 20:37 ` Emil Tsalapatis

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=DIZPH1MFO1TW.NPPNVHBBCMHT@etsalapatis.com \
    --to=emil@etsalapatis.com \
    --cc=acme@kernel.org \
    --cc=alan.maguire@oracle.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=david.faust@oracle.com \
    --cc=dwarves@vger.kernel.org \
    --cc=jose.marchesi@oracle.com \
    --cc=vineet.gupta@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