diff mbox series

[2/2] compiler.h: Include asm/rwonce.h under ARM64 and ALPHA to fix build errors

Message ID 1610535453-2352-3-git-send-email-yangtiezhu@loongson.cn (mailing list archive)
State Not Applicable, archived
Headers show
Series Fix build errors and warnings when make M=samples/bpf | expand

Commit Message

Tiezhu Yang Jan. 13, 2021, 10:57 a.m. UTC
When make M=samples/bpf on the Loongson 3A3000 platform which
belongs to MIPS arch, there exists many similar build errors
about 'asm/rwonce.h' file not found, so include it only under
CONFIG_ARM64 and CONFIG_ALPHA due to it exists only in arm64
and alpha arch.

  CLANG-bpf  samples/bpf/xdpsock_kern.o
In file included from samples/bpf/xdpsock_kern.c:2:
In file included from ./include/linux/bpf.h:9:
In file included from ./include/linux/workqueue.h:9:
In file included from ./include/linux/timer.h:5:
In file included from ./include/linux/list.h:9:
In file included from ./include/linux/kernel.h:10:
./include/linux/compiler.h:246:10: fatal error: 'asm/rwonce.h' file not found
         ^~~~~~~~~~~~~~
1 error generated.

$ find . -name rwonce.h
./include/asm-generic/rwonce.h
./arch/arm64/include/asm/rwonce.h
./arch/alpha/include/asm/rwonce.h

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 include/linux/compiler.h | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Yonghong Song Jan. 13, 2021, 5:14 p.m. UTC | #1
On 1/13/21 2:57 AM, Tiezhu Yang wrote:
> When make M=samples/bpf on the Loongson 3A3000 platform which
> belongs to MIPS arch, there exists many similar build errors
> about 'asm/rwonce.h' file not found, so include it only under
> CONFIG_ARM64 and CONFIG_ALPHA due to it exists only in arm64
> and alpha arch.
> 
>    CLANG-bpf  samples/bpf/xdpsock_kern.o
> In file included from samples/bpf/xdpsock_kern.c:2:
> In file included from ./include/linux/bpf.h:9:
> In file included from ./include/linux/workqueue.h:9:
> In file included from ./include/linux/timer.h:5:
> In file included from ./include/linux/list.h:9:
> In file included from ./include/linux/kernel.h:10:
> ./include/linux/compiler.h:246:10: fatal error: 'asm/rwonce.h' file not found
>           ^~~~~~~~~~~~~~
> 1 error generated.
> 
> $ find . -name rwonce.h
> ./include/asm-generic/rwonce.h
> ./arch/arm64/include/asm/rwonce.h
> ./arch/alpha/include/asm/rwonce.h
> 
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
>   include/linux/compiler.h | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/include/linux/compiler.h b/include/linux/compiler.h
> index b8fe0c2..bdbe759 100644
> --- a/include/linux/compiler.h
> +++ b/include/linux/compiler.h
> @@ -243,6 +243,12 @@ static inline void *offset_to_ptr(const int *off)
>    */
>   #define prevent_tail_call_optimization()	mb()
>   
> +#ifdef CONFIG_ARM64
>   #include <asm/rwonce.h>
> +#endif
> +
> +#ifdef CONFIG_ALPHA
> +#include <asm/rwonce.h>
> +#endif

I do not think this fix is correct. x86 does not define its own
rwonce.h and still compiles fine.

As noted in the above, we have include/asm-generic/rwonce.h.
Once you do a proper build, you will have rwonce.h in arch
generated directory like

-bash-4.4$ find . -name rwonce.h
./include/asm-generic/rwonce.h
./arch/alpha/include/asm/rwonce.h
./arch/arm64/include/asm/rwonce.h
./arch/x86/include/generated/asm/rwonce.h

for mips, it should generated in 
arch/mips/include/generated/asm/rwonce.h. Please double check why this 
does not happen.

>   
>   #endif /* __LINUX_COMPILER_H */
>
Sergey Shtylyov Jan. 14, 2021, 8:40 a.m. UTC | #2
Hello!

