arm64 tools build failure wrt smp_load_{acquire,release} expansion on gcc version 5.4.0 20160609 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9)
So I noticed the following build failure thare point to:
commit 09d62154f61316f7e97eae3f31ef8770c7e4b386
Author: Daniel Borkmann <[email protected]> Date: Fri Oct 19 15:51:02 2018 +0200
tools, perf: add and use optimized ring_buffer_{read_head, write_tail} helpers
-------------------------
50 ubuntu:16.04-x-arm64 : FAIL aarch64-linux-gnu-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
Works well with:
59 ubuntu:18.04-x-arm64 : Ok aarch64-linux-gnu-gcc (Ubuntu/Linaro 7.3.0-27ubuntu1~18.04) 7.3.0
And all the other environments I test build :-)
Peter, do you recall something simple that could fix this?
- Arnaldo
[root@seventh linux-perf-tools-build]# cat /tmp/dm.log/ubuntu\:16.04-x-arm64 ubuntu:16.04-x-arm64
Downloading http://192.168.86.4/perf/perf-4.19.0.tar.xz...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed100 1388k 100 1388k 0 0 82.9M 0 --:--:-- --:--:-- --:--:-- 90.3Me8eb3b801d8447b247f48e501e7d555384950388
Using built-in specs.
COLLECT_GCC=aarch64-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/aarch64-linux-gnu/5/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-arm64-cross/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-arm64-cross --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-arm64-cross --with-arch-directory=aarch64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libgcj --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=aarch64-linux-gnu --program-prefix=aarch64-linux-gnu- --includedir=/usr/aarch64-linux-gnu/include Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9)
make: Entering directory '/git/linux/tools/perf'
BUILD: Doing 'make -j4' parallel build HOSTCC /tmp/build/perf/fixdep.o HOSTLD /tmp/build/perf/fixdep-in.o LINK /tmp/build/perf/fixdep
sh: 1: command: Illegal option -c
Auto-detecting system features:
... dwarf: [ on ] ... dwarf_getlocations: [ on ] ... glibc: [ on ]
... gtk2: [ OFF ]
... libaudit: [ OFF ]
... libbfd: [ OFF ]
... libelf: [ on ]
... libnuma: [ OFF ]
... numa_num_possible_cpus: [ OFF ]
... libperl: [ OFF ]
... libpython: [ OFF ]
... libslang: [ OFF ]
... libcrypto: [ OFF ]
... libunwind: [ OFF ]
... libdw-dwarf-unwind: [ on ]
... zlib: [ on ]
... lzma: [ OFF ]
... get_cpuid: [ OFF ]
... bpf: [ on ]
Makefile.config:445: No sys/sdt.h found, no SDT events are defined, please install systemtap-sdt-devel or systemtap-sdt-dev Makefile.config:491: No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR Makefile.config:583: No libcrypto.h found, disables jitted code injection, please install libssl-devel or libssl-dev Makefile.config:598: slang not found, disables TUI support. Please install slang-devel, libslang-dev or libslang2-dev Makefile.config:612: GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev Makefile.config:639: Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev Makefile.config:666: No python interpreter was found: disables Python support - please install python-devel/python-dev Makefile.config:721: No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling Makefile.config:750: No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev Makefile.config:763: No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev Makefile.config:814: No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev Makefile.config:840: No alternatives command found, you need to set JDIR= to point to the root of your Java directory
GEN /tmp/build/perf/common-cmds.h
PERF_VERSION = 4.19.ge8eb3b8
<SNIP>
CC /tmp/build/perf/plugin_sched_switch.o
CC /tmp/build/perf/util/annotate.o
LD /tmp/build/perf/plugin_mac80211-in.o
CC /tmp/build/perf/plugin_function.o
LD /tmp/build/perf/plugin_kvm-in.o
CC /tmp/build/perf/plugin_xen.o
LD /tmp/build/perf/plugin_sched_switch-in.o
CC /tmp/build/perf/arch/common.o
LD /tmp/build/perf/plugin_function-in.o
LD /tmp/build/perf/plugin_xen-in.o
MKDIR /tmp/build/perf/ui/
CC /tmp/build/perf/ui/setup.o
CC /tmp/build/perf/plugin_scsi.o
In file included from /git/linux/tools/include/asm/barrier.h:8:0,
from util/../perf-sys.h:11,
from util/../perf.h:18,
from util/symbol.h:9,
from util/sort.h:12,
from util/annotate.c:14:
/git/linux/tools/include/linux/ring_buffer.h: In function 'ring_buffer_read_head':
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:56:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u; \
^
/git/linux/tools/include/linux/ring_buffer.h:58:9: note: in expansion of macro 'smp_load_acquire'
return smp_load_acquire(&base->data_head);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:56:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u; \
^
/git/linux/tools/include/linux/ring_buffer.h:58:9: note: in expansion of macro 'smp_load_acquire'
return smp_load_acquire(&base->data_head);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:56:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u; \
^
/git/linux/tools/include/linux/ring_buffer.h:58:9: note: in expansion of macro 'smp_load_acquire'
return smp_load_acquire(&base->data_head);
^
/git/linux/tools/include/linux/ring_buffer.h: In function 'ring_buffer_write_tail':
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:19:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u = \
^/git/linux/tools/include/linux/ring_buffer.h:70:2: note: in expansion of macro 'smp_store_release'
smp_store_release(&base->data_tail, tail);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:19:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u = \
^/git/linux/tools/include/linux/ring_buffer.h:70:2: note: in expansion of macro 'smp_store_release'
smp_store_release(&base->data_tail, tail);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:19:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u = \
^
/git/linux/tools/include/linux/ring_buffer.h:70:2: note: in expansion of macro 'smp_store_release'
smp_store_release(&base->data_tail, tail);
^
LD /tmp/build/perf/plugin_scsi-in.o
CC /tmp/build/perf/plugin_cfg80211.o
LD /tmp/build/perf/plugin_cfg80211-in.o
LINK /tmp/build/perf/plugin_jbd2.so
MKDIR /tmp/build/perf/arch/arm64/util/
MKDIR /tmp/build/perf/ui/
LINK /tmp/build/perf/plugin_hrtimer.so
CC /tmp/build/perf/arch/arm64/util/header.o
CC /tmp/build/perf/ui/helpline.o
LINK /tmp/build/perf/plugin_kmem.so
LINK /tmp/build/perf/plugin_kvm.so
LINK /tmp/build/perf/plugin_mac80211.so
LINK /tmp/build/perf/plugin_sched_switch.so
LINK /tmp/build/perf/plugin_function.so
MKDIR /tmp/build/perf/arch/arm64/util/
CC /tmp/build/perf/arch/arm64/util/sym-handling.o
CC /tmp/build/perf/ui/progress.o
LINK /tmp/build/perf/plugin_xen.so
LINK /tmp/build/perf/plugin_scsi.so
LINK /tmp/build/perf/plugin_cfg80211.so
MKDIR /tmp/build/perf/arch/arm64/tests/
CC /tmp/build/perf/arch/arm64/tests/regs_load.o
CC /tmp/build/perf/ui/util.o
MKDIR /tmp/build/perf/arch/arm64/tests/
CC /tmp/build/perf/arch/arm64/tests/dwarf-unwind.o
CC /tmp/build/perf/arch/arm64/util/dwarf-regs.o
CC /tmp/build/perf/ui/hist.o
CC /tmp/build/perf/arch/arm64/util/unwind-libdw.o
CC /tmp/build/perf/arch/arm64/tests/arch-tests.o
LD /tmp/build/perf/arch/arm64/tests/libperf-in.o
MKDIR /tmp/build/perf/arch/arm64/util/../../arm/util/
CC /tmp/build/perf/arch/arm64/util/../../arm/util/pmu.o
In file included from /git/linux/tools/include/asm/barrier.h:8:0,
from ui/../util/../perf-sys.h:11,
from ui/../util/../perf.h:18,
from ui/../util/callchain.h:5,
from ui/../util/hist.h:7,
from ui/hist.c:6:
/git/linux/tools/include/linux/ring_buffer.h: In function 'ring_buffer_read_head':
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:56:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u; \
^
/git/linux/tools/include/linux/ring_buffer.h:58:9: note: in expansion of macro 'smp_load_acquire'
return smp_load_acquire(&base->data_head);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:56:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u; \
^
/git/linux/tools/include/linux/ring_buffer.h:58:9: note: in expansion of macro 'smp_load_acquire'
return smp_load_acquire(&base->data_head);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:56:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u; \
^
/git/linux/tools/include/linux/ring_buffer.h:58:9: note: in expansion of macro 'smp_load_acquire'
return smp_load_acquire(&base->data_head);
^
/git/linux/tools/include/linux/ring_buffer.h: In function 'ring_buffer_write_tail':
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:19:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u = \
^/git/linux/tools/include/linux/ring_buffer.h:70:2: note: in expansion of macro 'smp_store_release'
smp_store_release(&base->data_tail, tail);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:19:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u = \
^/git/linux/tools/include/linux/ring_buffer.h:70:2: note: in expansion of macro 'smp_store_release'
smp_store_release(&base->data_tail, tail);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:19:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u = \
^
/git/linux/tools/include/linux/ring_buffer.h:70:2: note: in expansion of macro 'smp_store_release'
smp_store_release(&base->data_tail, tail);
^
MKDIR /tmp/build/perf/arch/arm64/util/../../arm/util/
CC /tmp/build/perf/arch/arm64/util/../../arm/util/auxtrace.o
CC /tmp/build/perf/arch/arm64/util/../../arm/util/cs-etm.o
In file included from /git/linux/tools/include/asm/barrier.h:8:0,
from /git/linux/tools/perf/util/include/../../util/../perf-sys.h:11,
from /git/linux/tools/perf/util/include/../../util/../perf.h:18,
from /git/linux/tools/perf/util/include/../../util/auxtrace.h:28,
from arch/arm64/util/../../arm/util/auxtrace.c:10:
/git/linux/tools/include/linux/ring_buffer.h: In function 'ring_buffer_read_head':
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:56:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u; \
^
/git/linux/tools/include/linux/ring_buffer.h:58:9: note: in expansion of macro 'smp_load_acquire'
return smp_load_acquire(&base->data_head);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:56:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u; \
^
/git/linux/tools/include/linux/ring_buffer.h:58:9: note: in expansion of macro 'smp_load_acquire'
return smp_load_acquire(&base->data_head);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:56:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u; \
^
/git/linux/tools/include/linux/ring_buffer.h:58:9: note: in expansion of macro 'smp_load_acquire'
return smp_load_acquire(&base->data_head);
^
/git/linux/tools/include/linux/ring_buffer.h: In function 'ring_buffer_write_tail':
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:19:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u = \
^/git/linux/tools/include/linux/ring_buffer.h:70:2: note: in expansion of macro 'smp_store_release'
smp_store_release(&base->data_tail, tail);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:19:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u = \
^/git/linux/tools/include/linux/ring_buffer.h:70:2: note: in expansion of macro 'smp_store_release'
smp_store_release(&base->data_tail, tail);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:19:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u = \
^/git/linux/tools/include/linux/ring_buffer.h:70:2: note: in expansion of macro 'smp_store_release'
smp_store_release(&base->data_tail, tail);
^
In file included from /git/linux/tools/include/asm/barrier.h:8:0,
from /git/linux/tools/perf/util/include/../../util/../perf-sys.h:11,
from /git/linux/tools/perf/util/include/../../util/../perf.h:18,
from /git/linux/tools/perf/util/include/../../util/symbol.h:9,
from /git/linux/tools/perf/util/include/../../util/evsel.h:11,
from arch/arm64/util/../../arm/util/cs-etm.h:10,
from arch/arm64/util/../../arm/util/cs-etm.c:15:
/git/linux/tools/include/linux/ring_buffer.h: In function 'ring_buffer_read_head':
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:56:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u; \
^
/git/linux/tools/include/linux/ring_buffer.h:58:9: note: in expansion of macro 'smp_load_acquire'
return smp_load_acquire(&base->data_head);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:56:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u; \
^
/git/linux/tools/include/linux/ring_buffer.h:58:9: note: in expansion of macro 'smp_load_acquire'
return smp_load_acquire(&base->data_head);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:56:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u; \
^
/git/linux/tools/include/linux/ring_buffer.h:58:9: note: in expansion of macro 'smp_load_acquire'
return smp_load_acquire(&base->data_head);
^
/git/linux/tools/include/linux/ring_buffer.h: In function 'ring_buffer_write_tail':
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:19:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u = \
^/git/linux/tools/include/linux/ring_buffer.h:70:2: note: in expansion of macro 'smp_store_release'
smp_store_release(&base->data_tail, tail);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:19:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u = \
^/git/linux/tools/include/linux/ring_buffer.h:70:2: note: in expansion of macro 'smp_store_release'
smp_store_release(&base->data_tail, tail);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:19:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u = \
^/git/linux/tools/include/linux/ring_buffer.h:70:2: note: in expansion of macro 'smp_store_release'
smp_store_release(&base->data_tail, tail);
^
cc1: all warnings being treated as errors
mv: cannot stat '/tmp/build/perf/arch/arm64/util/../../arm/util/.auxtrace.o.tmp': No such file or directory /git/linux/tools/build/Makefile.build:96: recipe for target '/tmp/build/perf/arch/arm64/util/../../arm/util/auxtrace.o' failed make[6]: *** [/tmp/build/perf/arch/arm64/util/../../arm/util/auxtrace.o] Error 1
make[6]: *** Waiting for unfinished jobs....
MKDIR /tmp/build/perf/scripts/ LD /tmp/build/perf/scripts/libperf-in.o CC /tmp/build/perf/trace/beauty/clone.o CC /tmp/build/perf/trace/beauty/fcntl.o CC /tmp/build/perf/trace/beauty/flock.o
cc1: all warnings being treated as errors
mv: cannot stat '/tmp/build/perf/arch/arm64/util/../../arm/util/.cs-etm.o.tmp': No such file or directory /git/linux/tools/build/Makefile.build:96: recipe for target '/tmp/build/perf/arch/arm64/util/../../arm/util/cs-etm.o' failed make[6]: *** [/tmp/build/perf/arch/arm64/util/../../arm/util/cs-etm.o] Error 1 /git/linux/tools/build/Makefile.build:139: recipe for target 'util' failed
make[5]: *** [util] Error 2
/git/linux/tools/build/Makefile.build:139: recipe for target 'arm64' failed
make[4]: *** [arm64] Error 2
/git/linux/tools/build/Makefile.build:139: recipe for target 'arch' failed
make[3]: *** [arch] Error 2
make[3]: *** Waiting for unfinished jobs....
CC /tmp/build/perf/trace/beauty/kcmp.o CC /tmp/build/perf/trace/beauty/mount_flags.o CC /tmp/build/perf/trace/beauty/pkey_alloc.o CC /tmp/build/perf/trace/beauty/prctl.o CC /tmp/build/perf/trace/beauty/sockaddr.o CC /tmp/build/perf/trace/beauty/socket.o CC /tmp/build/perf/trace/beauty/statx.o MKDIR /tmp/build/perf/ui/stdio/ CC /tmp/build/perf/ui/stdio/hist.o LD /tmp/build/perf/trace/beauty/libperf-in.o CC /tmp/build/perf/builtin-bench.o
cc1: all warnings being treated as errors
mv: cannot stat '/tmp/build/perf/util/.annotate.o.tmp': No such file or directory /git/linux/tools/build/Makefile.build:96: recipe for target '/tmp/build/perf/util/annotate.o' failed make[4]: *** [/tmp/build/perf/util/annotate.o] Error 1 /git/linux/tools/build/Makefile.build:139: recipe for target 'util' failed
make[3]: *** [util] Error 2
LINK /tmp/build/perf/pmu-events/jevents
GEN /tmp/build/perf/libtraceevent-dynamic-list
GEN /tmp/build/perf/pmu-events/pmu-events.c
CC /tmp/build/perf/pmu-events/pmu-events.o
LD /tmp/build/perf/pmu-events/pmu-events-in.o
CC /tmp/build/perf/builtin-annotate.o
CC /tmp/build/perf/builtin-config.o
In file included from /git/linux/tools/include/asm/barrier.h:8:0,
from util/../perf-sys.h:11,
from util/../perf.h:18,
from util/symbol.h:9,
from builtin-annotate.c:16:
/git/linux/tools/include/linux/ring_buffer.h: In function 'ring_buffer_read_head':
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:56:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u; \
^
/git/linux/tools/include/linux/ring_buffer.h:58:9: note: in expansion of macro 'smp_load_acquire'
return smp_load_acquire(&base->data_head);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:56:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u; \
^
/git/linux/tools/include/linux/ring_buffer.h:58:9: note: in expansion of macro 'smp_load_acquire'
return smp_load_acquire(&base->data_head);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:56:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u; \
^
/git/linux/tools/include/linux/ring_buffer.h:58:9: note: in expansion of macro 'smp_load_acquire'
return smp_load_acquire(&base->data_head);
^
/git/linux/tools/include/linux/ring_buffer.h: In function 'ring_buffer_write_tail':
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:19:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u = \
^/git/linux/tools/include/linux/ring_buffer.h:70:2: note: in expansion of macro 'smp_store_release'
smp_store_release(&base->data_tail, tail);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:19:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u = \
^/git/linux/tools/include/linux/ring_buffer.h:70:2: note: in expansion of macro 'smp_store_release'
smp_store_release(&base->data_tail, tail);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:19:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u = \
^/git/linux/tools/include/linux/ring_buffer.h:70:2: note: in expansion of macro 'smp_store_release'
smp_store_release(&base->data_tail, tail);
^
CC /tmp/build/perf/builtin-diff.o
cc1: all warnings being treated as errors
mv: cannot stat '/tmp/build/perf/ui/.hist.o.tmp': No such file or directory /git/linux/tools/build/Makefile.build:96: recipe for target '/tmp/build/perf/ui/hist.o' failed make[4]: *** [/tmp/build/perf/ui/hist.o] Error 1
make[4]: *** Waiting for unfinished jobs....
CC /tmp/build/perf/builtin-evlist.o
In file included from /git/linux/tools/include/asm/barrier.h:8:0,
from util/../perf-sys.h:11,
from util/../perf.h:18,
from util/event.h:9,
from util/debug.h:9,
from builtin-diff.c:10:
/git/linux/tools/include/linux/ring_buffer.h: In function 'ring_buffer_read_head':
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:56:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u; \
^
/git/linux/tools/include/linux/ring_buffer.h:58:9: note: in expansion of macro 'smp_load_acquire'
return smp_load_acquire(&base->data_head);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:56:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u; \
^
/git/linux/tools/include/linux/ring_buffer.h:58:9: note: in expansion of macro 'smp_load_acquire'
return smp_load_acquire(&base->data_head);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:56:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u; \
^
/git/linux/tools/include/linux/ring_buffer.h:58:9: note: in expansion of macro 'smp_load_acquire'
return smp_load_acquire(&base->data_head);
^
/git/linux/tools/include/linux/ring_buffer.h: In function 'ring_buffer_write_tail':
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:19:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u = \
^/git/linux/tools/include/linux/ring_buffer.h:70:2: note: in expansion of macro 'smp_store_release'
smp_store_release(&base->data_tail, tail);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:19:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u = \
^/git/linux/tools/include/linux/ring_buffer.h:70:2: note: in expansion of macro 'smp_store_release'
smp_store_release(&base->data_tail, tail);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:19:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u = \
^/git/linux/tools/include/linux/ring_buffer.h:70:2: note: in expansion of macro 'smp_store_release'
smp_store_release(&base->data_tail, tail);
^
In file included from /git/linux/tools/include/asm/barrier.h:8:0,
from perf-sys.h:11,
from perf.h:18,
from builtin-evlist.c:12:
/git/linux/tools/include/linux/ring_buffer.h: In function 'ring_buffer_read_head':
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:56:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u; \
^
/git/linux/tools/include/linux/ring_buffer.h:58:9: note: in expansion of macro 'smp_load_acquire'
return smp_load_acquire(&base->data_head);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:56:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u; \
^
/git/linux/tools/include/linux/ring_buffer.h:58:9: note: in expansion of macro 'smp_load_acquire'
return smp_load_acquire(&base->data_head);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:56:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u; \
^
/git/linux/tools/include/linux/ring_buffer.h:58:9: note: in expansion of macro 'smp_load_acquire'
return smp_load_acquire(&base->data_head);
^
/git/linux/tools/include/linux/ring_buffer.h: In function 'ring_buffer_write_tail':
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:19:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u = \
^/git/linux/tools/include/linux/ring_buffer.h:70:2: note: in expansion of macro 'smp_store_release'
smp_store_release(&base->data_tail, tail);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:19:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u = \
^/git/linux/tools/include/linux/ring_buffer.h:70:2: note: in expansion of macro 'smp_store_release'
smp_store_release(&base->data_tail, tail);
^
/git/linux/tools/include/asm/../../arch/arm64/include/asm/barrier.h:19:8: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
union { typeof(*p) __val; char __c[1]; } __u = \
^/git/linux/tools/include/linux/ring_buffer.h:70:2: note: in expansion of macro 'smp_store_release'
smp_store_release(&base->data_tail, tail);
^
cc1: all warnings being treated as errors
mv: cannot stat '/tmp/build/perf/.builtin-annotate.o.tmp': No such file or directory /git/linux/tools/build/Makefile.build:96: recipe for target '/tmp/build/perf/builtin-annotate.o' failed make[3]: *** [/tmp/build/perf/builtin-annotate.o] Error 1
make[3]: *** Waiting for unfinished jobs.... /git/linux/tools/build/Makefile.build:139: recipe for target 'ui' failed
make[3]: *** [ui] Error 2
Makefile.perf:650: recipe for target '/tmp/build/perf/libperf-in.o' failed
make[2]: *** [/tmp/build/perf/libperf-in.o] Error 2
make[2]: *** Waiting for unfinished jobs....
cc1: all warnings being treated as errors
mv: cannot stat '/tmp/build/perf/.builtin-evlist.o.tmp': No such file or directory /git/linux/tools/build/Makefile.build:96: recipe for target '/tmp/build/perf/builtin-evlist.o' failed make[3]: *** [/tmp/build/perf/builtin-evlist.o] Error 1
cc1: all warnings being treated as errors
mv: cannot stat '/tmp/build/perf/.builtin-diff.o.tmp': No such file or directory /git/linux/tools/build/Makefile.build:96: recipe for target '/tmp/build/perf/builtin-diff.o' failed make[3]: *** [/tmp/build/perf/builtin-diff.o] Error 1
Makefile.perf:522: recipe for target '/tmp/build/perf/perf-in.o' failed
make[2]: *** [/tmp/build/perf/perf-in.o] Error 2
Makefile.perf:206: recipe for target 'sub-make' failed
make[1]: *** [sub-make] Error 2
Makefile:69: recipe for target 'all' failed
make: *** [all] Error 2
make: Leaving directory '/git/linux/tools/perf'
[root@seventh linux-perf-tools-build]#
Hi Arnaldo,
Quoted 10 lines · Arnaldo Carvalho de Melo
So I noticed the following build failure thare point to:
commit
09d62154f61316f7e97eae3f31ef8770c7e4b386Author: Daniel Borkmann <[email protected]> Date: Fri Oct 19 15:51:02 2018 +0200tools, perf: add and use optimized ring_buffer_{read_head,
write_tail} helpers-------------------------
Quoted 7 lines
50 ubuntu:16.04-x-arm64 : FAIL aarch64-linux-gnu-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
Works well with:
59 ubuntu:18.04-x-arm64 : Ok aarch64-linux-gnu-gcc (Ubuntu/Linaro 7.3.0-27ubuntu1~18.04) 7.3.0
And all the other environments I test build :-)
Cheers for reporting this. I managed to reproduce the build failure with gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1).
The code in question is the arm64 versions of smp_load_acquire() and smp_store_release(). Unlike other architectures, these are not built around READ_ONCE() and WRITE_ONCE() since we have instructions we can use instead of fences. Bringing our macros up-to-date with those (i.e. tweaking the union initialisation and using the special "uXX_alias_t" types) appears to fix the issue for me.
Diff below...
Will
--->8
tools/arch/arm64/include/asm/barrier.h +67 -66
@@ -14,74 +14,75 @@#define wmb () asm volatile("dmb ishst" ::: "memory")#define rmb () asm volatile("dmb ishld" ::: "memory") -#define smp_store_release (p, v) \ -do { \ - union { typeof(*p) __val; char __c[1]; } __u = \ - { .__val = (__force typeof(*p)) (v) }; \ - \ - switch (sizeof(*p)) { \ - case 1: \ - asm volatile ("stlrb %w1, %0" \ - : "=Q" (*p) \ - : "r" (*(__u8 *)__u.__c) \ - : "memory"); \ - break; \ - case 2: \ - asm volatile ("stlrh %w1, %0" \ - : "=Q" (*p) \ - : "r" (*(__u16 *)__u.__c) \ - : "memory"); \ - break; \ - case 4: \ - asm volatile ("stlr %w1, %0" \ - : "=Q" (*p) \ - : "r" (*(__u32 *)__u.__c) \ - : "memory"); \ - break; \ - case 8: \ - asm volatile ("stlr %1, %0" \ - : "=Q" (*p) \ - : "r" (*(__u64 *)__u.__c) \ - : "memory"); \ - break; \ - default: \ -/* Only to shut up gcc ... */ \ -mb (); \ -break ; \ - } \ +#define smp_store_release (p, v) \ +do { \ + union { typeof(*p) __val; char __c[1]; } __u = \ + { .__val = (v) }; \ + \ + switch (sizeof(*p)) { \ + case 1: \ + asm volatile ("stlrb %w1, %0" \ + : "=Q" (*p) \ + : "r" (*(__u8_alias_t *)__u.__c) \ + : "memory"); \ + break; \ + case 2: \ + asm volatile ("stlrh %w1, %0" \ + : "=Q" (*p) \ + : "r" (*(__u16_alias_t *)__u.__c) \ + : "memory"); \ + break; \ + case 4: \ + asm volatile ("stlr %w1, %0" \ + : "=Q" (*p) \ + : "r" (*(__u32_alias_t *)__u.__c) \ + : "memory"); \ + break; \ + case 8: \ + asm volatile ("stlr %1, %0" \ + : "=Q" (*p) \ + : "r" (*(__u64_alias_t *)__u.__c) \ + : "memory"); \ + break; \ + default: \ +/* Only to shut up gcc ... */ \ +mb (); \ +break ; \ + } \ } while (0) -#define smp_load_acquire (p) \ -({ \ - union { typeof(*p) __val; char __c[1]; } __u; \ - \ - switch (sizeof(*p)) { \ - case 1: \ - asm volatile ("ldarb %w0, %1" \ - : "=r" (*(__u8 *)__u.__c) \ - : "Q" (*p) : "memory"); \ - break; \ - case 2: \ - asm volatile ("ldarh %w0, %1" \ - : "=r" (*(__u16 *)__u.__c) \ - : "Q" (*p) : "memory"); \ - break; \ - case 4: \ - asm volatile ("ldar %w0, %1" \ - : "=r" (*(__u32 *)__u.__c) \ - : "Q" (*p) : "memory"); \ - break; \ - case 8: \ - asm volatile ("ldar %0, %1" \ - : "=r" (*(__u64 *)__u.__c) \ - : "Q" (*p) : "memory"); \ - break; \ - default: \ -/* Only to shut up gcc ... */ \ -mb (); \ -break ; \ - } \ - __u.__val; \ +#define smp_load_acquire (p) \ +({ \ + union { typeof(*p) __val; char __c[1]; } __u = \ + { .__c = { 0 } }; \ + \ + switch (sizeof(*p)) { \ + case 1: \ + asm volatile ("ldarb %w0, %1" \ + : "=r" (*(__u8_alias_t *)__u.__c) \ + : "Q" (*p) : "memory"); \ + break; \ + case 2: \ + asm volatile ("ldarh %w0, %1" \ + : "=r" (*(__u16_alias_t *)__u.__c) \ + : "Q" (*p) : "memory"); \ + break; \ + case 4: \ + asm volatile ("ldar %w0, %1" \ + : "=r" (*(__u32_alias_t *)__u.__c) \ + : "Q" (*p) : "memory"); \ + break; \ + case 8: \ + asm volatile ("ldar %0, %1" \ + : "=r" (*(__u64_alias_t *)__u.__c) \ + : "Q" (*p) : "memory"); \ + break; \ + default: \ +/* Only to shut up gcc ... */ \ +mb (); \ +break ; \ + } \ + __u.__val; \ })#endif /* _TOOLS_LINUX_ASM_AARCH64_BARRIER_H */
Daniel Borkmann
Tested-byQuoted 20 lines · Will Deacon
Hi Arnaldo,
Quoted 17 lines · Arnaldo Carvalho de Melo
So I noticed the following build failure thare point to:
commit
09d62154f61316f7e97eae3f31ef8770c7e4b386Author: Daniel Borkmann <[email protected]> Date: Fri Oct 19 15:51:02 2018 +0200tools, perf: add and use optimized ring_buffer_{read_head,
write_tail} helpers-------------------------
50 ubuntu:16.04-x-arm64 : FAIL aarch64-linux-gnu-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
Works well with:
59 ubuntu:18.04-x-arm64 : Ok aarch64-linux-gnu-gcc (Ubuntu/Linaro 7.3.0-27ubuntu1~18.04) 7.3.0
And all the other environments I test build :-)
Urgh, sorry about that, I tested the patch with arm64 on Ubuntu 18.04 back then, but not 16.04. :(
Quoted 11 lines
Cheers for reporting this. I managed to reproduce the build failure with gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1).
The code in question is the arm64 versions of
smp_load_acquire()andsmp_store_release(). Unlike other architectures, these are not built aroundREAD_ONCE()andWRITE_ONCE()since we have instructions we can use instead of fences. Bringing our macros up-to-date with those (i.e. tweaking the union initialisation and using the special "uXX_alias_t" types) appears to fix the issue for me.Diff below...
I just gave this a spin on 16.04 and it resolves the build issue, thanks for the quick fix, Will!
Quoted 151 lines
Will
--->8
tools/arch/arm64/include/asm/barrier.h +67
-66@@ -14,74 +14,75 @@#define wmb () asm volatile("dmb ishst" ::: "memory")#define rmb () asm volatile("dmb ishld" ::: "memory") -#define smp_store_release (p, v) \ -do { \ - union { typeof(*p) __val; char __c[1]; } __u = \ - { .__val = (__force typeof(*p)) (v) }; \ - \ - switch (sizeof(*p)) { \ - case 1: \ - asm volatile ("stlrb %w1, %0" \ - : "=Q" (*p) \ - : "r" (*(__u8 *)__u.__c) \ - : "memory"); \ - break; \ - case 2: \ - asm volatile ("stlrh %w1, %0" \ - : "=Q" (*p) \ - : "r" (*(__u16 *)__u.__c) \ - : "memory"); \ - break; \ - case 4: \ - asm volatile ("stlr %w1, %0" \ - : "=Q" (*p) \ - : "r" (*(__u32 *)__u.__c) \ - : "memory"); \ - break; \ - case 8: \ - asm volatile ("stlr %1, %0" \ - : "=Q" (*p) \ - : "r" (*(__u64 *)__u.__c) \ - : "memory"); \ - break; \ - default: \ -/* Only to shut up gcc ... */ \ -mb (); \ -break ; \ - } \ +#define smp_store_release (p, v) \ +do { \ + union { typeof(*p) __val; char __c[1]; } __u = \ + { .__val = (v) }; \ + \ + switch (sizeof(*p)) { \ + case 1: \ + asm volatile ("stlrb %w1, %0" \ + : "=Q" (*p) \ + : "r" (*(__u8_alias_t *)__u.__c) \ + : "memory"); \ + break; \ + case 2: \ + asm volatile ("stlrh %w1, %0" \ + : "=Q" (*p) \ + : "r" (*(__u16_alias_t *)__u.__c) \ + : "memory"); \ + break; \ + case 4: \ + asm volatile ("stlr %w1, %0" \ + : "=Q" (*p) \ + : "r" (*(__u32_alias_t *)__u.__c) \ + : "memory"); \ + break; \ + case 8: \ + asm volatile ("stlr %1, %0" \ + : "=Q" (*p) \ + : "r" (*(__u64_alias_t *)__u.__c) \ + : "memory"); \ + break; \ + default: \ +/* Only to shut up gcc ... */ \ +mb (); \ +break ; \ + } \ } while (0) -#define smp_load_acquire (p) \ -({ \ - union { typeof(*p) __val; char __c[1]; } __u; \ - \ - switch (sizeof(*p)) { \ - case 1: \ - asm volatile ("ldarb %w0, %1" \ - : "=r" (*(__u8 *)__u.__c) \ - : "Q" (*p) : "memory"); \ - break; \ - case 2: \ - asm volatile ("ldarh %w0, %1" \ - : "=r" (*(__u16 *)__u.__c) \ - : "Q" (*p) : "memory"); \ - break; \ - case 4: \ - asm volatile ("ldar %w0, %1" \ - : "=r" (*(__u32 *)__u.__c) \ - : "Q" (*p) : "memory"); \ - break; \ - case 8: \ - asm volatile ("ldar %0, %1" \ - : "=r" (*(__u64 *)__u.__c) \ - : "Q" (*p) : "memory"); \ - break; \ - default: \ -/* Only to shut up gcc ... */ \ -mb (); \ -break ; \ - } \ - __u.__val; \ +#define smp_load_acquire (p) \ +({ \ + union { typeof(*p) __val; char __c[1]; } __u = \ + { .__c = { 0 } }; \ + \ + switch (sizeof(*p)) { \ + case 1: \ + asm volatile ("ldarb %w0, %1" \ + : "=r" (*(__u8_alias_t *)__u.__c) \ + : "Q" (*p) : "memory"); \ + break; \ + case 2: \ + asm volatile ("ldarh %w0, %1" \ + : "=r" (*(__u16_alias_t *)__u.__c) \ + : "Q" (*p) : "memory"); \ + break; \ + case 4: \ + asm volatile ("ldar %w0, %1" \ + : "=r" (*(__u32_alias_t *)__u.__c) \ + : "Q" (*p) : "memory"); \ + break; \ + case 8: \ + asm volatile ("ldar %0, %1" \ + : "=r" (*(__u64_alias_t *)__u.__c) \ + : "Q" (*p) : "memory"); \ + break; \ + default: \ +/* Only to shut up gcc ... */ \ +mb (); \ +break ; \ + } \ + __u.__val; \ })#endif /* _TOOLS_LINUX_ASM_AARCH64_BARRIER_H */
Em Wed, Oct 31, 2018 at 07:08:29PM +0100, Daniel Borkmann escreveu:
Quoted 7 lines · Will Deacon
Quoted 1 line
Diff below...
I just gave this a spin on 16.04 and it resolves the build issue, thanks for the quick fix, Will!
Tested-by Daniel Borkmann <[email protected]>
It buildz, ship it:
# time dm android-ndk:r12b-arm \ android-ndk:r15c-arm \ debian:experimental-x-arm64 \ ubuntu:14.04.4-x-linaro-arm64 \ ubuntu:16.04-x-arm \ ubuntu:16.04-x-arm64 \ ubuntu:18.04-x-arm \ ubuntu:18.04-x-arm64 1 android-ndk:r12b-arm : Ok arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease) 2 android-ndk:r15c-arm : Ok arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease) 3 debian:experimental-x-arm64 : Ok aarch64-linux-gnu-gcc (Debian 8.2.0-7) 8.2.0 4 ubuntu:14.04.4-x-linaro-arm64 : Ok aarch64-linux-gnu-gcc (Linaro GCC 5.5-2017.10) 5.5.0 5 ubuntu:16.04-x-arm : Ok arm-linux-gnueabihf-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609 6 ubuntu:16.04-x-arm64 : Ok aarch64-linux-gnu-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609 7 ubuntu:18.04-x-arm : Ok arm-linux-gnueabihf-gcc (Ubuntu/Linaro 7.3.0-27ubuntu1~18.04) 7.3.0 8 ubuntu:18.04-x-arm64 : Ok aarch64-linux-gnu-gcc (Ubuntu/Linaro 7.3.0-27ubuntu1~18.04) 7.3.0 #
So I've added it to my tree as below, can I keep it like that?
Thanks,
- Arnaldo
commit 86b21876a75c912917ade1e2b3831501eb2e9e45
Author: Will Deacon <[email protected]> Date: Wed Oct 31 17:44:08 2018 +0000
tools headers barrier: Fix arm64 tools build failure wrt smp_load_{acquire,release}
Cheers for reporting this. I managed to reproduce the build failure with gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1).
The code in question is the arm64 versions of smp_load_acquire() and smp_store_release(). Unlike other architectures, these are not built around READ_ONCE() and WRITE_ONCE() since we have instructions we can use instead of fences. Bringing our macros up-to-date with those (i.e. tweaking the union initialisation and using the special "uXX_alias_t" types) appears to fix the issue for me.
tools/arch/arm64/include/asm/barrier.h +67 -66
@@ -14,74 +14,75 @@#define wmb () asm volatile("dmb ishst" ::: "memory")#define rmb () asm volatile("dmb ishld" ::: "memory") -#define smp_store_release (p, v) \ -do { \ - union { typeof(*p) __val; char __c[1]; } __u = \ - { .__val = (__force typeof(*p)) (v) }; \ - \ - switch (sizeof(*p)) { \ - case 1: \ - asm volatile ("stlrb %w1, %0" \ - : "=Q" (*p) \ - : "r" (*(__u8 *)__u.__c) \ - : "memory"); \ - break; \ - case 2: \ - asm volatile ("stlrh %w1, %0" \ - : "=Q" (*p) \ - : "r" (*(__u16 *)__u.__c) \ - : "memory"); \ - break; \ - case 4: \ - asm volatile ("stlr %w1, %0" \ - : "=Q" (*p) \ - : "r" (*(__u32 *)__u.__c) \ - : "memory"); \ - break; \ - case 8: \ - asm volatile ("stlr %1, %0" \ - : "=Q" (*p) \ - : "r" (*(__u64 *)__u.__c) \ - : "memory"); \ - break; \ - default: \ -/* Only to shut up gcc ... */ \ -mb (); \ -break ; \ - } \ +#define smp_store_release (p, v) \ +do { \ + union { typeof(*p) __val; char __c[1]; } __u = \ + { .__val = (v) }; \ + \ + switch (sizeof(*p)) { \ + case 1: \ + asm volatile ("stlrb %w1, %0" \ + : "=Q" (*p) \ + : "r" (*(__u8_alias_t *)__u.__c) \ + : "memory"); \ + break; \ + case 2: \ + asm volatile ("stlrh %w1, %0" \ + : "=Q" (*p) \ + : "r" (*(__u16_alias_t *)__u.__c) \ + : "memory"); \ + break; \ + case 4: \ + asm volatile ("stlr %w1, %0" \ + : "=Q" (*p) \ + : "r" (*(__u32_alias_t *)__u.__c) \ + : "memory"); \ + break; \ + case 8: \ + asm volatile ("stlr %1, %0" \ + : "=Q" (*p) \ + : "r" (*(__u64_alias_t *)__u.__c) \ + : "memory"); \ + break; \ + default: \ +/* Only to shut up gcc ... */ \ +mb (); \ +break ; \ + } \ } while (0) -#define smp_load_acquire (p) \ -({ \ - union { typeof(*p) __val; char __c[1]; } __u; \ - \ - switch (sizeof(*p)) { \ - case 1: \ - asm volatile ("ldarb %w0, %1" \ - : "=r" (*(__u8 *)__u.__c) \ - : "Q" (*p) : "memory"); \ - break; \ - case 2: \ - asm volatile ("ldarh %w0, %1" \ - : "=r" (*(__u16 *)__u.__c) \ - : "Q" (*p) : "memory"); \ - break; \ - case 4: \ - asm volatile ("ldar %w0, %1" \ - : "=r" (*(__u32 *)__u.__c) \ - : "Q" (*p) : "memory"); \ - break; \ - case 8: \ - asm volatile ("ldar %0, %1" \ - : "=r" (*(__u64 *)__u.__c) \ - : "Q" (*p) : "memory"); \ - break; \ - default: \ -/* Only to shut up gcc ... */ \ -mb (); \ -break ; \ - } \ - __u.__val; \ +#define smp_load_acquire (p) \ +({ \ + union { typeof(*p) __val; char __c[1]; } __u = \ + { .__c = { 0 } }; \ + \ + switch (sizeof(*p)) { \ + case 1: \ + asm volatile ("ldarb %w0, %1" \ + : "=r" (*(__u8_alias_t *)__u.__c) \ + : "Q" (*p) : "memory"); \ + break; \ + case 2: \ + asm volatile ("ldarh %w0, %1" \ + : "=r" (*(__u16_alias_t *)__u.__c) \ + : "Q" (*p) : "memory"); \ + break; \ + case 4: \ + asm volatile ("ldar %w0, %1" \ + : "=r" (*(__u32_alias_t *)__u.__c) \ + : "Q" (*p) : "memory"); \ + break; \ + case 8: \ + asm volatile ("ldar %0, %1" \ + : "=r" (*(__u64_alias_t *)__u.__c) \ + : "Q" (*p) : "memory"); \ + break; \ + default: \ +/* Only to shut up gcc ... */ \ +mb (); \ +break ; \ + } \ + __u.__val; \ })#endif /* _TOOLS_LINUX_ASM_AARCH64_BARRIER_H */
[apologies if you get this twice -- my GPU hung (!) whilst sending my
previous response]
Quoted 29 lines · Arnaldo Carvalho de Melo
Em Wed, Oct 31, 2018 at 07:08:29PM +0100, Daniel Borkmann escreveu:
Quoted 7 lines · Will Deacon
Quoted 1 line
Diff below...
I just gave this a spin on 16.04 and it resolves the build issue, thanks for the quick fix, Will!
Tested-by Daniel Borkmann <[email protected]>It buildz, ship it:
# time dm android-ndk:r12b-arm \ android-ndk:r15c-arm \ debian:experimental-x-arm64 \ ubuntu:14.04.4-x-linaro-arm64 \ ubuntu:16.04-x-arm \ ubuntu:16.04-x-arm64 \ ubuntu:18.04-x-arm \ ubuntu:18.04-x-arm64 1 android-ndk:r12b-arm : Ok arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease) 2 android-ndk:r15c-arm : Ok arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease) 3 debian:experimental-x-arm64 : Ok aarch64-linux-gnu-gcc (Debian 8.2.0-7) 8.2.0 4 ubuntu:14.04.4-x-linaro-arm64 : Ok aarch64-linux-gnu-gcc (Linaro GCC 5.5-2017.10) 5.5.0 5 ubuntu:16.04-x-arm : Ok arm-linux-gnueabihf-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609 6 ubuntu:16.04-x-arm64 : Ok aarch64-linux-gnu-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609 7 ubuntu:18.04-x-arm : Ok arm-linux-gnueabihf-gcc (Ubuntu/Linaro 7.3.0-27ubuntu1~18.04) 7.3.0 8 ubuntu:18.04-x-arm64 : Ok aarch64-linux-gnu-gcc (Ubuntu/Linaro 7.3.0-27ubuntu1~18.04) 7.3.0 #
Quoted 1 line
So I've added it to my tree as below, can I keep it like that?
Yup, thanks for turning it into a proper patch. Just to be explicit, here's my s-o-b:
Will
tip-bot for Will Deacon
merge bot[tip:perf/urgent] tools headers barrier: Fix arm64 tools build failure wrt smp_load_{acquire,release}
In reply to Will Deacontools headers barrier: Fix arm64 tools build failure wrt smp_load_{acquire,release}
Commit-ID: 51f5fd2e4615dcdc25cd7f9d19b7b27eb9ecdac7 Gitweb: https://git.kernel.org/tip/51f5fd2e4615dcdc25cd7f9d19b7b27eb9ecdac7 Author: Will Deacon <[email protected]> AuthorDate: Wed, 31 Oct 2018 17:44:08 +0000 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 1 Nov 2018 10:07:43 -0300
tools headers barrier: Fix arm64 tools build failure wrt smp_load_{acquire,release}
Cheers for reporting this. I managed to reproduce the build failure with gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1).
The code in question is the arm64 versions of smp_load_acquire() and smp_store_release(). Unlike other architectures, these are not built around READ_ONCE() and WRITE_ONCE() since we have instructions we can use instead of fences. Bringing our macros up-to-date with those (i.e. tweaking the union initialisation and using the special "uXX_alias_t" types) appears to fix the issue for me.
Committer notes:
Testing it in the systems previously failing:
# time dm android-ndk:r12b-arm \
android-ndk:r15c-arm \
debian:experimental-x-arm64 \
ubuntu:14.04.4-x-linaro-arm64 \
ubuntu:16.04-x-arm \
ubuntu:16.04-x-arm64 \
ubuntu:18.04-x-arm \
ubuntu:18.04-x-arm64
1 android-ndk:r12b-arm : Ok arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease)
2 android-ndk:r15c-arm : Ok arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease)
3 debian:experimental-x-arm64 : Ok aarch64-linux-gnu-gcc (Debian 8.2.0-7) 8.2.0
4 ubuntu:14.04.4-x-linaro-arm64 : Ok aarch64-linux-gnu-gcc (Linaro GCC 5.5-2017.10) 5.5.0
5 ubuntu:16.04-x-arm : Ok arm-linux-gnueabihf-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
6 ubuntu:16.04-x-arm64 : Ok aarch64-linux-gnu-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
7 ubuntu:18.04-x-arm : Ok arm-linux-gnueabihf-gcc (Ubuntu/Linaro 7.3.0-27ubuntu1~18.04) 7.3.0
8 ubuntu:18.04-x-arm64 : Ok aarch64-linux-gnu-gcc (Ubuntu/Linaro 7.3.0-27ubuntu1~18.04) 7.3.0--- tools/arch/arm64/include/asm/barrier.h | 133 +++++++++++++++++---------------- 1 file changed, 67 insertions(+), 66 deletions(-)
tools/arch/arm64/include/asm/barrier.h +67 -66
@@ -14,74 +14,75 @@#define wmb () asm volatile("dmb ishst" ::: "memory")#define rmb () asm volatile("dmb ishld" ::: "memory") -#define smp_store_release (p, v) \ -do { \ - union { typeof(*p) __val; char __c[1]; } __u = \ - { .__val = (__force typeof(*p)) (v) }; \ - \ - switch (sizeof(*p)) { \ - case 1: \ - asm volatile ("stlrb %w1, %0" \ - : "=Q" (*p) \ - : "r" (*(__u8 *)__u.__c) \ - : "memory"); \ - break; \ - case 2: \ - asm volatile ("stlrh %w1, %0" \ - : "=Q" (*p) \ - : "r" (*(__u16 *)__u.__c) \ - : "memory"); \ - break; \ - case 4: \ - asm volatile ("stlr %w1, %0" \ - : "=Q" (*p) \ - : "r" (*(__u32 *)__u.__c) \ - : "memory"); \ - break; \ - case 8: \ - asm volatile ("stlr %1, %0" \ - : "=Q" (*p) \ - : "r" (*(__u64 *)__u.__c) \ - : "memory"); \ - break; \ - default: \ -/* Only to shut up gcc ... */ \ -mb (); \ -break ; \ - } \ +#define smp_store_release (p, v) \ +do { \ + union { typeof(*p) __val; char __c[1]; } __u = \ + { .__val = (v) }; \ + \ + switch (sizeof(*p)) { \ + case 1: \ + asm volatile ("stlrb %w1, %0" \ + : "=Q" (*p) \ + : "r" (*(__u8_alias_t *)__u.__c) \ + : "memory"); \ + break; \ + case 2: \ + asm volatile ("stlrh %w1, %0" \ + : "=Q" (*p) \ + : "r" (*(__u16_alias_t *)__u.__c) \ + : "memory"); \ + break; \ + case 4: \ + asm volatile ("stlr %w1, %0" \ + : "=Q" (*p) \ + : "r" (*(__u32_alias_t *)__u.__c) \ + : "memory"); \ + break; \ + case 8: \ + asm volatile ("stlr %1, %0" \ + : "=Q" (*p) \ + : "r" (*(__u64_alias_t *)__u.__c) \ + : "memory"); \ + break; \ + default: \ +/* Only to shut up gcc ... */ \ +mb (); \ +break ; \ + } \ } while (0) -#define smp_load_acquire (p) \ -({ \ - union { typeof(*p) __val; char __c[1]; } __u; \ - \ - switch (sizeof(*p)) { \ - case 1: \ - asm volatile ("ldarb %w0, %1" \ - : "=r" (*(__u8 *)__u.__c) \ - : "Q" (*p) : "memory"); \ - break; \ - case 2: \ - asm volatile ("ldarh %w0, %1" \ - : "=r" (*(__u16 *)__u.__c) \ - : "Q" (*p) : "memory"); \ - break; \ - case 4: \ - asm volatile ("ldar %w0, %1" \ - : "=r" (*(__u32 *)__u.__c) \ - : "Q" (*p) : "memory"); \ - break; \ - case 8: \ - asm volatile ("ldar %0, %1" \ - : "=r" (*(__u64 *)__u.__c) \ - : "Q" (*p) : "memory"); \ - break; \ - default: \ -/* Only to shut up gcc ... */ \ -mb (); \ -break ; \ - } \ - __u.__val; \ +#define smp_load_acquire (p) \ +({ \ + union { typeof(*p) __val; char __c[1]; } __u = \ + { .__c = { 0 } }; \ + \ + switch (sizeof(*p)) { \ + case 1: \ + asm volatile ("ldarb %w0, %1" \ + : "=r" (*(__u8_alias_t *)__u.__c) \ + : "Q" (*p) : "memory"); \ + break; \ + case 2: \ + asm volatile ("ldarh %w0, %1" \ + : "=r" (*(__u16_alias_t *)__u.__c) \ + : "Q" (*p) : "memory"); \ + break; \ + case 4: \ + asm volatile ("ldar %w0, %1" \ + : "=r" (*(__u32_alias_t *)__u.__c) \ + : "Q" (*p) : "memory"); \ + break; \ + case 8: \ + asm volatile ("ldar %0, %1" \ + : "=r" (*(__u64_alias_t *)__u.__c) \ + : "Q" (*p) : "memory"); \ + break; \ + default: \ +/* Only to shut up gcc ... */ \ +mb (); \ +break ; \ + } \ + __u.__val; \ })#endif /* _TOOLS_LINUX_ASM_AARCH64_BARRIER_H */