Skip to contentSkip to conversation

Question about "asm/rwonce.h: No such file or directory"

DISCUSSION Xiao Yang 4 participants 15 messages Nov 12, 2019 – Nov 13, 2019

Subsystems (2)
lore
Share & tools
lore

Xiao Yang

author
#0 lore raw

Hi Will,

With your patch[1], I alway get the following error when building tools/bpf:

----------------------------------------------------------------------------------

make -C tools/bpf/
make: Entering directory '/usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/tools/bpf'

Auto-detecting system features:
... libbfd: [ on ]
... disassembler-four-args: [ OFF ]

CC bpf_jit_disasm.o
CC bpf_dbg.o
In file included from /usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/include/uapi/linux/filter.h:9:0, from /usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/tools/bpf/bpf_dbg.c:41:
/usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/include/linux/compiler.h:247:24:
fatal error: asm/rwonce.h: No such file or directory
#include <asm/rwonce.h>
^
compilation terminated.
Makefile:61: recipe for target 'bpf_dbg.o' failed
make: *** [bpf_dbg.o] Error 1
make: *** Waiting for unfinished jobs....
make: Leaving directory

----------------------------------------------------------------------------------

[1] https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git/commit/?h=lto&id=642a312d47ceb54603630d9d04f5052f3b46d9a3

It seems that include/linux/compiler.h cannot find the asm/rwonce.h because tools/bpf/Makefile doesn't include arch/*/include/generated/asm/rwonce.h.

Did I miss some operations to build tools/bpf?

Best Regards,

XIao Yang

#1 lore raw

[+lkml, Masahiro, Alexei and Daniel]

Quoted 2 lines · Xiao Yang

With your patch[1], I alway get the following error when building tools/bpf:

In case people want to reproduce this, my branch is here:

https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git/log/?h=lto

Quoted 26 lines

----------------------------------------------------------------------------------

make -C tools/bpf/
make: Entering directory '/usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/tools/bpf'

Auto-detecting system features:
... libbfd: [ on ]
... disassembler-four-args: [ OFF ]

CC bpf_jit_disasm.o
CC bpf_dbg.o
In file included from /usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/include/uapi/linux/filter.h:9:0, from /usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/tools/bpf/bpf_dbg.c:41:
/usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/include/linux/compiler.h:247:24:
fatal error: asm/rwonce.h: No such file or directory
#include <asm/rwonce.h>
^
compilation terminated.
Makefile:61: recipe for target 'bpf_dbg.o' failed
make: *** [bpf_dbg.o] Error 1
make: *** Waiting for unfinished jobs....
make: Leaving directory

Quoted 6 lines

----------------------------------------------------------------------------------

[1] https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git/commit/?h=lto&id=642a312d47ceb54603630d9d04f5052f3b46d9a3

It seems that include/linux/compiler.h cannot find the asm/rwonce.h because tools/bpf/Makefile doesn't include arch/*/include/generated/asm/rwonce.h.

The problem with referring to the generated files is that they don't exist unless you've configured the main source directory. The real problem here seems to be that tools/bpf/ refers directly to header files in the kernel sources without any understanding of kbuild, and therefore mandatory-y headers simply don't exist when it goes looking for them.

Perhaps it's possible to introduce a dependency on a top-level "make asm-generic" so that we can reference the generated headers from the arch directly. Thoughts?

Will

#2 lore raw
Quoted 41 lines · Will Deacon

[+lkml, Masahiro, Alexei and Daniel]

Quoted 2 lines · Xiao Yang

With your patch[1], I alway get the following error when building tools/bpf:

In case people want to reproduce this, my branch is here:

https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git/log/?h=lto

Quoted 30 lines

----------------------------------------------------------------------------------

make -C tools/bpf/
make: Entering directory '/usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/tools/bpf'

Auto-detecting system features:
... libbfd: [ on ]
... disassembler-four-args: [ OFF ]

