BPF Archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next V2 0/2] bpf: avoid `attribute ignored' warnings in GCC
@ 2024-05-07  7:42 Jose E. Marchesi
  2024-05-07  7:42 ` [PATCH bpf-next V2 1/2] bpf: avoid __hidden__ attribute in static object Jose E. Marchesi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jose E. Marchesi @ 2024-05-07  7:42 UTC (permalink / raw
  To: bpf

These two patches avoid warnings (turned into errors) when building
the BPF selftests with GCC.

[Changes from V1:
- As requested by reviewer, an additional patch has been added in
  order to remove __hidden from the `private' macro in
  cpumask_common.h.
- Typo bening -> benign fixed in the commit message of the second
  patch.]

Jose E. Marchesi (2):
  bpf: avoid __hidden__ attribute in static object
  bpf: disable some `attribute ignored' warnings in GCC

 tools/testing/selftests/bpf/Makefile               | 2 +-
 tools/testing/selftests/bpf/progs/cpumask_common.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH bpf-next V2 1/2] bpf: avoid __hidden__ attribute in static object
  2024-05-07  7:42 [PATCH bpf-next V2 0/2] bpf: avoid `attribute ignored' warnings in GCC Jose E. Marchesi
@ 2024-05-07  7:42 ` Jose E. Marchesi
  2024-05-07  7:42 ` [PATCH bpf-next V2 2/2] bpf: disable some `attribute ignored' warnings in GCC Jose E. Marchesi
  2024-05-07 21:40 ` [PATCH bpf-next V2 0/2] bpf: avoid " patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Jose E. Marchesi @ 2024-05-07  7:42 UTC (permalink / raw
  To: bpf; +Cc: Jose E . Marchesi, david.faust, cupertino.miranda, Yonghong Song

An object defined as `static' defaults to hidden visibility.  If
additionally the visibility(__weak__) compiler attribute is applied to
the declaration of the object, GCC warns that the attribute gets
ignored.

This patch removes the only instance of this problem among the BPF
selftests.

Tested in bpf-next master.

Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
Cc: david.faust@oracle.com
Cc: cupertino.miranda@oracle.com
Cc: Yonghong Song <yonghong.song@linux.dev>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
---
 tools/testing/selftests/bpf/progs/cpumask_common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/progs/cpumask_common.h b/tools/testing/selftests/bpf/progs/cpumask_common.h
index c705d8112a35..b979e91f55f0 100644
--- a/tools/testing/selftests/bpf/progs/cpumask_common.h
+++ b/tools/testing/selftests/bpf/progs/cpumask_common.h
@@ -9,7 +9,7 @@
 
 int err;
 
-#define private(name) SEC(".bss." #name) __hidden __attribute__((aligned(8)))
+#define private(name) SEC(".bss." #name) __attribute__((aligned(8)))
 private(MASK) static struct bpf_cpumask __kptr * global_mask;
 
 struct __cpumask_map_value {
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH bpf-next V2 2/2] bpf: disable some `attribute ignored' warnings in GCC
  2024-05-07  7:42 [PATCH bpf-next V2 0/2] bpf: avoid `attribute ignored' warnings in GCC Jose E. Marchesi
  2024-05-07  7:42 ` [PATCH bpf-next V2 1/2] bpf: avoid __hidden__ attribute in static object Jose E. Marchesi
@ 2024-05-07  7:42 ` Jose E. Marchesi
  2024-05-07 21:40 ` [PATCH bpf-next V2 0/2] bpf: avoid " patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Jose E. Marchesi @ 2024-05-07  7:42 UTC (permalink / raw
  To: bpf
  Cc: Jose E . Marchesi, david.faust, cupertino.miranda, Yonghong Song,
	Eduard Zingerman

This patch modifies selftests/bpf/Makefile to pass -Wno-attributes to
GCC.  This is because of the following attributes which are ignored:

- btf_decl_tag
- btf_type_tag

  There are many of these.  At the moment none of these are
  recognized/handled by gcc-bpf.

  We are aware that btf_decl_tag is necessary for some of the
  selftest harness to communicate test failure/success.  Support for
  it is in progress in GCC upstream:

  https://gcc.gnu.org/pipermail/gcc-patches/2024-May/650482.html

  However, the GCC master branch is not yet open, so the series
  above (currently under review upstream) wont be able to make it
  there until 14.1 gets released, probably mid next week.

  As for btf_type_tag, more extensive work will be needed in GCC
  upstream to support it in both BTF and DWARF.  We have a WIP big
  patch for that, but that is not needed to compile/build the
  selftests.

- used

  There are SEC macros defined in the selftests as:

  #define SEC(N) __attribute__((section(N),used))

  The SEC macro is used for both functions and global variables.
  According to the GCC documentation `used' attribute is really only
  meaningful for functions, and it warns when the attribute is used
  for other global objects, like for example ctl_array in
  test_xdp_noinline.c.

  Ignoring this is benign.

- align_value

  In progs/test_cls_redirect.c:127 there is:

  typedef uint8_t *net_ptr __attribute__((align_value(8)));

  GCC warns that it is ignoring this attribute, because it is not
  implemented by GCC.

  I think ignoring this attribute in GCC is benign, because according
  to the clang documentation [1] its purpose seems to be merely
  declarative and doesn't seem to translate into extra checks at
  run-time, only to perhaps better optimized code ("runtime behavior
  is undefined if the pointed memory object is not aligned to the
  specified alignment").

  [1] https://clang.llvm.org/docs/AttributeReference.html#align-value

Tested in bpf-next master.

Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
Cc: david.faust@oracle.com
Cc: cupertino.miranda@oracle.com
Cc: Yonghong Song <yonghong.song@linux.dev>
Cc: Eduard Zingerman <eddyz87@gmail.com>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
---
 tools/testing/selftests/bpf/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index ba28d42b74db..5d9c906bc3cb 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -431,7 +431,7 @@ endef
 # Build BPF object using GCC
 define GCC_BPF_BUILD_RULE
 	$(call msg,GCC-BPF,$(TRUNNER_BINARY),$2)
-	$(Q)$(BPF_GCC) $3 -O2 -c $1 -o $2
+	$(Q)$(BPF_GCC) $3 -Wno-attributes -O2 -c $1 -o $2
 endef
 
 SKEL_BLACKLIST := btf__% test_pinning_invalid.c test_sk_assign.c
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next V2 0/2] bpf: avoid `attribute ignored' warnings in GCC
  2024-05-07  7:42 [PATCH bpf-next V2 0/2] bpf: avoid `attribute ignored' warnings in GCC Jose E. Marchesi
  2024-05-07  7:42 ` [PATCH bpf-next V2 1/2] bpf: avoid __hidden__ attribute in static object Jose E. Marchesi
  2024-05-07  7:42 ` [PATCH bpf-next V2 2/2] bpf: disable some `attribute ignored' warnings in GCC Jose E. Marchesi
@ 2024-05-07 21:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-05-07 21:40 UTC (permalink / raw
  To: Jose E. Marchesi; +Cc: bpf

Hello:

This series was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Tue,  7 May 2024 09:42:25 +0200 you wrote:
> These two patches avoid warnings (turned into errors) when building
> the BPF selftests with GCC.
> 
> [Changes from V1:
> - As requested by reviewer, an additional patch has been added in
>   order to remove __hidden from the `private' macro in
>   cpumask_common.h.
> - Typo bening -> benign fixed in the commit message of the second
>   patch.]
> 
> [...]

Here is the summary with links:
  - [bpf-next,V2,1/2] bpf: avoid __hidden__ attribute in static object
    https://git.kernel.org/bpf/bpf-next/c/2ce987e16502
  - [bpf-next,V2,2/2] bpf: disable some `attribute ignored' warnings in GCC
    https://git.kernel.org/bpf/bpf-next/c/b0fbdf759da0

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-05-07 21:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-07  7:42 [PATCH bpf-next V2 0/2] bpf: avoid `attribute ignored' warnings in GCC Jose E. Marchesi
2024-05-07  7:42 ` [PATCH bpf-next V2 1/2] bpf: avoid __hidden__ attribute in static object Jose E. Marchesi
2024-05-07  7:42 ` [PATCH bpf-next V2 2/2] bpf: disable some `attribute ignored' warnings in GCC Jose E. Marchesi
2024-05-07 21:40 ` [PATCH bpf-next V2 0/2] bpf: avoid " patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).