* Re: [PATCH] compiler.h: Fix barrier_data() on clang [not found] <20201014212631.207844-1-nivedita@alum.mit.edu> @ 2020-11-16 17:47 ` Andreas Schwab 2020-11-16 17:53 ` Randy Dunlap 2020-11-16 19:31 ` Nick Desaulniers 0 siblings, 2 replies; 7+ messages in thread From: Andreas Schwab @ 2020-11-16 17:47 UTC (permalink / raw) To: Arvind Sankar Cc: clang-built-linux, Nathan Chancellor, Nick Desaulniers, linux-kernel, linux-riscv On Okt 14 2020, Arvind Sankar wrote: > Commit > 815f0ddb346c ("include/linux/compiler*.h: make compiler-*.h mutually exclusive") > > neglected to copy barrier_data() from compiler-gcc.h into > compiler-clang.h. The definition in compiler-gcc.h was really to work > around clang's more aggressive optimization, so this broke > barrier_data() on clang, and consequently memzero_explicit() as well. > > For example, this results in at least the memzero_explicit() call in > lib/crypto/sha256.c:sha256_transform() being optimized away by clang. > > Fix this by moving the definition of barrier_data() into compiler.h. > > Also move the gcc/clang definition of barrier() into compiler.h, > __memory_barrier() is icc-specific (and barrier() is already defined > using it in compiler-intel.h) and doesn't belong in compiler.h. > > Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu> > Fixes: 815f0ddb346c ("include/linux/compiler*.h: make compiler-*.h mutually exclusive") This breaks build on riscv: CC [M] drivers/net/ethernet/emulex/benet/be_main.o In file included from ./include/vdso/processor.h:10, from ./arch/riscv/include/asm/processor.h:11, from ./include/linux/prefetch.h:15, from drivers/net/ethernet/emulex/benet/be_main.c:14: ./arch/riscv/include/asm/vdso/processor.h: In function 'cpu_relax': ./arch/riscv/include/asm/vdso/processor.h:14:2: error: implicit declaration of function 'barrier' [-Werror=implicit-function-declaration] 14 | barrier(); | ^~~~~~~ cc1: some warnings being treated as errors make[5]: *** [scripts/Makefile.build:283: drivers/net/ethernet/emulex/benet/be_main.o] Error 1 make[4]: *** [scripts/Makefile.build:500: drivers/net/ethernet/emulex/benet] Error 2 make[3]: *** [scripts/Makefile.build:500: drivers/net/ethernet/emulex] Error 2 make[2]: *** [scripts/Makefile.build:500: drivers/net/ethernet] Error 2 make[1]: *** [scripts/Makefile.build:500: drivers/net] Error 2 make: *** [Makefile:1799: drivers] Error 2 Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different." _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] compiler.h: Fix barrier_data() on clang 2020-11-16 17:47 ` [PATCH] compiler.h: Fix barrier_data() on clang Andreas Schwab @ 2020-11-16 17:53 ` Randy Dunlap 2020-11-16 18:30 ` Andreas Schwab 2020-11-16 19:31 ` Nick Desaulniers 1 sibling, 1 reply; 7+ messages in thread From: Randy Dunlap @ 2020-11-16 17:53 UTC (permalink / raw) To: Andreas Schwab, Arvind Sankar Cc: clang-built-linux, Nathan Chancellor, Nick Desaulniers, linux-kernel, linux-riscv On 11/16/20 9:47 AM, Andreas Schwab wrote: > On Okt 14 2020, Arvind Sankar wrote: > >> Commit >> 815f0ddb346c ("include/linux/compiler*.h: make compiler-*.h mutually exclusive") >> >> neglected to copy barrier_data() from compiler-gcc.h into >> compiler-clang.h. The definition in compiler-gcc.h was really to work >> around clang's more aggressive optimization, so this broke >> barrier_data() on clang, and consequently memzero_explicit() as well. >> >> For example, this results in at least the memzero_explicit() call in >> lib/crypto/sha256.c:sha256_transform() being optimized away by clang. >> >> Fix this by moving the definition of barrier_data() into compiler.h. >> >> Also move the gcc/clang definition of barrier() into compiler.h, >> __memory_barrier() is icc-specific (and barrier() is already defined >> using it in compiler-intel.h) and doesn't belong in compiler.h. >> >> Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu> >> Fixes: 815f0ddb346c ("include/linux/compiler*.h: make compiler-*.h mutually exclusive") > > This breaks build on riscv: > > CC [M] drivers/net/ethernet/emulex/benet/be_main.o > In file included from ./include/vdso/processor.h:10, > from ./arch/riscv/include/asm/processor.h:11, > from ./include/linux/prefetch.h:15, > from drivers/net/ethernet/emulex/benet/be_main.c:14: > ./arch/riscv/include/asm/vdso/processor.h: In function 'cpu_relax': > ./arch/riscv/include/asm/vdso/processor.h:14:2: error: implicit declaration of function 'barrier' [-Werror=implicit-function-declaration] > 14 | barrier(); > | ^~~~~~~ > cc1: some warnings being treated as errors > make[5]: *** [scripts/Makefile.build:283: drivers/net/ethernet/emulex/benet/be_main.o] Error 1 > make[4]: *** [scripts/Makefile.build:500: drivers/net/ethernet/emulex/benet] Error 2 > make[3]: *** [scripts/Makefile.build:500: drivers/net/ethernet/emulex] Error 2 > make[2]: *** [scripts/Makefile.build:500: drivers/net/ethernet] Error 2 > make[1]: *** [scripts/Makefile.build:500: drivers/net] Error 2 > make: *** [Makefile:1799: drivers] Error 2 Hi, What kernel version are you building? This should be fixed in 5.10-rc4 by commit 3347acc6fcd4ee71ad18a9ff9d9dac176b517329; specifically this portion of it: diff --git a/include/asm-generic/barrier.h b/include/asm-generic/barrier.h index 798027bb89be..640f09479bdf 100644 --- a/include/asm-generic/barrier.h +++ b/include/asm-generic/barrier.h @@ -13,6 +13,7 @@ #ifndef __ASSEMBLY__ +#include <linux/compiler.h> #include <asm/rwonce.h> #ifndef nop -- ~Randy _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] compiler.h: Fix barrier_data() on clang 2020-11-16 17:53 ` Randy Dunlap @ 2020-11-16 18:30 ` Andreas Schwab 2020-11-16 19:28 ` Randy Dunlap 0 siblings, 1 reply; 7+ messages in thread From: Andreas Schwab @ 2020-11-16 18:30 UTC (permalink / raw) To: Randy Dunlap Cc: Nick Desaulniers, linux-kernel, clang-built-linux, Arvind Sankar, Nathan Chancellor, linux-riscv On Nov 16 2020, Randy Dunlap wrote: > What kernel version are you building? 5.10-rc4 Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different." _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] compiler.h: Fix barrier_data() on clang 2020-11-16 18:30 ` Andreas Schwab @ 2020-11-16 19:28 ` Randy Dunlap 2020-11-16 22:19 ` Randy Dunlap 0 siblings, 1 reply; 7+ messages in thread From: Randy Dunlap @ 2020-11-16 19:28 UTC (permalink / raw) To: Andreas Schwab Cc: Nick Desaulniers, linux-kernel, clang-built-linux, Arvind Sankar, Nathan Chancellor, linux-riscv On 11/16/20 10:30 AM, Andreas Schwab wrote: > On Nov 16 2020, Randy Dunlap wrote: > >> What kernel version are you building? > > 5.10-rc4 > > Andreas. OK, thanks. My build machine is slow, but I have a patch that I am testing: --- From: Randy Dunlap <rdunlap@infradead.org> riscv's <vdso/processor.h> uses barrier() so it should #include <asm/barrier.h> to prevent build errors. Reported-by: Andreas Schwab <schwab@linux-m68k.org> --- arch/riscv/include/asm/vdso/processor.h | 2 ++ 1 file changed, 2 insertions(+) --- lnx-510-rc4.orig/arch/riscv/include/asm/vdso/processor.h +++ lnx-510-rc4/arch/riscv/include/asm/vdso/processor.h @@ -4,6 +4,8 @@ #ifndef __ASSEMBLY__ +#include <asm/barrier.h> + static inline void cpu_relax(void) { #ifdef __riscv_muldiv _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] compiler.h: Fix barrier_data() on clang 2020-11-16 19:28 ` Randy Dunlap @ 2020-11-16 22:19 ` Randy Dunlap 0 siblings, 0 replies; 7+ messages in thread From: Randy Dunlap @ 2020-11-16 22:19 UTC (permalink / raw) To: Andreas Schwab Cc: Nick Desaulniers, linux-kernel, clang-built-linux, Arvind Sankar, Nathan Chancellor, linux-riscv On 11/16/20 11:28 AM, Randy Dunlap wrote: > On 11/16/20 10:30 AM, Andreas Schwab wrote: >> On Nov 16 2020, Randy Dunlap wrote: >> >>> What kernel version are you building? >> >> 5.10-rc4 >> >> Andreas. > > OK, thanks. > > My build machine is slow, but I have a patch that I am testing: > > --- > From: Randy Dunlap <rdunlap@infradead.org> > > riscv's <vdso/processor.h> uses barrier() so it should > #include <asm/barrier.h> to prevent build errors. > > Reported-by: Andreas Schwab <schwab@linux-m68k.org> > --- > arch/riscv/include/asm/vdso/processor.h | 2 ++ > 1 file changed, 2 insertions(+) > > --- lnx-510-rc4.orig/arch/riscv/include/asm/vdso/processor.h > +++ lnx-510-rc4/arch/riscv/include/asm/vdso/processor.h > @@ -4,6 +4,8 @@ > > #ifndef __ASSEMBLY__ > > +#include <asm/barrier.h> > + > static inline void cpu_relax(void) > { > #ifdef __riscv_muldiv This fixes the emulex/benet/ driver build. I'm still building allmodconfig to see if there are any other issues. -- ~Randy _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] compiler.h: Fix barrier_data() on clang 2020-11-16 17:47 ` [PATCH] compiler.h: Fix barrier_data() on clang Andreas Schwab 2020-11-16 17:53 ` Randy Dunlap @ 2020-11-16 19:31 ` Nick Desaulniers 2020-11-16 21:07 ` Andreas Schwab 1 sibling, 1 reply; 7+ messages in thread From: Nick Desaulniers @ 2020-11-16 19:31 UTC (permalink / raw) To: Andreas Schwab, Palmer Dabbelt Cc: clang-built-linux, Arvind Sankar, Nathan Chancellor, linux-riscv, LKML On Mon, Nov 16, 2020 at 9:47 AM Andreas Schwab <schwab@linux-m68k.org> wrote: > > On Okt 14 2020, Arvind Sankar wrote: > > > Commit > > 815f0ddb346c ("include/linux/compiler*.h: make compiler-*.h mutually exclusive") > > > > neglected to copy barrier_data() from compiler-gcc.h into > > compiler-clang.h. The definition in compiler-gcc.h was really to work > > around clang's more aggressive optimization, so this broke > > barrier_data() on clang, and consequently memzero_explicit() as well. > > > > For example, this results in at least the memzero_explicit() call in > > lib/crypto/sha256.c:sha256_transform() being optimized away by clang. > > > > Fix this by moving the definition of barrier_data() into compiler.h. > > > > Also move the gcc/clang definition of barrier() into compiler.h, > > __memory_barrier() is icc-specific (and barrier() is already defined > > using it in compiler-intel.h) and doesn't belong in compiler.h. > > > > Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu> > > Fixes: 815f0ddb346c ("include/linux/compiler*.h: make compiler-*.h mutually exclusive") > > This breaks build on riscv: > > CC [M] drivers/net/ethernet/emulex/benet/be_main.o > In file included from ./include/vdso/processor.h:10, > from ./arch/riscv/include/asm/processor.h:11, > from ./include/linux/prefetch.h:15, > from drivers/net/ethernet/emulex/benet/be_main.c:14: > ./arch/riscv/include/asm/vdso/processor.h: In function 'cpu_relax': > ./arch/riscv/include/asm/vdso/processor.h:14:2: error: implicit declaration of function 'barrier' [-Werror=implicit-function-declaration] > 14 | barrier(); > | ^~~~~~~ > cc1: some warnings being treated as errors > make[5]: *** [scripts/Makefile.build:283: drivers/net/ethernet/emulex/benet/be_main.o] Error 1 > make[4]: *** [scripts/Makefile.build:500: drivers/net/ethernet/emulex/benet] Error 2 > make[3]: *** [scripts/Makefile.build:500: drivers/net/ethernet/emulex] Error 2 > make[2]: *** [scripts/Makefile.build:500: drivers/net/ethernet] Error 2 > make[1]: *** [scripts/Makefile.build:500: drivers/net] Error 2 > make: *** [Makefile:1799: drivers] Error 2 > > Andreas. A lot of VDSO's reset KBUILD_CFLAGS or use a new variable for their compiler flags. As such, they're missing `-include` command line flag that injects include/linux/compiler_types.h, which `#includes` numerous other headers if `__KERNEL__` is defined (`-D__KERNEL__`). So the RISCV VDSO Makefile might need to `-include $(srctree)/include/linux/compiler_types.h -D__KERNEL__`, or `#include <linux/compiler.h>"` directly in arch/riscv/include/asm/vdso/processor.h. -- Thanks, ~Nick Desaulniers _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] compiler.h: Fix barrier_data() on clang 2020-11-16 19:31 ` Nick Desaulniers @ 2020-11-16 21:07 ` Andreas Schwab 0 siblings, 0 replies; 7+ messages in thread From: Andreas Schwab @ 2020-11-16 21:07 UTC (permalink / raw) To: Nick Desaulniers Cc: Palmer Dabbelt, LKML, clang-built-linux, Arvind Sankar, Nathan Chancellor, linux-riscv On Nov 16 2020, Nick Desaulniers wrote: > A lot of VDSO's reset KBUILD_CFLAGS or use a new variable for their > compiler flags. As such, they're missing `-include` command line flag > that injects include/linux/compiler_types.h, It's not missing here. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different." _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-11-16 22:20 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20201014212631.207844-1-nivedita@alum.mit.edu>
2020-11-16 17:47 ` [PATCH] compiler.h: Fix barrier_data() on clang Andreas Schwab
2020-11-16 17:53 ` Randy Dunlap
2020-11-16 18:30 ` Andreas Schwab
2020-11-16 19:28 ` Randy Dunlap
2020-11-16 22:19 ` Randy Dunlap
2020-11-16 19:31 ` Nick Desaulniers
2020-11-16 21:07 ` Andreas Schwab
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox