On 7/3/21 4:34 PM, Cole Robinson wrote: > Hi, I'm hitting build errors with clang on i686 userspace on x86_64 > kernel. Affects both qemu 6.0.0 and qemu.git, tested with fedora > clang-12.0.1~rc3-1.fc35.i686.
> /builddir/build/BUILD/qemu-6.0.0/include/qemu/stats64.h:58:21: warning: > misaligned atomic operation may incur significant performance penalty; > the expected alignment (8 bytes) exceeds the actual alignment (4 bytes) > [-Watomic-alignment] > uint64_t orig = qatomic_read__nocheck(&s->value); > ^ > /builddir/build/BUILD/qemu-6.0.0/include/qemu/atomic.h:129:5: note: > expanded from macro 'qatomic_read__nocheck' > __atomic_load_n(ptr, __ATOMIC_RELAXED) Ah I hit this one few months ago using Clang10 to build i386 guest on mips64el host. In my notes I see I tried: -- >8 -- diff --git a/include/qemu/stats64.h b/include/qemu/stats64.h index fdd3d1b8f98..df9962add4e 100644 --- a/include/qemu/stats64.h +++ b/include/qemu/stats64.h @@ -37,7 +37,7 @@ static inline void stat64_init(Stat64 *s, uint64_t value) static inline uint64_t stat64_get(const Stat64 *s) { - return qatomic_read__nocheck(&s->value); + return qatomic_read_u64(&s->value); } static inline void stat64_add(Stat64 *s, uint64_t value) @@ -47,7 +47,7 @@ static inline void stat64_add(Stat64 *s, uint64_t value) static inline void stat64_min(Stat64 *s, uint64_t value) { - uint64_t orig = qatomic_read__nocheck(&s->value); + uint64_t orig = qatomic_read_u64(&s->value); while (orig > value) { orig = qatomic_cmpxchg__nocheck(&s->value, orig, value); } @@ -55,7 +55,7 @@ static inline void stat64_min(Stat64 *s, uint64_t value) static inline void stat64_max(Stat64 *s, uint64_t value) { - uint64_t orig = qatomic_read__nocheck(&s->value); + uint64_t orig = qatomic_read_u64(&s->value); while (orig < value) { orig = qatomic_cmpxchg__nocheck(&s->value, orig, value); } --- TBH today I don't remember much, I think the change wasn't making much sense, then I stopped using Clang there. Ah wait, there is also another one (which I reverted later): -- >8 -- diff --git a/meson.build b/meson.build index 372576f82c5..1a5da5ee56b 100644 --- a/meson.build +++ b/meson.build @@ -161,6 +161,9 @@ error('Multipath is supported only on Linux') endif +if 'CONFIG_ATOMIC64' in config_host + atomic = cc.find_library('atomic', required: config_host['ARCH'] in ['i386', 'arm', 'riscv32']) +endif m = cc.find_library('m', required: false) util = cc.find_library('util', required: false) winmm = [] @@ -1534,7 +1537,7 @@ util_ss = util_ss.apply(config_all, strict: false) libqemuutil = static_library('qemuutil', sources: util_ss.sources() + stub_ss.sources() + genh, - dependencies: [util_ss.dependencies(), m, glib, socket, malloc]) + dependencies: [util_ss.dependencies(), atomic, m, glib, socket, malloc]) qemuutil = declare_dependency(link_with: libqemuutil, sources: genh + version_res) --- No clue neither. Posting in case it ring a bell to someone.