All of lore.kernel.org
 help / color / mirror / Atom feed
* bpf selftest compiling error
@ 2022-05-13  0:49 Vincent Li
  2022-05-13  1:12 ` Vincent Li
  0 siblings, 1 reply; 6+ messages in thread
From: Vincent Li @ 2022-05-13  0:49 UTC (permalink / raw)
  To: bpf

Hi,

I cloned the bpf-next and tried to compile the bpf selftest.

first I got error

"
CC      /usr/src/bpf
next/tools/testing/selftests/bpf/tools/build/bpftool/xlated_dumper.o

make[1]: *** No rule to make target
'/usr/src/bpf-next/tools/include/asm-generic/bitops/find.h', needed by
'/usr/src/bpf-next/tools/testing/selftests/bpf/tools/build/bpftool/btf_dumper.o'.
Stop.

I could not find find.h in
/usr/src/bpf-next/tools/include/asm-generic/bitops/find.h but I found
it in /usr/src/bpf-next/tools/include/linux/find.h, copied it to
/usr/src/bpf-next/tools/include/asm-generic/bitops, seems resolved the
problem,

then I got another error below,

  CLNG-BPF [test_maps] map_kptr.o

progs/map_kptr.c:7:29: error: unknown attribute 'btf_type_tag' ignored
[-Werror,-Wunknown-attributes]

        struct prog_test_ref_kfunc __kptr *unref_ptr;

                                   ^~~~~~

/usr/src/bpf-next/tools/testing/selftests/bpf/tools/include/bpf/bpf_helpers.h:176:31:
note: expanded from macro '__kptr'

#define __kptr __attribute__((btf_type_tag("kptr")))

                              ^~~~~~~~~~~~~~~~~~~~

progs/map_kptr.c:8:29: error: unknown attribute 'btf_type_tag' ignored
[-Werror,-Wunknown-attributes]

        struct prog_test_ref_kfunc __kptr_ref *ref_ptr;

                                   ^~~~~~~~~~

/usr/src/bpf-next/tools/testing/selftests/bpf/tools/include/bpf/bpf_helpers.h:177:35:
note: expanded from macro '__kptr_ref'

#define __kptr_ref __attribute__((btf_type_tag("kptr_ref")))
"

my clang is 12.0.1 and installed new clang from llvm github repository

clang version 15.0.0 (https://github.com/llvm/llvm-project.git
e91a73de24d60954700d7ac0293c050ab2cbe90b)

it resolved the problem, but now I got error

  GEN-SKEL [test_progs] test_bpf_nf.skel.h

libbpf: failed to find BTF info for global/extern symbol 'bpf_skb_ct_lookup'

Error: failed to link
'/usr/src/bpf-next/tools/testing/selftests/bpf/test_bpf_nf.o': Unknown
error -2 (-2)

make: *** [Makefile:508:
/usr/src/bpf-next/tools/testing/selftests/bpf/test_bpf_nf.skel.h]
Error 254

running out of ideas on how to fix the compiling error. I hope I am
not doing something wrong :)

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

* Re: bpf selftest compiling error
  2022-05-13  0:49 bpf selftest compiling error Vincent Li
@ 2022-05-13  1:12 ` Vincent Li
  2022-05-18 14:51   ` Shung-Hsi Yu
  0 siblings, 1 reply; 6+ messages in thread
From: Vincent Li @ 2022-05-13  1:12 UTC (permalink / raw)
  To: bpf

On Thu, May 12, 2022 at 5:49 PM Vincent Li <vincent.mc.li@gmail.com> wrote:
>
> Hi,
>
> I cloned the bpf-next and tried to compile the bpf selftest.
>
> first I got error
>
> "
> CC      /usr/src/bpf
> next/tools/testing/selftests/bpf/tools/build/bpftool/xlated_dumper.o
>
> make[1]: *** No rule to make target
> '/usr/src/bpf-next/tools/include/asm-generic/bitops/find.h', needed by
> '/usr/src/bpf-next/tools/testing/selftests/bpf/tools/build/bpftool/btf_dumper.o'.
> Stop.
>
> I could not find find.h in
> /usr/src/bpf-next/tools/include/asm-generic/bitops/find.h but I found
> it in /usr/src/bpf-next/tools/include/linux/find.h, copied it to
> /usr/src/bpf-next/tools/include/asm-generic/bitops, seems resolved the
> problem,
>
> then I got another error below,
>
>   CLNG-BPF [test_maps] map_kptr.o
>
> progs/map_kptr.c:7:29: error: unknown attribute 'btf_type_tag' ignored
> [-Werror,-Wunknown-attributes]
>
>         struct prog_test_ref_kfunc __kptr *unref_ptr;
>
>                                    ^~~~~~
>
> /usr/src/bpf-next/tools/testing/selftests/bpf/tools/include/bpf/bpf_helpers.h:176:31:
> note: expanded from macro '__kptr'
>
> #define __kptr __attribute__((btf_type_tag("kptr")))
>
>                               ^~~~~~~~~~~~~~~~~~~~
>
> progs/map_kptr.c:8:29: error: unknown attribute 'btf_type_tag' ignored
> [-Werror,-Wunknown-attributes]
>
>         struct prog_test_ref_kfunc __kptr_ref *ref_ptr;
>
>                                    ^~~~~~~~~~
>
> /usr/src/bpf-next/tools/testing/selftests/bpf/tools/include/bpf/bpf_helpers.h:177:35:
> note: expanded from macro '__kptr_ref'
>
> #define __kptr_ref __attribute__((btf_type_tag("kptr_ref")))
> "
>
> my clang is 12.0.1 and installed new clang from llvm github repository
>
> clang version 15.0.0 (https://github.com/llvm/llvm-project.git
> e91a73de24d60954700d7ac0293c050ab2cbe90b)
>
> it resolved the problem, but now I got error
>
>   GEN-SKEL [test_progs] test_bpf_nf.skel.h
>
> libbpf: failed to find BTF info for global/extern symbol 'bpf_skb_ct_lookup'
>
> Error: failed to link
> '/usr/src/bpf-next/tools/testing/selftests/bpf/test_bpf_nf.o': Unknown
> error -2 (-2)
>
> make: *** [Makefile:508:
> /usr/src/bpf-next/tools/testing/selftests/bpf/test_bpf_nf.skel.h]
> Error 254
>
> running out of ideas on how to fix the compiling error. I hope I am
> not doing something wrong :)

I recompiled the bpf-next kernel tree after clang 15 installation with
make bzImage; make modules; make and then recompiled bpf selftest, all
compiling errors are gone, sorry for the noise.

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

* Re: bpf selftest compiling error
  2022-05-13  1:12 ` Vincent Li