On 13.01.2021 13:57, Tiezhu Yang wrote:

> When make M=samples/bpf on the Loongson 3A3000 platform which
> belongs to MIPS arch, there exists many similar build errors
> about 'asm/rwonce.h' file not found, so include it only under
> CONFIG_ARM64 and CONFIG_ALPHA due to it exists only in arm64
> and alpha arch.
> 
>    CLANG-bpf  samples/bpf/xdpsock_kern.o
> In file included from samples/bpf/xdpsock_kern.c:2:
> In file included from ./include/linux/bpf.h:9:
> In file included from ./include/linux/workqueue.h:9:
> In file included from ./include/linux/timer.h:5:
> In file included from ./include/linux/list.h:9:
> In file included from ./include/linux/kernel.h:10:
> ./include/linux/compiler.h:246:10: fatal error: 'asm/rwonce.h' file not found
>           ^~~~~~~~~~~~~~
> 1 error generated.
> 
> $ find . -name rwonce.h
> ./include/asm-generic/rwonce.h
> ./arch/arm64/include/asm/rwonce.h
> ./arch/alpha/include/asm/rwonce.h
> 
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
>   include/linux/compiler.h | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/include/linux/compiler.h b/include/linux/compiler.h
> index b8fe0c2..bdbe759 100644
> --- a/include/linux/compiler.h
> +++ b/include/linux/compiler.h
> @@ -243,6 +243,12 @@ static inline void *offset_to_ptr(const int *off)
>    */
>   #define prevent_tail_call_optimization()	mb()
>   
> +#ifdef CONFIG_ARM64

    Why not #if defined(CONFIG_ALPHA) || defined(CONFIG_ARM64)?

>   #include <asm/rwonce.h>
> +#endif
> +
> +#ifdef CONFIG_ALPHA
> +#include <asm/rwonce.h>
> +#endif
>   
>   #endif /* __LINUX_COMPILER_H */
> 

MBR, Sergei
Tiezhu Yang Jan. 18, 2021, 9:25 a.m. UTC | #3
On 01/14/2021 01:14 AM, Yonghong Song wrote:
> I do not think this fix is correct. x86 does not define its own
> rwonce.h and still compiles fine.
>
> As noted in the above, we have include/asm-generic/rwonce.h.
> Once you do a proper build, you will have rwonce.h in arch
> generated directory like
>
> -bash-4.4$ find . -name rwonce.h
> ./include/asm-generic/rwonce.h
> ./arch/alpha/include/asm/rwonce.h
> ./arch/arm64/include/asm/rwonce.h
> ./arch/x86/include/generated/asm/rwonce.h
>
> for mips, it should generated in 
> arch/mips/include/generated/asm/rwonce.h. Please double check why this 
> does not happen.

Hi Yonghong,

Thank you very much for your reply.
You are right, this patch is meaningless.

I find this build error when make M=samples/bpf after make clean,
so the ./arch/mips/include/generated/asm/rwonce.h is not exist.

After rebuild the kernel, this header file can be found when make
M=samples/bpf due to samples/bpf/Makefile contains $LINUXINCLUDE.

$ find . -name rwonce.h
./include/asm-generic/rwonce.h
./arch/arm64/include/asm/rwonce.h
./arch/mips/include/generated/asm/rwonce.h
./arch/alpha/include/asm/rwonce.h
$ cat ./arch/mips/include/generated/asm/rwonce.h
#include <asm-generic/rwonce.h>


Hi Sergei and kernel test robot,

Thank you for your suggestion and report,
please ignore this patch, sorry for the noise.

Thanks,
Tiezhu
diff mbox series

Patch

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index b8fe0c2..bdbe759 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -243,6 +243,12 @@  static inline void *offset_to_ptr(const int *off)
  */
 #define prevent_tail_call_optimization()	mb()
 
+#ifdef CONFIG_ARM64
 #include <asm/rwonce.h>
+#endif
+
+#ifdef CONFIG_ALPHA
+#include <asm/rwonce.h>
+#endif
 
 #endif /* __LINUX_COMPILER_H */