diff mbox series

arm allmodconfig build issue with bpf

Message ID 9950a25d-1a79-42c9-ade7-dc51ef569ad2@oracle.com (mailing list archive)
State New
Headers show
Series arm allmodconfig build issue with bpf | expand

Commit Message

John Garry Dec. 4, 2024, 3:54 p.m. UTC
Hi all,

For some time, the arm allmodconfig build has had this following build 
issue for me:

$ make net/bpf/test_run.o
   CALL    scripts/checksyscalls.sh
   CC      net/bpf/test_run.o
net/bpf/test_run.c:522:1: error: ‘retain’ attribute ignored 
[-Werror=attributes]
   522 | {
       | ^
net/bpf/test_run.c:568:1: error: ‘retain’ attribute ignored 
[-Werror=attributes]
   568 | {
       | ^
net/bpf/test_run.c:577:1: error: ‘retain’ attribute ignored 
[-Werror=attributes]
   577 | {
       | ^
net/bpf/test_run.c:584:1: error: ‘retain’ attribute ignored 
[-Werror=attributes]
   584 | {
       | ^
net/bpf/test_run.c:590:1: error: ‘retain’ attribute ignored 
[-Werror=attributes]
   590 | {
       | ^
net/bpf/test_run.c:619:1: error: ‘retain’ attribute ignored 
[-Werror=attributes]
   619 | {
       | ^
net/bpf/test_run.c:624:1: error: ‘retain’ attribute ignored 
[-Werror=attributes]
   624 | {
       | ^
net/bpf/test_run.c:630:1: error: ‘retain’ attribute ignored 
[-Werror=attributes]
   630 | {
       | ^
net/bpf/test_run.c:634:1: error: ‘retain’ attribute ignored 
[-Werror=attributes]
   634 | {
       | ^
cc1: all warnings being treated as errors
make[4]: *** [scripts/Makefile.build:194: net/bpf/test_run.o] Error 1
make[3]: *** [scripts/Makefile.build:440: net/bpf] Error 2
make[2]: *** [scripts/Makefile.build:440: net] Error 2
make[1]: *** [/home/ubuntu/mnt/linux2/Makefile:1989: .] Error 2
make: *** [Makefile:251: __sub-make] Error 2
ubuntu@jgarry-ubuntu-bm5-instance-20230215-1843:~/mnt/linux2$

The issue comes the definition of __bpf_kfunc from include/linux/btf.h

Other files which include btf.h, like kernel/cgroup/rstat.c, have this 
same issue.

I am crossing compiling with the following:

$ /usr/bin/arm-linux-gnueabihf-gcc --version
arm-linux-gnueabihf-gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Normally I bodge a fix like:

---->8----

        \
         __diag_push();


----8<----

Any proposals to properly fix this?

Thanks,
John

Comments

Russell King (Oracle) Dec. 4, 2024, 4:06 p.m. UTC | #1
On Wed, Dec 04, 2024 at 03:54:30PM +0000, John Garry wrote:
> Hi all,
> 
> For some time, the arm allmodconfig build has had this following build issue
> for me:
> 
> $ make net/bpf/test_run.o
>   CALL    scripts/checksyscalls.sh
>   CC      net/bpf/test_run.o
> net/bpf/test_run.c:522:1: error: ‘retain’ attribute ignored
> [-Werror=attributes]
>   522 | {
>       | ^
> net/bpf/test_run.c:568:1: error: ‘retain’ attribute ignored
> [-Werror=attributes]
>   568 | {
>       | ^
> net/bpf/test_run.c:577:1: error: ‘retain’ attribute ignored
> [-Werror=attributes]
>   577 | {
>       | ^
> net/bpf/test_run.c:584:1: error: ‘retain’ attribute ignored
> [-Werror=attributes]
>   584 | {
>       | ^
> net/bpf/test_run.c:590:1: error: ‘retain’ attribute ignored
> [-Werror=attributes]
>   590 | {
>       | ^
> net/bpf/test_run.c:619:1: error: ‘retain’ attribute ignored
> [-Werror=attributes]
>   619 | {
>       | ^
> net/bpf/test_run.c:624:1: error: ‘retain’ attribute ignored
> [-Werror=attributes]
>   624 | {
>       | ^
> net/bpf/test_run.c:630:1: error: ‘retain’ attribute ignored
> [-Werror=attributes]
>   630 | {
>       | ^
> net/bpf/test_run.c:634:1: error: ‘retain’ attribute ignored
> [-Werror=attributes]
>   634 | {
>       | ^
> cc1: all warnings being treated as errors
> make[4]: *** [scripts/Makefile.build:194: net/bpf/test_run.o] Error 1
> make[3]: *** [scripts/Makefile.build:440: net/bpf] Error 2
> make[2]: *** [scripts/Makefile.build:440: net] Error 2
> make[1]: *** [/home/ubuntu/mnt/linux2/Makefile:1989: .] Error 2
> make: *** [Makefile:251: __sub-make] Error 2
> ubuntu@jgarry-ubuntu-bm5-instance-20230215-1843:~/mnt/linux2$
> 
> The issue comes the definition of __bpf_kfunc from include/linux/btf.h

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99587

seems relevant. Jakub's reply in comment 3 suggests that:

#if __has_attribute(__retain__) && \
        (defined(CONFIG_LD_DEAD_CODE_DATA_ELIMINATION) || \
         defined(CONFIG_LTO_CLANG))
# define __retain                       __attribute__((__retain__))
#else
# define __retain
#endif

is wrong - __has_attribute(__retain__) doesn't mean that GCC supports
__retain__, it only means that it "knows" about it but may still
reject it.

The nice thing about this bug is... it's remained "NEW" for three
years already, so likely means that it remains unfixed.
diff mbox series

Patch

diff --git a/include/linux/btf.h b/include/linux/btf.h
index b12c63af9e78..4214e76c9168 100644
--- a/include/linux/btf.h
+++ b/include/linux/btf.h
@@ -83,7 +83,7 @@ 
   * as to avoid issues such as the compiler inlining or eliding either 
a static
   * kfunc, or a global kfunc in an LTO build.
   */
-#define __bpf_kfunc
+#define __bpf_kfunc __used __retain noinline

  #define __bpf_kfunc_start_defs()