@ 2022-05-18 14:51   ` Shung-Hsi Yu
  2022-05-19  8:21     ` Jean-Philippe Brucker
  0 siblings, 1 reply; 6+ messages in thread
From: Shung-Hsi Yu @ 2022-05-18 14:51 UTC (permalink / raw)
  To: Vincent Li, Jean-Philippe Brucker; +Cc: bpf, Quentin Monnet

On Thu, May 12, 2022 at 06:12:36PM -0700, Vincent Li wrote:
> On Thu, May 12, 2022 at 5:49 PM Vincent Li <vincent.mc.li@gmail.com> wrote:
> >
> > Hi,
> >
> > I cloned the bpf-next and tried to compile the bpf selftest.
> >
> > first I got error
> >
> > "
> > CC      /usr/src/bpf
> > next/tools/testing/selftests/bpf/tools/build/bpftool/xlated_dumper.o
> >
> > make[1]: *** No rule to make target
> > '/usr/src/bpf-next/tools/include/asm-generic/bitops/find.h', needed by
> > '/usr/src/bpf-next/tools/testing/selftests/bpf/tools/build/bpftool/btf_dumper.o'.
> > Stop.

I also ran into the same issue on bpf-next, and the error seems rather
absurd as

  1. asm-generic/bitops/find.h was removed back in 47d8c15615c0a "include:
     move find.h from asm_generic to linux", so perhaps this error has
     something to do with Makefile.asm-generic
  2. normal way of building bpftool with `make tools/bpf/bpftool` still
     works fine