CC bpf_jit_disasm.o
CC bpf_dbg.o
In file included from /usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/include/uapi/linux/filter.h:9:0, from /usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/tools/bpf/bpf_dbg.c:41:
/usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/include/linux/compiler.h:247:24:
fatal error: asm/rwonce.h: No such file or directory
#include <asm/rwonce.h>
^
compilation terminated.
Makefile:61: recipe for target 'bpf_dbg.o' failed
make: *** [bpf_dbg.o] Error 1
make: *** Waiting for unfinished jobs....
make: Leaving directory

----------------------------------------------------------------------------------

[1] https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git/commit/?h=lto&id=642a312d47ceb54603630d9d04f5052f3b46d9a3

Quoted 8 lines
Quoted 2 lines

It seems that include/linux/compiler.h cannot find the asm/rwonce.h because tools/bpf/Makefile doesn't include arch/*/include/generated/asm/rwonce.h.

The problem with referring to the generated files is that they don't exist unless you've configured the main source directory. The real problem here seems to be that tools/bpf/ refers directly to header files in the kernel sources without any understanding of kbuild, and therefore mandatory-y headers simply don't exist when it goes looking for them.

Please note tools/ is out of scope of Kbuild. The tools/ created a completely different build system.

tools/bpf/ looks like a host program.
Does it include a kernel-space header
of the target architecture?

I see a lots of header duplication in tools/include/, but I am not sure if tools/include/linux/filter.h is the correct header to include.

Quoted 6 lines

Perhaps it's possible to introduce a dependency on a top-level "make asm-generic" so that we can reference the generated headers from the arch directly. Thoughts?

Will

Signature · 2 lines
Best Regards
Masahiro Yamada
maintainer
#3 lore raw
Quoted 42 lines · Masahiro Yamada
Quoted 41 lines · Will Deacon

[+lkml, Masahiro, Alexei and Daniel]

Quoted 2 lines · Xiao Yang

With your patch[1], I alway get the following error when building tools/bpf:

In case people want to reproduce this, my branch is here:

https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git/log/?h=lto

Quoted 30 lines

----------------------------------------------------------------------------------

make -C tools/bpf/
make: Entering directory '/usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/tools/bpf'

Auto-detecting system features:
... libbfd: [ on ]
... disassembler-four-args: [ OFF ]

CC bpf_jit_disasm.o
CC bpf_dbg.o
In file included from /usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/include/uapi/linux/filter.h:9:0, from /usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/tools/bpf/bpf_dbg.c:41:
/usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/include/linux/compiler.h:247:24:
fatal error: asm/rwonce.h: No such file or directory
#include <asm/rwonce.h>
^
compilation terminated.
Makefile:61: recipe for target 'bpf_dbg.o' failed
make: *** [bpf_dbg.o] Error 1
make: *** Waiting for unfinished jobs....
make: Leaving directory

----------------------------------------------------------------------------------

[1] https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git/commit/?h=lto&id=642a312d47ceb54603630d9d04f5052f3b46d9a3

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

It seems that include/linux/compiler.h cannot find the asm/rwonce.h because tools/bpf/Makefile doesn't include arch/*/include/generated/asm/rwonce.h.

The problem with referring to the generated files is that they don't exist unless you've configured the main source directory. The real problem here seems to be that tools/bpf/ refers directly to header files in the kernel sources without any understanding of kbuild, and therefore mandatory-y headers simply don't exist when it goes looking for them.

