Re: [PATCH v2] tools include: define READ_ONCE/WRITE_ONCE for C++
From: Sandipan Das
Date: Wed Apr 04 2018 - 02:16:51 EST
Hi,
On 11/30/2017 07:06 AM, Li Zhijian wrote:
> since 6aa7de0, we failed to build perf with C++(clang)
> to fix the following compile errors
> --------------
> lizhijian@haswell-OptiPlex-9020:~/lkp/linux/tools/perf$ make LLVM_CONFIG=/usr/bin/llvm-config-3.9 LIBCLANGLLVM=1
> ...
> CC util/probe-finder.o
> In file included from /home/lizj/linux/tools/perf/util/util.h:13:0,
> from /home/lizj/linux/tools/perf/util/util-cxx.h:20,
> from util/c++/clang-c.h:5,
> from util/c++/clang-test.cpp:2:
> /home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h: In function âint atomic_read(const atomic_t*)â:
> /home/lizj/linux/tools/include/linux/compiler.h:157:45: error: use of deleted function âatomic_read(const atomic_t*)::<anonymous union>::<constructor>()â
> ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), __u.__c, sizeof(x)); __u.__val; })
> ^
> /home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: note: in expansion of macro âREAD_ONCEâ
> return READ_ONCE((v)->counter);
> ^
> /home/lizj/linux/tools/include/linux/compiler.h:157:11: note: âatomic_read(const atomic_t*)::<anonymous union>::<constructor>()â is implicitly deleted because the default definition would be ill-formed:
> ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), __u.__c, sizeof(x)); __u.__val; })
> ^
> /home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: note: in expansion of macro âREAD_ONCEâ
> return READ_ONCE((v)->counter);
> ^
> /home/lizj/linux/tools/include/linux/compiler.h:157:11: error: uninitialized const member in âunion atomic_read(const atomic_t*)::<anonymous>â
> ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), __u.__c, sizeof(x)); __u.__val; })
> ^
> /home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: note: in expansion of macro âREAD_ONCEâ
> return READ_ONCE((v)->counter);
> ^
> /home/lizj/linux/tools/include/linux/compiler.h:157:23: note: âconst int atomic_read(const atomic_t*)::<anonymous union>::__valâ should be initialized
> ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), __u.__c, sizeof(x)); __u.__val; })
> ^
> /home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: note: in expansion of macro âREAD_ONCEâ
> return READ_ONCE((v)->counter);
> ^
> LD tests/perf-in.o
> ...
> --------------
>
I ran into the same problems while building perf with clang support.
If the solution proposed here is acceptable, can someone please pick
up this patch?
--
With Regards,
Sandipan