Anyway removing ARCH= CROSS_COMPILE= in the bpf selftests Makefile
(reverting change added in ea79020a2d9e "selftests/bpf: Enable
cross-building with clang") can be used as a workaround to get the build
working again. Adding the commit author to the thread to see if there is
better approach available.


Best,
Shung-Hsi

> > I could not find find.h in
> > /usr/src/bpf-next/tools/include/asm-generic/bitops/find.h but I found
> > it in /usr/src/bpf-next/tools/include/linux/find.h, copied it to
> > /usr/src/bpf-next/tools/include/asm-generic/bitops, seems resolved the
> > problem,
> >
> > then I got another error below,
> >
> >   CLNG-BPF [test_maps] map_kptr.o
> >
> > progs/map_kptr.c:7:29: error: unknown attribute 'btf_type_tag' ignored
> > [-Werror,-Wunknown-attributes]
> >
> >         struct prog_test_ref_kfunc __kptr *unref_ptr;
> >
> >                                    ^~~~~~
> >
> > /usr/src/bpf-next/tools/testing/selftests/bpf/tools/include/bpf/bpf_helpers.h:176:31:
> > note: expanded from macro '__kptr'
> >
> > #define __kptr __attribute__((btf_type_tag("kptr")))
> >
> >                               ^~~~~~~~~~~~~~~~~~~~
> >
> > progs/map_kptr.c:8:29: error: unknown attribute 'btf_type_tag' ignored
> > [-Werror,-Wunknown-attributes]
> >
> >         struct prog_test_ref_kfunc __kptr_ref *ref_ptr;
> >
> >                                    ^~~~~~~~~~
> >
> > /usr/src/bpf-next/tools/testing/selftests/bpf/tools/include/bpf/bpf_helpers.h:177:35:
> > note: expanded from macro '__kptr_ref'
> >
> > #define __kptr_ref __attribute__((btf_type_tag("kptr_ref")))
> > "
> >
> > my clang is 12.0.1 and installed new clang from llvm github repository
> >
> > clang version 15.0.0 (https://github.com/llvm/llvm-project.git
> > e91a73de24d60954700d7ac0293c050ab2cbe90b)
> >
> > it resolved the problem, but now I got error
> >
> >   GEN-SKEL [test_progs] test_bpf_nf.skel.h
> >
> > libbpf: failed to find BTF info for global/extern symbol 'bpf_skb_ct_lookup'
> >
> > Error: failed to link
> > '/usr/src/bpf-next/tools/testing/selftests/bpf/test_bpf_nf.o': Unknown
> > error -2 (-2)
> >
> > make: *** [Makefile:508:
> > /usr/src/bpf-next/tools/testing/selftests/bpf/test_bpf_nf.skel.h]
> > Error 254
> >
> > running out of ideas on how to fix the compiling error. I hope I am
> > not doing something wrong :)
> 
> I recompiled the bpf-next kernel tree after clang 15 installation with
> make bzImage; make modules; make and then recompiled bpf selftest, all
> compiling errors are gone, sorry for the noise.


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

* Re: bpf selftest compiling error
  2022-05-18 14:51   ` Shung-Hsi Yu
@ 2022-05-19  8:21     ` Jean-Philippe Brucker
  2022-05-19 12:10       ` Quentin Monnet
  0 siblings, 1 reply; 6+ messages in thread
From: Jean-Philippe Brucker @ 2022-05-19  8:21 UTC (permalink / raw)
  To: Shung-Hsi Yu; +Cc: Vincent Li, bpf, Quentin Monnet

Hi,

On Wed, May 18, 2022 at 10:51:44PM +0800, Shung-Hsi Yu wrote:
> On Thu, May 12, 2022 at 06:12:36PM -0700, Vincent Li wrote:
> > On Thu, May 12, 2022 at 5:49 PM Vincent Li <vincent.mc.li@gmail.com> wrote:
> > >
> > > Hi,
> > >
> > > I cloned the bpf-next and tried to compile the bpf selftest.
> > >
> > > first I got error
> > >
> > > "
> > > CC      /usr/src/bpf
> > > next/tools/testing/selftests/bpf/tools/build/bpftool/xlated_dumper.o
> > >
> > > make[1]: *** No rule to make target
> > > '/usr/src/bpf-next/tools/include/asm-generic/bitops/find.h', needed by
> > > '/usr/src/bpf-next/tools/testing/selftests/bpf/tools/build/bpftool/btf_dumper.o'.
> > > Stop.
> 
> I also ran into the same issue on bpf-next, and the error seems rather
> absurd as
> 
>   1. asm-generic/bitops/find.h was removed back in 47d8c15615c0a "include:
>      move find.h from asm_generic to linux", so perhaps this error has
>      something to do with Makefile.asm-generic
>   2. normal way of building bpftool with `make tools/bpf/bpftool` still
>      works fine
> 
> Anyway removing ARCH= CROSS_COMPILE= in the bpf selftests Makefile
> (reverting change added in ea79020a2d9e "selftests/bpf: Enable
> cross-building with clang") can be used as a workaround to get the build
> working again. Adding the commit author to the thread to see if there is
> better approach available.

Could you share the commands that lead to this error?  And did you make
sure to clean the build tree?  I often get errors when building tools
because my toolchains changed and some dependencies in generated .*.d
files do not exist anymore.

I can't reproduce this specific error on today's linux-next (but found
another issue with out-of-tree build that I'll investigate). This is what
I run, on an x86 host for an x86 target:

 $ make defconfig
 $ cat tools/testing/selftests/bpf/config >> .config
   # and enable CONFIG_DEBUG_INFO_BTF
 $ make
 $ make -C tools/testing/selftests TARGETS=bpf SKIP_TARGETS=

Thanks,
Jean

> 
> 
> Best,
> Shung-Hsi
> 
> > > I could not find find.h in
> > > /usr/src/bpf-next/tools/include/asm-generic/bitops/find.h but I found
> > > it in /usr/src/bpf-next/tools/include/linux/find.h, copied it to
> > > /usr/src/bpf-next/tools/include/asm-generic/bitops, seems resolved the
> > > problem,
> > >
> > > then I got another error below,
> > >
> > >   CLNG-BPF [test_maps] map_kptr.o
> > >
> > > progs/map_kptr.c:7:29: error: unknown attribute 'btf_type_tag' ignored
> > > [-Werror,-Wunknown-attributes]
> > >
> > >         struct prog_test_ref_kfunc __kptr *unref_ptr;
> > >
> > >                                    ^~~~~~
> > >
> > > /usr/src/bpf-next/tools/testing/selftests/bpf/tools/include/bpf/bpf_helpers.h:176:31:
> > > note: expanded from macro '__kptr'
> > >
> > > #define __kptr __attribute__((btf_type_tag("kptr")))
> > >
> > >                               ^~~~~~~~~~~~~~~~~~~~
> > >
> > > progs/map_kptr.c:8:29: error: unknown attribute 'btf_type_tag' ignored
> > > [-Werror,-Wunknown-attributes]
> > >
> > >         struct prog_test_ref_kfunc __kptr_ref *ref_ptr;
> > >
> > >                                    ^~~~~~~~~~
> > >
> > > /usr/src/bpf-next/tools/testing/selftests/bpf/tools/include/bpf/bpf_helpers.h:177:35:
> > > note: expanded from macro '__kptr_ref'
> > >
> > > #define __kptr_ref __attribute__((btf_type_tag("kptr_ref")))
> > > "
> > >
> > > my clang is 12.0.1 and installed new clang from llvm github repository
> > >
> > > clang version 15.0.0 (https://github.com/llvm/llvm-project.git
> > > e91a73de24d60954700d7ac0293c050ab2cbe90b)
> > >
> > > it resolved the problem, but now I got error
> > >
> > >   GEN-SKEL [test_progs] test_bpf_nf.skel.h
> > >
> > > libbpf: failed to find BTF info for global/extern symbol 'bpf_skb_ct_lookup'
> > >
> > > Error: failed to link
> > > '/usr/src/bpf-next/tools/testing/selftests/bpf/test_bpf_nf.o': Unknown
> > > error -2 (-2)
> > >
> > > make: *** [Makefile:508:
> > > /usr/src/bpf-next/tools/testing/selftests/bpf/test_bpf_nf.skel.h]
> > > Error 254
> > >
> > > running out of ideas on how to fix the compiling error. I hope I am
> > > not doing something wrong :)
> > 
> > I recompiled the bpf-next kernel tree after clang 15 installation with
> > make bzImage; make modules; make and then recompiled bpf selftest, all
> > compiling errors are gone, sorry for the noise.
> 

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

* Re: bpf selftest compiling error
  2022-05-19  8:21     ` Jean-Philippe Brucker