Hmm, I am puzzled why that is. :/ I think there are two options, i) remove it from CFLAGS like below (at least this doesn't let the build fail in my case but requires linux headers to be installed) or ii) add a copy of filter.h to tools/include/uapi/linux/filter.h so the few tools can just reuse it. We do have bpf_common.h and bpf.h there already.

tools/bpf/Makefile +0 -1
index 5d1995fd369c..08dfd289174c 100644
@@ -10,7 +10,6 @@ MAKE = make
 INSTALL ?= install
 
 CFLAGS += -Wall -O2
-CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/include/uapi -I$(srctree)/include
 
 # This will work when bpf is built in tools env. where srctree
 # isn't set and when invoked from selftests build, where srctree

Thanks,
Daniel

author
#14 lore raw
In reply to Will Deacon
Quoted 47 lines · Will Deacon

[+lkml, Masahiro, Alexei and Daniel]

Quoted 2 lines · Xiao Yang

With your patch[1], I alway get the following error when building tools/bpf:

In case people want to reproduce this, my branch is here:

https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git/log/?h=lto

Quoted 26 lines

----------------------------------------------------------------------------------

make -C tools/bpf/
make: Entering directory '/usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/tools/bpf'

Auto-detecting system features:
... libbfd: [ on ]
... disassembler-four-args: [ OFF ]

CC bpf_jit_disasm.o
CC bpf_dbg.o
In file included from /usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/include/uapi/linux/filter.h:9:0, from /usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/tools/bpf/bpf_dbg.c:41:
/usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/include/linux/compiler.h:247:24:
fatal error: asm/rwonce.h: No such file or directory
#include <asm/rwonce.h>
^
compilation terminated.
Makefile:61: recipe for target 'bpf_dbg.o' failed
make: *** [bpf_dbg.o] Error 1
make: *** Waiting for unfinished jobs....
make: Leaving directory

Quoted 6 lines

----------------------------------------------------------------------------------

[1] https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git/commit/?h=lto&id=642a312d47ceb54603630d9d04f5052f3b46d9a3

It seems that include/linux/compiler.h cannot find the asm/rwonce.h because tools/bpf/Makefile doesn't include arch/*/include/generated/asm/rwonce.h.

The problem with referring to the generated files is that they don't exist unless you've configured the main source directory. The real problem here seems to be that tools/bpf/ refers directly to header files in the kernel sources without any understanding of kbuild, and therefore mandatory-y headers simply don't exist when it goes looking for them.

Quoted 3 lines

Perhaps it's possible to introduce a dependency on a top-level "make asm-generic" so that we can reference the generated headers from the arch directly. Thoughts?

Hi Will,

Thanks for your reply.

I tried to do "make asm-generic" operation before, but it just generated asm/rwonce.h

in arch/*/include/generated directory and building tools/bpf still cannot find it.

Perhaps, the Makefile of tools/bpf needs to be improved.

Best Regards,

Xiao Yang

Quoted 2 lines

Will

author
#4 lore raw
In reply to Daniel Borkmann
Quoted 59 lines · Daniel Borkmann
Quoted 49 lines · Masahiro Yamada
Quoted 48 lines · Will Deacon

[+lkml, Masahiro, Alexei and Daniel]

Quoted 2 lines · Xiao Yang

With your patch[1], I alway get the following error when building tools/bpf:

In case people want to reproduce this, my branch is here:

https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git/log/?h=lto

Quoted 36 lines

----------------------------------------------------------------------------------

make -C tools/bpf/
make: Entering directory '/usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/tools/bpf'

Auto-detecting system features:
... libbfd: [ on ]
... disassembler-four-args: [ OFF ]

CC bpf_jit_disasm.o
CC bpf_dbg.o
In file included from /usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/include/uapi/linux/filter.h:9:0,

from /usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/tools/bpf/bpf_dbg.c:41:

/usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/include/linux/compiler.h:247:24:

fatal error: asm/rwonce.h: No such file or directory #include <asm/rwonce.h>
^
compilation terminated.
Makefile:61: recipe for target 'bpf_dbg.o' failed
make: *** [bpf_dbg.o] Error 1
make: *** Waiting for unfinished jobs....
make: Leaving directory

----------------------------------------------------------------------------------

[1] https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git/commit/?h=lto&id=642a312d47ceb54603630d9d04f5052f3b46d9a3

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

It seems that include/linux/compiler.h cannot find the asm/rwonce.h because tools/bpf/Makefile doesn't include arch/*/include/generated/asm/rwonce.h.

The problem with referring to the generated files is that they don't exist unless you've configured the main source directory. The real problem here seems to be that tools/bpf/ refers directly to header files in the kernel sources without any understanding of kbuild, and therefore mandatory-y headers simply don't exist when it goes looking for them.

Quoted 5 lines

Hmm, I am puzzled why that is. :/ I think there are two options, i) remove it from CFLAGS like below (at least this doesn't let the build fail in my case but requires linux headers to be installed) or ii) add a copy of filter.h to tools/include/uapi/linux/filter.h so the few tools can just reuse it. We do have bpf_common.h and bpf.h there already.

Hi Daniel,

Thanks for your suggestions.

Did you mean that building bpf uses the filter.h from installed linux header rather than include/uapi/linux/filter.h in kernel?

It seems that you just try to workaround the issue by using linux/filter.h from linux header.

The root casue is that include/linux/compiler.h cannot find the location of <asm/rwonce.h>.

Thanks,

Xiao Yang

Quoted 17 lines
tools/bpf/Makefile +0 -0
index 5d1995fd369c..08dfd289174c 100644
@@ -10,7 +10,6 @@ MAKE = make

 INSTALL ?= install

 CFLAGS += -Wall -O2

tools/bpf/Makefile +0 -2
-CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/include/uapi 
-I$(srctree)/include

 # This will work when bpf is built in tools env. where srctree # isn't set and when invoked from selftests build, where srctree

Thanks,
Daniel

#5 lore raw
In reply to Daniel Borkmann
Quoted 65 lines · Daniel Borkmann
Quoted 42 lines · Masahiro Yamada
Quoted 41 lines · Will Deacon

[+lkml, Masahiro, Alexei and Daniel]

Quoted 2 lines · Xiao Yang

With your patch[1], I alway get the following error when building tools/bpf:

In case people want to reproduce this, my branch is here:

https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git/log/?h=lto

Quoted 30 lines

----------------------------------------------------------------------------------

make -C tools/bpf/
make: Entering directory '/usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/tools/bpf'

Auto-detecting system features:
... libbfd: [ on ]
... disassembler-four-args: [ OFF ]

CC bpf_jit_disasm.o
CC bpf_dbg.o
In file included from /usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/include/uapi/linux/filter.h:9:0, from /usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/tools/bpf/bpf_dbg.c:41:
/usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/include/linux/compiler.h:247:24:
fatal error: asm/rwonce.h: No such file or directory
#include <asm/rwonce.h>
^
compilation terminated.
Makefile:61: recipe for target 'bpf_dbg.o' failed
make: *** [bpf_dbg.o] Error 1
make: *** Waiting for unfinished jobs....
make: Leaving directory

----------------------------------------------------------------------------------

[1] https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git/commit/?h=lto&id=642a312d47ceb54603630d9d04f5052f3b46d9a3

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

It seems that include/linux/compiler.h cannot find the asm/rwonce.h because tools/bpf/Makefile doesn't include arch/*/include/generated/asm/rwonce.h.

The problem with referring to the generated files is that they don't exist unless you've configured the main source directory. The real problem here seems to be that tools/bpf/ refers directly to header files in the kernel sources without any understanding of kbuild, and therefore mandatory-y headers simply don't exist when it goes looking for them.

Hmm, I am puzzled why that is. :/ I think there are two options, i) remove it from CFLAGS like below (at least this doesn't let the build fail in my case but requires linux headers to be installed) or ii) add a copy of filter.h to tools/include/uapi/linux/filter.h so the few tools can just reuse it. We do have bpf_common.h and bpf.h there already.

tools/bpf/Makefile +0 -0
index 5d1995fd369c..08dfd289174c 100644

tools/bpf/Makefile MAKE = make · line 15

Quoted 7 lines
tools/bpf/Makefile +0 -1
@@ -10,7 +10,6 @@ MAKE = make
  INSTALL ?= install
 
  CFLAGS += -Wall -O2
-CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/include/uapi -I$(srctree)/include
 
  # This will work when bpf is built in tools env. where srctree
  # isn't set and when invoked from selftests build, where srctree

I think this is the most sane fix
to include the linux/filter.h in the system.

(probably, it is located in /usr/include/linux/filter.h)

Signature · 2 lines
Best Regards
Masahiro Yamada
author
#6 lore raw
Quoted 65 lines · Masahiro Yamada
Quoted 64 lines · Daniel Borkmann
Quoted 40 lines · Masahiro Yamada
Quoted 39 lines · Will Deacon

[+lkml, Masahiro, Alexei and Daniel]

Quoted 2 lines · Xiao Yang

With your patch[1], I alway get the following error when building tools/bpf:

In case people want to reproduce this, my branch is here:

https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git/log/?h=lto

Quoted 30 lines

----------------------------------------------------------------------------------

make -C tools/bpf/
make: Entering directory '/usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/tools/bpf'

Auto-detecting system features:
... libbfd: [ on ]
... disassembler-four-args: [ OFF ]

CC bpf_jit_disasm.o
CC bpf_dbg.o
In file included from /usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/include/uapi/linux/filter.h:9:0, from /usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/tools/bpf/bpf_dbg.c:41:
/usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/include/linux/compiler.h:247:24:
fatal error: asm/rwonce.h: No such file or directory
#include <asm/rwonce.h>
^
compilation terminated.
Makefile:61: recipe for target 'bpf_dbg.o' failed
make: *** [bpf_dbg.o] Error 1
make: *** Waiting for unfinished jobs....
make: Leaving directory

----------------------------------------------------------------------------------

[1] https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git/commit/?h=lto&id=642a312d47ceb54603630d9d04f5052f3b46d9a3

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

It seems that include/linux/compiler.h cannot find the asm/rwonce.h because tools/bpf/Makefile doesn't include arch/*/include/generated/asm/rwonce.h.

The problem with referring to the generated files is that they don't exist unless you've configured the main source directory. The real problem here seems to be that tools/bpf/ refers directly to header files in the kernel sources without any understanding of kbuild, and therefore mandatory-y headers simply don't exist when it goes looking for them.

Hmm, I am puzzled why that is. :/ I think there are two options, i) remove it from CFLAGS like below (at least this doesn't let the build fail in my case but requires linux headers to be installed) or ii) add a copy of filter.h to tools/include/uapi/linux/filter.h so the few tools can just reuse it. We do have bpf_common.h and bpf.h there already.

tools/bpf/Makefile +0 -1
index 5d1995fd369c..08dfd289174c 100644
@@ -10,7 +10,6 @@ MAKE = make
   INSTALL ?= install
 
   CFLAGS += -Wall -O2
-CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/include/uapi -I$(srctree)/include
 
Quoted 8 lines

tools/bpf/Makefile MAKE = make · line 15

Quoted 3 lines
tools/bpf/Makefile +0 -0
   # This will work when bpf is built in tools env. where srctree
   # isn't set and when invoked from selftests build, where srctree

I think this is the most sane fix
to include the linux/filter.h in the system.

(probably, it is located in /usr/include/linux/filter.h)

Hi Masahiro,

Is it correct for include/linux/compiler.h to include <asm/rwonce.h>?

On x86_64 arch, asm/rwonce.h is generated in ./arch/x86/include/generated/ directory and compiler.h cannot find it.

Best Regards,

XIao Yang

Quoted 2 lines
#7 lore raw
Quoted 74 lines · Xiao Yang
Quoted 72 lines · Masahiro Yamada
Quoted 60 lines · Daniel Borkmann
Quoted 40 lines · Masahiro Yamada
Quoted 39 lines · Will Deacon

[+lkml, Masahiro, Alexei and Daniel]

Quoted 2 lines · Xiao Yang

With your patch[1], I alway get the following error when building tools/bpf:

In case people want to reproduce this, my branch is here:

https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git/log/?h=lto

Quoted 30 lines

----------------------------------------------------------------------------------

make -C tools/bpf/
make: Entering directory '/usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/tools/bpf'

Auto-detecting system features:
... libbfd: [ on ]
... disassembler-four-args: [ OFF ]

CC bpf_jit_disasm.o
CC bpf_dbg.o
In file included from /usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/include/uapi/linux/filter.h:9:0, from /usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/tools/bpf/bpf_dbg.c:41:
/usr/src/perf_selftests-x86_64-rhel-7.6-642a312d47ceb54603630d9d04f5052f3b46d9a3/include/linux/compiler.h:247:24:
fatal error: asm/rwonce.h: No such file or directory
#include <asm/rwonce.h>
^
compilation terminated.
Makefile:61: recipe for target 'bpf_dbg.o' failed
make: *** [bpf_dbg.o] Error 1
make: *** Waiting for unfinished jobs....
make: Leaving directory

----------------------------------------------------------------------------------

[1] https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git/commit/?h=lto&id=642a312d47ceb54603630d9d04f5052f3b46d9a3

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

It seems that include/linux/compiler.h cannot find the asm/rwonce.h because tools/bpf/Makefile doesn't include arch/*/include/generated/asm/rwonce.h.

The problem with referring to the generated files is that they don't exist unless you've configured the main source directory. The real problem here seems to be that tools/bpf/ refers directly to header files in the kernel sources without any understanding of kbuild, and therefore mandatory-y headers simply don't exist when it goes looking for them.

Hmm, I am puzzled why that is. :/ I think there are two options, i) remove it from CFLAGS like below (at least this doesn't let the build fail in my case but requires linux headers to be installed) or ii) add a copy of filter.h to tools/include/uapi/linux/filter.h so the few tools can just reuse it. We do have bpf_common.h and bpf.h there already.

tools/bpf/Makefile +0 -0
index 5d1995fd369c..08dfd289174c 100644

tools/bpf/Makefile MAKE = make · line 15

Quoted 7 lines
tools/bpf/Makefile +0 -1
@@ -10,7 +10,6 @@ MAKE = make
   INSTALL ?= install
 
   CFLAGS += -Wall -O2
-CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/include/uapi -I$(srctree)/include
 
   # This will work when bpf is built in tools env. where srctree
   # isn't set and when invoked from selftests build, where srctree

I think this is the most sane fix
to include the linux/filter.h in the system.

Quoted 5 lines
Quoted 1 line

(probably, it is located in /usr/include/linux/filter.h)

Hi Masahiro,

Is it correct for include/linux/compiler.h to include <asm/rwonce.h>?

Sorry, I really do not understand what you are doing.

include/linux/compiler.h is only for kernel-space. Shrug if a user-land program includes it.

Quoted 10 lines

On x86_64 arch, asm/rwonce.h is generated in ./arch/x86/include/generated/ directory and compiler.h cannot find it.

Best Regards,

XIao Yang

Quoted 2 lines
Signature · 2 lines
Best Regards
Masahiro Yamada
author
#8 lore raw
Quoted 4 lines · Masahiro Yamada

Sorry, I really do not understand what you are doing.

include/linux/compiler.h is only for kernel-space. Shrug if a user-land program includes it.

Hi Masahiro,

For building tools/bpf, it is good to fix the compiler error by Daniel's patch(i.e. use linux/filter from linux header).

linux/compiler.h may be used by other code in kernel.  Is it possible to trigger the same error when the other code

including linux/compiler.h is built? Is this kind of code able to find the location of <asm/rwonce.h>?

Best Regards,

Xiao Yang

#9 lore raw
Quoted 9 lines · Xiao Yang
Quoted 4 lines · Masahiro Yamada

Sorry, I really do not understand what you are doing.

include/linux/compiler.h is only for kernel-space. Shrug if a user-land program includes it.

Hi Masahiro,

Quoted 8 lines

For building tools/bpf, it is good to fix the compiler error by Daniel's patch(i.e. use linux/filter from linux header).

linux/compiler.h may be used by other code in kernel. Is it possible to trigger the same error when the other code

including linux/compiler.h is built? Is this kind of code able to find the location of <asm/rwonce.h>?

<asm/rwonce.h> is also kernel-only header.

The kernel code can find <asm/rwonce.h>, but user-land code cannot.

Quoted 5 lines

Best Regards,

Xiao Yang

Signature · 2 lines
Best Regards
Masahiro Yamada
author
#10 lore raw
Quoted 14 lines · Masahiro Yamada
Quoted 13 lines · Xiao Yang
Quoted 4 lines · Masahiro Yamada

Sorry, I really do not understand what you are doing.

include/linux/compiler.h is only for kernel-space. Shrug if a user-land program includes it.

Hi Masahiro,

For building tools/bpf, it is good to fix the compiler error by Daniel's patch(i.e. use linux/filter from linux header).

linux/compiler.h may be used by other code in kernel. Is it possible to trigger the same error when the other code

Quoted 6 lines
Quoted 2 lines

including linux/compiler.h is built? Is this kind of code able to find the location of <asm/rwonce.h>?

<asm/rwonce.h> is also kernel-only header.

The kernel code can find <asm/rwonce.h>, but user-land code cannot.

Hi Masahiro,

Sorry, I am not familar with it.

Thanks a lot for your explanation and I have seen the LINUXINCLUDE variable in Makefile.

I will try to send a patch as Daniel suggested.

Best Regards,

Xiao Yang

Quoted 10 lines
Quoted 9 lines

Best Regards,

Xiao Yang

Acked-by Daniel Borkmann
#11 lore raw
Quoted 27 lines · Xiao Yang
Quoted 14 lines · Masahiro Yamada
Quoted 13 lines · Xiao Yang
Quoted 4 lines · Masahiro Yamada

Sorry, I really do not understand what you are doing.

include/linux/compiler.h is only for kernel-space. Shrug if a user-land program includes it.

Hi Masahiro,

For building tools/bpf, it is good to fix the compiler error by Daniel's patch(i.e. use linux/filter from linux header).

linux/compiler.h may be used by other code in kernel. Is it possible to trigger the same error when the other code

Quoted 6 lines
Quoted 2 lines

including linux/compiler.h is built? Is this kind of code able to find the location of <asm/rwonce.h>?

<asm/rwonce.h> is also kernel-only header.

The kernel code can find <asm/rwonce.h>, but user-land code cannot.

Hi Masahiro,

Sorry, I am not familar with it.

Quoted 9 lines

Thanks a lot for your explanation and I have seen the LINUXINCLUDE variable in Makefile.

I will try to send a patch as Daniel suggested.

Best Regards,

Xiao Yang

Hmm, digging into the git history,
this include path was added by the following commit:

commit d7475de58575c904818efa369c82e88c6648ce2e

Author: Kamal Mostafa <[email protected]>
Date:   Wed Nov 11 14:24:27 2015 -0800

tools/net: Use include/uapi with __EXPORTED_HEADERS__

Use the local uapi headers to keep in sync with "recently" added #define's (e.g. SKF_AD_VLAN_TPID). Refactored CFLAGS, and bpf_asm doesn't need -I.

Fixes 3f356385e8a4 ("filter: bpf_asm: add minimal bpf asm tool")

I am not sure how big a deal it is,
but it could be a problem on old distros??

Signature · 2 lines
Best Regards
Masahiro Yamada
author
#12 lore raw
Quoted 54 lines · Masahiro Yamada
Quoted 24 lines · Xiao Yang
Quoted 11 lines · Masahiro Yamada
Quoted 10 lines · Xiao Yang
Quoted 4 lines · Masahiro Yamada

Sorry, I really do not understand what you are doing.

include/linux/compiler.h is only for kernel-space. Shrug if a user-land program includes it.

Hi Masahiro,

For building tools/bpf, it is good to fix the compiler error by Daniel's patch(i.e. use linux/filter from linux header).

Quoted 8 lines
Quoted 5 lines

linux/compiler.h may be used by other code in kernel. Is it possible to trigger the same error when the other code

including linux/compiler.h is built? Is this kind of code able to find the location of <asm/rwonce.h>?

<asm/rwonce.h> is also kernel-only header.

The kernel code can find <asm/rwonce.h>, but user-land code cannot.

Hi Masahiro,

Sorry, I am not familar with it.

Quoted 9 lines

Thanks a lot for your explanation and I have seen the LINUXINCLUDE variable in Makefile.

I will try to send a patch as Daniel suggested.

Best Regards,

Xiao Yang

Hmm, digging into the git history,
this include path was added by the following commit:

commit d7475de58575c904818efa369c82e88c6648ce2e

Author: Kamal Mostafa <[email protected]>
Date:   Wed Nov 11 14:24:27 2015 -0800

tools/net: Use include/uapi with __EXPORTED_HEADERS__

Use the local uapi headers to keep in sync with "recently" added #define's (e.g. SKF_AD_VLAN_TPID). Refactored CFLAGS, and bpf_asm doesn't need -I.

Fixes 3f356385e8a4 ("filter: bpf_asm: add minimal bpf asm tool")
Quoted 3 lines

I am not sure how big a deal it is,
but it could be a problem on old distros??

Hi Daniel, Masahiro

Could we include the linux/filter.h generated by "make headers_install" as a higher priority?

(PS: According to above commit, just ensure that tools/bpf keeps in sync with new linux header as far as possible).

and then use the linux/filter.h in system if kernel doesn't provide linux/filter.h by "make headers_install".

--------------------------------------------------------------------------------------------------------------------

tools/bpf/Makefile +0 -0
index 5d1995fd369c..1e0c768132af 100644
@@ -10,7 +10,7 @@ MAKE = make

 INSTALL ?= install

 CFLAGS += -Wall -O2
-CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/include/uapi -I$(srctree)/include +CFLAGS += -I$(srctree)/usr/include

 # This will work when bpf is built in tools env. where srctree # isn't set and when invoked from selftests build, where srctree

---------------------------------------------------------------------------------------------------------------------

Best Regards,

Xiao Yang

Quoted 1 line
#13 lore raw
Quoted 78 lines · Xiao Yang
Quoted 54 lines · Masahiro Yamada
Quoted 24 lines · Xiao Yang
Quoted 11 lines · Masahiro Yamada
Quoted 10 lines · Xiao Yang
Quoted 4 lines · Masahiro Yamada

Sorry, I really do not understand what you are doing.

include/linux/compiler.h is only for kernel-space. Shrug if a user-land program includes it.

Hi Masahiro,

For building tools/bpf, it is good to fix the compiler error by Daniel's patch(i.e. use linux/filter from linux header).

Quoted 8 lines
Quoted 5 lines

linux/compiler.h may be used by other code in kernel. Is it possible to trigger the same error when the other code

including linux/compiler.h is built? Is this kind of code able to find the location of <asm/rwonce.h>?

<asm/rwonce.h> is also kernel-only header.

The kernel code can find <asm/rwonce.h>, but user-land code cannot.

Hi Masahiro,

Sorry, I am not familar with it.

Quoted 9 lines

Thanks a lot for your explanation and I have seen the LINUXINCLUDE variable in Makefile.

I will try to send a patch as Daniel suggested.

Best Regards,

Xiao Yang

Hmm, digging into the git history,
this include path was added by the following commit:

commit d7475de58575c904818efa369c82e88c6648ce2e

Author: Kamal Mostafa <[email protected]>
Date:   Wed Nov 11 14:24:27 2015 -0800

tools/net: Use include/uapi with __EXPORTED_HEADERS__

Use the local uapi headers to keep in sync with "recently" added #define's (e.g. SKF_AD_VLAN_TPID). Refactored CFLAGS, and bpf_asm doesn't need -I.

Fixes 3f356385e8a4 ("filter: bpf_asm: add minimal bpf asm tool")
Quoted 3 lines

I am not sure how big a deal it is,
but it could be a problem on old distros??

Hi Daniel, Masahiro

Could we include the linux/filter.h generated by "make headers_install" as a higher priority?

(PS: According to above commit, just ensure that tools/bpf keeps in sync with new linux header as far as possible).

and then use the linux/filter.h in system if kernel doesn't provide linux/filter.h by "make headers_install".

--------------------------------------------------------------------------------------------------------------------

tools/bpf/Makefile +0 -0
index 5d1995fd369c..1e0c768132af 100644

tools/bpf/Makefile MAKE = make · line 13

Quoted 6 lines
tools/bpf/Makefile +1 -2
@@ -10,7 +10,7 @@ MAKE = make
  INSTALL ?= install
 
  CFLAGS += -Wall -O2
-CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/include/uapi
-I$(srctree)/include
+CFLAGS += -I$(srctree)/usr/include

Probably, this does not work for O= build.

And, you also need to run 'make headers' somewhere because usr/include does not contain any header in a clean state.

Be careful, people always tend to break out-of-tree build. I recommend to double, triple check it.

(I believe this is a horrible design mistake
of the tools build system.)

Quoted 12 lines
tools/bpf/Makefile +0 -1
  # This will work when bpf is built in tools env. where srctree
  # isn't set and when invoked from selftests build, where srctree
 
---------------------------------------------------------------------------------------------------------------------

Best Regards,

Xiao Yang

Quoted 1 line
Signature · 2 lines
Best Regards
Masahiro Yamada