Merge branch 'bpf-selftests-fixes-for-gcc-bpf-16'

Jose E. Marchesi says:

====================
bpf: selftests fixes for GCC-BPF 16

Hello.

Just a couple of small fixes to get the BPF selftests build with what
will become GCC 16 this spring.  One of the regressions is due to a
change in the behavior of a warning in GCC 16.  The other is due to
the fact that GCC 16 actually implements btf_decl_tag and
btf_type_tag.

Salud!
====================

Link: https://patch.msgid.link/20260106173650.18191-1-jose.marchesi@oracle.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
Alexei Starovoitov
2026-01-06 21:04:11 -08:00
3 changed files with 21 additions and 1 deletions

View File

@@ -7,6 +7,16 @@
#define MAX_ENTRIES 8
/* clang considers 'sum += 1' as usage but 'sum++' as non-usage. GCC
* is more consistent and considers both 'sum += 1' and 'sum++' as
* non-usage. This triggers warnings in the functions below.
*
* Starting with GCC 16 -Wunused-but-set-variable=2 can be used to
* mimic clang's behavior. */
#if !defined(__clang__) && __GNUC__ > 15
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
struct map_value {
struct bpf_timer timer;
};

View File

@@ -7,6 +7,16 @@
#include "bpf_tracing_net.h"
#include "bpf_misc.h"
/* clang considers 'sum += 1' as usage but 'sum++' as non-usage. GCC
* is more consistent and considers both 'sum += 1' and 'sum++' as
* non-usage. This triggers warnings in the functions below.
*
* Starting with GCC 16 -Wunused-but-set-variable=2 can be used to
* mimic clang's behavior. */
#if !defined(__clang__) && __GNUC__ > 15
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
char _license[] SEC("license") = "GPL";
struct {

View File

@@ -33,7 +33,7 @@ struct {
} hashmap1 SEC(".maps");
static __noinline int foo(int x __tag1 __tag2) __tag1 __tag2
static __noinline __tag1 __tag2 int foo(int x __tag1 __tag2)
{
struct key_t key;
value_t val = {};