@ 2022-05-19 12:10       ` Quentin Monnet
  2022-05-19 15:57         ` Shung-Hsi Yu
  0 siblings, 1 reply; 6+ messages in thread
From: Quentin Monnet @ 2022-05-19 12:10 UTC (permalink / raw)
  To: Jean-Philippe Brucker, Shung-Hsi Yu; +Cc: Vincent Li, bpf

2022-05-19 09:21 UTC+0100 ~ Jean-Philippe Brucker <jean-philippe@linaro.org>
> Hi,
> 
> On Wed, May 18, 2022 at 10:51:44PM +0800, Shung-Hsi Yu wrote:
>> On Thu, May 12, 2022 at 06:12:36PM -0700, Vincent Li wrote:
>>> On Thu, May 12, 2022 at 5:49 PM Vincent Li <vincent.mc.li@gmail.com> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I cloned the bpf-next and tried to compile the bpf selftest.
>>>>
>>>> first I got error
>>>>
>>>> "
>>>> CC      /usr/src/bpf
>>>> next/tools/testing/selftests/bpf/tools/build/bpftool/xlated_dumper.o
>>>>
>>>> make[1]: *** No rule to make target
>>>> '/usr/src/bpf-next/tools/include/asm-generic/bitops/find.h', needed by
>>>> '/usr/src/bpf-next/tools/testing/selftests/bpf/tools/build/bpftool/btf_dumper.o'.
>>>> Stop.
>>
>> I also ran into the same issue on bpf-next, and the error seems rather
>> absurd as
>>
>>   1. asm-generic/bitops/find.h was removed back in 47d8c15615c0a "include:
>>      move find.h from asm_generic to linux", so perhaps this error has
>>      something to do with Makefile.asm-generic
>>   2. normal way of building bpftool with `make tools/bpf/bpftool` still
>>      works fine
>>
>> Anyway removing ARCH= CROSS_COMPILE= in the bpf selftests Makefile
>> (reverting change added in ea79020a2d9e "selftests/bpf: Enable
>> cross-building with clang") can be used as a workaround to get the build
>> working again. Adding the commit author to the thread to see if there is
>> better approach available.
> 
> Could you share the commands that lead to this error?  And did you make
> sure to clean the build tree?  I often get errors when building tools
> because my toolchains changed and some dependencies in generated .*.d
> files do not exist anymore.
> 
> I can't reproduce this specific error on today's linux-next (but found
> another issue with out-of-tree build that I'll investigate). This is what
> I run, on an x86 host for an x86 target:
> 
>  $ make defconfig
>  $ cat tools/testing/selftests/bpf/config >> .config
>    # and enable CONFIG_DEBUG_INFO_BTF
>  $ make
>  $ make -C tools/testing/selftests TARGETS=bpf SKIP_TARGETS=
> 
> Thanks,
> Jean

Hi, for what it's worth I also observed the same today in samples/bpf;
but after "make clean" the issue disappeared, and I can't reproduce it
anymore.

Quentin

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

* Re: bpf selftest compiling error
  2022-05-19 12:10       ` Quentin Monnet
@ 2022-05-19 15:57         ` Shung-Hsi Yu
  0 siblings, 0 replies; 6+ messages in thread
From: Shung-Hsi Yu @ 2022-05-19 15:57 UTC (permalink / raw)
  To: Quentin Monnet; +Cc: Jean-Philippe Brucker, Vincent Li, bpf

On Thu, May 19, 2022 at 01:10:42PM +0100, Quentin Monnet wrote:
> 2022-05-19 09:21 UTC+0100 ~ Jean-Philippe Brucker <jean-philippe@linaro.org>
> > Hi,
> > 
> > On Wed, May 18, 2022 at 10:51:44PM +0800, Shung-Hsi Yu wrote:
> >> On Thu, May 12, 2022 at 06:12:36PM -0700, Vincent Li wrote:
> >>> On Thu, May 12, 2022 at 5:49 PM Vincent Li <vincent.mc.li@gmail.com> wrote:
> >>>>
> >>>> Hi,
> >>>>
> >>>> I cloned the bpf-next and tried to compile the bpf selftest.
> >>>>
> >>>> first I got error
> >>>>
> >>>> "
> >>>> CC      /usr/src/bpf
> >>>> next/tools/testing/selftests/bpf/tools/build/bpftool/xlated_dumper.o
> >>>>
> >>>> make[1]: *** No rule to make target
> >>>> '/usr/src/bpf-next/tools/include/asm-generic/bitops/find.h', needed by
> >>>> '/usr/src/bpf-next/tools/testing/selftests/bpf/tools/build/bpftool/btf_dumper.o'.
> >>>> Stop.
> >>
> >> I also ran into the same issue on bpf-next, and the error seems rather
> >> absurd as
> >>
> >>   1. asm-generic/bitops/find.h was removed back in 47d8c15615c0a "include:
> >>      move find.h from asm_generic to linux", so perhaps this error has
> >>      something to do with Makefile.asm-generic
> >>   2. normal way of building bpftool with `make tools/bpf/bpftool` still
> >>      works fine
> >>
> >> Anyway removing ARCH= CROSS_COMPILE= in the bpf selftests Makefile
> >> (reverting change added in ea79020a2d9e "selftests/bpf: Enable
> >> cross-building with clang") can be used as a workaround to get the build
> >> working again. Adding the commit author to the thread to see if there is
> >> better approach available.
> > 
> > Could you share the commands that lead to this error?  And did you make
> > sure to clean the build tree?  I often get errors when building tools
> > because my toolchains changed and some dependencies in generated .*.d
> > files do not exist anymore.

In hindsight I likely did a clean after removing the cross-compile
environment variables, and that's probably what made the build work, not the
removal of ARCH= CROSS_COMPILE=. Sorry for jumping to conclusion.

> > I can't reproduce this specific error on today's linux-next (but found
> > another issue with out-of-tree build that I'll investigate). This is what
> > I run, on an x86 host for an x86 target:
> > 
> >  $ make defconfig
> >  $ cat tools/testing/selftests/bpf/config >> .config
> >    # and enable CONFIG_DEBUG_INFO_BTF
> >  $ make
> >  $ make -C tools/testing/selftests TARGETS=bpf SKIP_TARGETS=
> > 
> > Thanks,
> > Jean
> 
> Hi, for what it's worth I also observed the same today in samples/bpf;
> but after "make clean" the issue disappeared, and I can't reproduce it
> anymore.
> 
> Quentin

I also can't get the error to reproduce.

Thanks,
Shung-Hsi


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

end of thread, other threads:[~2022-05-19 15:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-13  0:49 bpf selftest compiling error Vincent Li
2022-05-13  1:12 ` Vincent Li
2022-05-18 14:51   ` Shung-Hsi Yu
2022-05-19  8:21     ` Jean-Philippe Brucker
2022-05-19 12:10       ` Quentin Monnet
2022-05-19 15:57         ` Shung-Hsi Yu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.