clang build error on i686
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.
Full build log from the 6.0.0 build:
https://gist.githubusercontent.com/crobinso/7b1206044eac7326490b2adce829e861/raw/9dddef968051fd6383ba7adb9e595081ad4f8fa4/gistfile1.txt
Lots of errors like:
/usr/bin/ld: libqemu-aarch64-softmmu.fa.p/accel_tcg_cputlb.c.o: in function `helper_atomic_cmpxchgq_le_mmu':
/builddir/build/BUILD/qemu-6.0.0/accel/tcg/atomic_template.h:86:
undefined reference to __atomic_compare_exchange_8' /usr/bin/ld: libqemu-aarch64-softmmu.fa.p/accel_tcg_cputlb.c.o: in function helper_atomic_xchgq_le_mmu':
/builddir/build/BUILD/qemu-6.0.0/accel/tcg/atomic_template.h:134:
undefined reference to `__atomic_exchange_8'
Also warnings like:
/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)Search the log for __atomic for other hits.
Thanks,
Cole
Quoted 8 lines · Cole Robinson
Hi, I'm hitting build errors with clang on i686 userspace on
x86_64kernel. 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]
Quoted 5 lines
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 --
include/qemu/stats64.h +3 -3
@@ -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 --
meson.build +2 -0
@@ -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.
Quoted 9 lines · Cole Robinson
Hi, I'm hitting build errors with clang on i686 userspace on
x86_64kernel. Affects both qemu 6.0.0 and qemu.git, tested with fedora clang-12.0.1~rc3-1.fc35.i686.Full build log from the 6.0.0 build:
https://gist.githubusercontent.com/crobinso/7b1206044eac7326490b2adce829e861/raw/9dddef968051fd6383ba7adb9e595081ad4f8fa4/gistfile1.txtLots of errors like:
Quoted 8 lines
/usr/bin/ld:libqemu-aarch64-softmmu.fa.p/accel_tcg_cputlb.c.o: in function `helper_atomic_cmpxchgq_le_mmu':
/builddir/build/BUILD/qemu-6.0.0/accel/tcg/atomic_template.h:86:
undefined reference to__atomic_compare_exchange_8' /usr/bin/ld: libqemu-aarch64-softmmu.fa.p/accel_tcg_cputlb.c.o: in functionhelper_atomic_xchgq_le_mmu':
/builddir/build/BUILD/qemu-6.0.0/accel/tcg/atomic_template.h:134:
undefined reference to `__atomic_exchange_8'
Marc-André reported this one recently:
https://www.mail-archive.com/[email protected]/msg814163.html
Peter once replied smth related:
https://lists.gnu.org/archive/html/qemu-devel/2018-01/msg02103.html
Quoted 48 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Cole Robinson
Hi, I'm hitting build errors with clang on i686 userspace on
x86_64kernel. 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]Quoted 5 lines
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.
Ah wait, there is also another one (which I reverted later):
-- >8 --
meson.build +3
-0@@ -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 = []
meson.build +1
-1@@ -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)
Quoted 3 lines
---
No clue neither. Posting in case it ring a bell to someone.
I suppose I dropped it after reading this thread:
https://www.mail-archive.com/[email protected]/msg445404.html
Quoted 25 lines · Cole Robinson
Hi, I'm hitting build errors with clang on i686 userspace on
x86_64kernel. Affects both qemu 6.0.0 and qemu.git, tested with fedora clang-12.0.1~rc3-1.fc35.i686.Full build log from the 6.0.0 build:
https://gist.githubusercontent.com/crobinso/7b1206044eac7326490b2adce829e861/raw/9dddef968051fd6383ba7adb9e595081ad4f8fa4/gistfile1.txtLots of errors like:
/usr/bin/ld:libqemu-aarch64-softmmu.fa.p/accel_tcg_cputlb.c.o: in function `helper_atomic_cmpxchgq_le_mmu':
/builddir/build/BUILD/qemu-6.0.0/accel/tcg/atomic_template.h:86:
undefined reference to__atomic_compare_exchange_8' /usr/bin/ld: libqemu-aarch64-softmmu.fa.p/accel_tcg_cputlb.c.o: in functionhelper_atomic_xchgq_le_mmu':
/builddir/build/BUILD/qemu-6.0.0/accel/tcg/atomic_template.h:134:
undefined reference to `__atomic_exchange_8'Also warnings like:
/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]
Quoted 5 lines
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)I think at least part of what is happening here is that this compiler/host doesn't support native 64-bit atomics, but configure has selected CONFIG_ATOMIC64 anyway. I've cc'd Paolo and Richard who 'git blame' suggests have touched the configure test and the stats64.h code in the past.
(The compiler provides fallbacks in libatomic for the 64-bit atomics, but we deliberately do not link against libatomic because we do not want to use them.)
thanks
-- PMM
Quoted 32 lines · Peter Maydell
Quoted 25 lines · Cole Robinson
Hi, I'm hitting build errors with clang on i686 userspace on
x86_64kernel. Affects both qemu 6.0.0 and qemu.git, tested with fedora clang-12.0.1~rc3-1.fc35.i686.Full build log from the 6.0.0 build:
https://gist.githubusercontent.com/crobinso/7b1206044eac7326490b2adce829e861/raw/9dddef968051fd6383ba7adb9e595081ad4f8fa4/gistfile1.txtLots of errors like:
/usr/bin/ld:libqemu-aarch64-softmmu.fa.p/accel_tcg_cputlb.c.o: in function `helper_atomic_cmpxchgq_le_mmu':
/builddir/build/BUILD/qemu-6.0.0/accel/tcg/atomic_template.h:86:
undefined reference to__atomic_compare_exchange_8' /usr/bin/ld: libqemu-aarch64-softmmu.fa.p/accel_tcg_cputlb.c.o: in functionhelper_atomic_xchgq_le_mmu':
/builddir/build/BUILD/qemu-6.0.0/accel/tcg/atomic_template.h:134:
undefined reference to `__atomic_exchange_8'Also warnings like:
/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]Quoted 5 lines
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)
Quoted 3 lines
I think at least part of what is happening here is that this compiler/host doesn't support native 64-bit atomics, but configure has selected
CONFIG_ATOMIC64anyway.
Not true. The host certainly supports it.
This is a new alignment warning in clang-12 wrt the alignment of the atomic operation. Which may be complicated by the fact that the i386 abi does not normally align structures beyond 4 bytes.
We may need to disable this warning for i386 (but not x86_64).
r~
Quoted 38 lines · Richard Henderson
Quoted 32 lines · Peter Maydell
Quoted 25 lines · Cole Robinson
Hi, I'm hitting build errors with clang on i686 userspace on
x86_64kernel. Affects both qemu 6.0.0 and qemu.git, tested with fedora clang-12.0.1~rc3-1.fc35.i686.Full build log from the 6.0.0 build:
https://gist.githubusercontent.com/crobinso/7b1206044eac7326490b2adce829e861/raw/9dddef968051fd6383ba7adb9e595081ad4f8fa4/gistfile1.txtLots of errors like:
/usr/bin/ld:libqemu-aarch64-softmmu.fa.p/accel_tcg_cputlb.c.o: in function `helper_atomic_cmpxchgq_le_mmu':
/builddir/build/BUILD/qemu-6.0.0/accel/tcg/atomic_template.h:86:
undefined reference to__atomic_compare_exchange_8' /usr/bin/ld: libqemu-aarch64-softmmu.fa.p/accel_tcg_cputlb.c.o: in functionhelper_atomic_xchgq_le_mmu':
/builddir/build/BUILD/qemu-6.0.0/accel/tcg/atomic_template.h:134:
undefined reference to `__atomic_exchange_8'Also warnings like:
/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]Quoted 5 lines
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)Quoted 3 lines
I think at least part of what is happening here is that this compiler/host doesn't support native 64-bit atomics, but configure has selected
CONFIG_ATOMIC64anyway.
Quoted 7 lines
Not true. The host certainly supports it.
This is a new alignment warning in clang-12 wrt the alignment of the atomic operation. Which may be complicated by the fact that the i386 abi does not normally align structures beyond 4 bytes.
We may need to disable this warning for i386 (but not
x86_64).
The first part of the problem isn't just a warning, though -- it's clang actually emitting calls to libatomic.
-- PMM
Quoted 10 lines · Peter Maydell
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Lots of errors like:
/usr/bin/ld:libqemu-aarch64-softmmu.fa.p/accel_tcg_cputlb.c.o: in function `helper_atomic_cmpxchgq_le_mmu':
/builddir/build/BUILD/qemu-6.0.0/accel/tcg/atomic_template.h:86:
undefined reference to__atomic_compare_exchange_8' /usr/bin/ld: libqemu-aarch64-softmmu.fa.p/accel_tcg_cputlb.c.o: in functionhelper_atomic_xchgq_le_mmu':
/builddir/build/BUILD/qemu-6.0.0/accel/tcg/atomic_template.h:134:
undefined reference to `__atomic_exchange_8'
...
Quoted 2 lines
The first part of the problem isn't just a warning, though -- it's clang actually emitting calls to libatomic.
I wasn't able to reproduce this part, only the compile-time warning.
r~