buildsys: More fixes to use GCC on macOS
v2 cover buildsys: More fixes to use GCC on macOS
Few fixes to be able to use GCC extensions which are not available on Clang.
Since RFC:
- Split Clang __builtin_available() patch
- Do not un-inline qemu_thread_jit_execute/write
- Do not use #pragma diagnostic
- Demote ui/cocoa key arrays to static const
- Lookup scripts/entitlement.sh script once again
- Pass filtered QEMU_OBJCFLAGS configure -> meson
- Disable out-of-line atomic operations on Aarch64
Philippe Mathieu-Daudé (8):
osdep: Avoid using Clang-specific __builtin_available()
osdep: Ignore 'unguarded-availability-new' warnings on macOS Catalina
meson: Resolve the entitlement.sh script once for good
configure: Disable out-of-line atomic operations on Aarch64
meson: Log QEMU_CXXFLAGS content in summary
configure: Pass filtered QEMU_OBJCFLAGS to meson
audio: Rename coreaudio extension to use Objective-C compiler ui/cocoa: Constify qkeycode translation arrays
audio/{coreaudio.c => coreaudio.m} | 0
audio/meson.build | 2 +-
configure | 35 ++++++++++++++++++++++++++++++
include/qemu/osdep.h | 10 +++------
meson.build | 11 ++++++++--
ui/cocoa.m | 4 ++--
6 files changed, 50 insertions(+), 12 deletions(-)
rename audio/{coreaudio.c => coreaudio.m} (100%)Signature · 1 line
2.34.1
PATCH v2 1/8 osdep: Avoid using Clang-specific __builtin_available()
Remove the Clang specific __builtin_available() to allow building with GCC, otherwise we get:
include/qemu/osdep.h: In function 'qemu_thread_jit_write':
include/qemu/osdep.h:787:9: warning: implicit declaration of function '__builtin_available'; did you mean '__builtin_scalbl'? [-Wimplicit-function-declaration]
787 | if (__builtin_available(macOS 11.0, *)) {
| ^~~~~~~~~~~~~~~~~~~
| __builtin_scalbl
include/qemu/osdep.h:787:9: warning: nested extern declaration of '__builtin_available' [-Wnested-externs]
include/qemu/osdep.h:787:29: error: 'macOS' undeclared (first use in this function)
787 | if (__builtin_available(macOS 11.0, *)) {
| ^~~~~
include/qemu/osdep.h:787:29: note: each undeclared identifier is reported only once for each function it appears in
include/qemu/osdep.h:787:34: error: expected ')' before numeric constant
787 | if (__builtin_available(macOS 11.0, *)) {
| ~ ^~~~~
| )--- include/qemu/osdep.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
include/qemu/osdep.h +2 -6
@@ -777,16 +777,12 @@ size_t qemu_get_host_physmem(void); MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0static inline void qemu_thread_jit_execute (void ) { - if (__builtin_available(macOS 11.0, *)) { -pthread_jit_write_protect_np (true); - } +pthread_jit_write_protect_np (true); }static inline void qemu_thread_jit_write (void ) { - if (__builtin_available(macOS 11.0, *)) { -pthread_jit_write_protect_np (false); - } +pthread_jit_write_protect_np (false); }#else static inline void qemu_thread_jit_write (void ) {}
Signature · 1 line
2.34.1
PATCH v2 2/8 osdep: Ignore 'unguarded-availability-new' warnings on macOS Catalina
In reply to Philippe Mathieu-Daudé viaWhen building with GCC on macOS Catalina we get 2254 times:
include/qemu/osdep.h:780:5: warning: 'pthread_jit_write_protect_np' is only available on macOS 11.0 or newer [-Wunguarded-availability-new]
pthread_jit_write_protect_np(true);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~Fix by using a stricker toolchain version low range, replacing MAC_OS_X_VERSION_MAX_ALLOWED by MAC_OS_X_VERSION_MIN_REQUIRED.
--- include/qemu/osdep.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/qemu/osdep.h +1 -1
@@ -774,7 +774,7 @@ size_t qemu_get_host_physmem(void);* for the current thread. */ #if defined(MAC_OS_VERSION_11_0 ) && \ -MAC_OS_X_VERSION_MAX_ALLOWED >=MAC_OS_VERSION_11_0 +MAC_OS_X_VERSION_MIN_REQUIRED >=MAC_OS_VERSION_11_0 static inline void qemu_thread_jit_execute (void ) {pthread_jit_write_protect_np (true);
Signature · 1 line
2.34.1
Re: [PATCH v2 2/8] osdep: Ignore 'unguarded-availability-new' warnings on macOS Catalina
Quoted 29 lines · Philippe Mathieu-Daudé
When building with GCC on macOS Catalina we get 2254 times:
include/qemu/osdep.h:780:5: warning: 'pthread_jit_write_protect_np' is only available on macOS 11.0 or newer [-Wunguarded-availability-new]pthread_jit_write_protect_np(true); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~Fix by using a stricker toolchain version low range, replacing
MAC_OS_X_VERSION_MAX_ALLOWEDbyMAC_OS_X_VERSION_MIN_REQUIRED.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/qemu/osdep.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/qemu/osdep.h +1
-2@@ -774,7 +774,7 @@ size_t qemu_get_host_physmem(void);* for the current thread. */ #if defined(MAC_OS_VERSION_11_0 ) && \ -MAC_OS_X_VERSION_MAX_ALLOWED >=MAC_OS_VERSION_11_0 +MAC_OS_X_VERSION_MIN_REQUIRED >=MAC_OS_VERSION_11_0 static inline void qemu_thread_jit_execute (void ) {pthread_jit_write_protect_np (true); --
Quoted 2 lines
2.34.1
This should be squashed with "[PATCH v2 1/8] osdep: Avoid using Clang-specific __builtin_available()"; Removing __builtin_available makes it incompatible with macOS < 11.0, hence this change is needed.
PATCH v2 3/8 meson: Resolve the entitlement.sh script once for good
In reply to Philippe Mathieu-Daudé viaCommit 235b523dba ("meson: Use find_program() to resolve the entitlement.sh script") didn't correctly fixed the issue, as the script is still resolved for each target. Move the check earlier, before processing each target.
--- meson.build | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
meson.build +4 -1
@@ -2894,6 +2894,10 @@ common_all = static_library('common', feature_to_c = find_program('scripts/feature_to_c.sh') +if targetos == 'darwin' + entitlement = find_program('scripts/entitlement.sh') +endif + emulators = {} foreach target : target_dirs config_target = config_target_mak[target]
@@ -3051,7 +3055,6 @@ foreach target : target_dirs install_input += meson.current_source_dir() / entitlements endif - entitlement = find_program('scripts/entitlement.sh') emulators += {exe['name'] : custom_target(exe['name'], input: build_input, output: exe['name'],
Signature · 1 line
2.34.1
PATCH v2 4/8 configure: Disable out-of-line atomic operations on Aarch64
In reply to Philippe Mathieu-Daudé viaGCC 10.1 introduced the -moutline-atomics option on Aarch64. This options is enabled by default, and triggers a link failure:
Undefined symbols for architecture arm64:
"___aarch64_cas1_acq_rel", referenced from:
_qmp_migrate_recover in migration_migration.c.o _cpu_atomic_cmpxchgb_mmu in accel_tcg_cputlb.c.o _cpu_atomic_fetch_sminb_mmu in accel_tcg_cputlb.c.o _cpu_atomic_fetch_uminb_mmu in accel_tcg_cputlb.c.o _cpu_atomic_fetch_smaxb_mmu in accel_tcg_cputlb.c.o _cpu_atomic_fetch_umaxb_mmu in accel_tcg_cputlb.c.o _cpu_atomic_smin_fetchb_mmu in accel_tcg_cputlb.c.o
...
"___aarch64_ldadd4_acq_rel", referenced from:
_multifd_recv_new_channel in migration_multifd.c.o _monitor_event in monitor_hmp.c.o _handle_hmp_command in monitor_hmp.c.o _colo_compare_finalize in net_colo-compare.c.o _flatview_unref in softmmu_memory.c.o _virtio_scsi_hotunplug in hw_scsi_virtio-scsi.c.o _tcg_register_thread in tcg_tcg.c.o
...
"___aarch64_swp4_acq", referenced from:
_qemu_spin_lock in softmmu_cpu-timers.c.o _cpu_get_ticks in softmmu_cpu-timers.c.o _qemu_spin_lock in softmmu_icount.c.o _cpu_exec in accel_tcg_cpu-exec.c.o _page_flush_tb_1.isra.0 in accel_tcg_translate-all.c.o _page_entry_lock in accel_tcg_translate-all.c.o _do_tb_phys_invalidate in accel_tcg_translate-all.c.o
...
QEMU implements its own atomic operations using C11 builtin helpers. Disable the GCC out-of-line atomic ops.
---
Cc: Stefan Hajnoczi <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Clearly out of my understanding, but at least it links and the qtests pass.
--- configure | 12 ++++++++++++ 1 file changed, 12 insertions(+)
configure +12 -0
@@ -2826,6 +2826,18 @@ else avx512f_opt="no" fi +######################################### +# Disable out-of-line atomic operations. + +case "$cpu" in + aarch64) + write_c_skeleton; + if compile_prog "$CPU_CFLAGS -Werror -mno-outline-atomics" "" ; then + CPU_CFLAGS="-mno-outline-atomics $CPU_CFLAGS" + fi + ;; +esac + ######################################## # check if __[u]int128_t is usable.
Signature · 1 line
2.34.1
Re: [PATCH v2 4/8] configure: Disable out-of-line atomic operations on Aarch64
Quoted 71 lines · Philippe Mathieu-Daudé
GCC 10.1 introduced the -moutline-atomics option on Aarch64. This options is enabled by default, and triggers a link failure:
Undefined symbols for architecture arm64:
"___aarch64_cas1_acq_rel", referenced from:
_qmp_migrate_recoverin migration_migration.c.o_cpu_atomic_cmpxchgb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_fetch_sminb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_fetch_uminb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_fetch_smaxb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_fetch_umaxb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_smin_fetchb_mmuin accel_tcg_cputlb.c.o
...
"___aarch64_ldadd4_acq_rel", referenced from:
_multifd_recv_new_channelin migration_multifd.c.o_monitor_eventin monitor_hmp.c.o_handle_hmp_commandin monitor_hmp.c.o_colo_compare_finalizein net_colo-compare.c.o_flatview_unrefin softmmu_memory.c.o_virtio_scsi_hotunplugin hw_scsi_virtio-scsi.c.o_tcg_register_threadin tcg_tcg.c.o
...
"___aarch64_swp4_acq", referenced from:
_qemu_spin_lockin softmmu_cpu-timers.c.o_cpu_get_ticksin softmmu_cpu-timers.c.o_qemu_spin_lockin softmmu_icount.c.o_cpu_execin accel_tcg_cpu-exec.c.o _page_flush_tb_1.isra.0 in accel_tcg_translate-all.c.o_page_entry_lockin accel_tcg_translate-all.c.o_do_tb_phys_invalidatein accel_tcg_translate-all.c.o
...QEMU implements its own atomic operations using C11 builtin helpers. Disable the GCC out-of-line atomic ops.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Cc: Stefan Hajnoczi <[email protected]>
Cc: Paolo Bonzini <[email protected]>Clearly out of my understanding, but at least it links and the qtests pass.
--- configure | 12 ++++++++++++ 1 file changed, 12 insertions(+)configure +12
-1@@ -2826,6 +2826,18 @@ else avx512f_opt="no" fi +######################################### +# Disable out-of-line atomic operations. + +case "$cpu" in + aarch64) + write_c_skeleton; + if compile_prog "$CPU_CFLAGS -Werror -mno-outline-atomics" "" ; then + CPU_CFLAGS="-mno-outline-atomics $CPU_CFLAGS" + fi + ;; +esac + ######################################## # check if __[u]int128_t is usable. --
Quoted 2 lines
2.34.1
This change would (slightly) increase the code size and is harmful to the other proper GCC installations. The flag should be specified by the user (or the user should fix the GCC installation.)
Re: [PATCH v2 4/8] configure: Disable out-of-line atomic operations on Aarch64
In reply to Philippe Mathieu-Daudé viaQuoted 40 lines · Philippe Mathieu-Daudé via
GCC 10.1 introduced the -moutline-atomics option on Aarch64. This options is enabled by default, and triggers a link failure:
Undefined symbols for architecture arm64:
"___aarch64_cas1_acq_rel", referenced from:
_qmp_migrate_recoverin migration_migration.c.o_cpu_atomic_cmpxchgb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_fetch_sminb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_fetch_uminb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_fetch_smaxb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_fetch_umaxb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_smin_fetchb_mmuin accel_tcg_cputlb.c.o
...
"___aarch64_ldadd4_acq_rel", referenced from:
_multifd_recv_new_channelin migration_multifd.c.o_monitor_eventin monitor_hmp.c.o_handle_hmp_commandin monitor_hmp.c.o_colo_compare_finalizein net_colo-compare.c.o_flatview_unrefin softmmu_memory.c.o_virtio_scsi_hotunplugin hw_scsi_virtio-scsi.c.o_tcg_register_threadin tcg_tcg.c.o
...
"___aarch64_swp4_acq", referenced from:
_qemu_spin_lockin softmmu_cpu-timers.c.o_cpu_get_ticksin softmmu_cpu-timers.c.o_qemu_spin_lockin softmmu_icount.c.o_cpu_execin accel_tcg_cpu-exec.c.o _page_flush_tb_1.isra.0 in accel_tcg_translate-all.c.o_page_entry_lockin accel_tcg_translate-all.c.o_do_tb_phys_invalidatein accel_tcg_translate-all.c.o
...QEMU implements its own atomic operations using C11 builtin helpers. Disable the GCC out-of-line atomic ops.
Signed-off-by Philippe Mathieu-Daudé<[email protected]>---
Cc: Stefan Hajnoczi<[email protected]>
Cc: Paolo Bonzini<[email protected]>
Quoted 5 lines
Clearly out of my understanding, but at least it links and the qtests pass.
--- configure | 12 ++++++++++++ 1 file changed, 12 insertions(+)
These should have been supplied by libgcc.a, which we're supposed to be linking against. Something is wrong with your installation.
r~
Re: [PATCH v2 4/8] configure: Disable out-of-line atomic operations on Aarch64
Quoted 41 lines · Richard Henderson
Quoted 40 lines · Philippe Mathieu-Daudé via
GCC 10.1 introduced the -moutline-atomics option on Aarch64. This options is enabled by default, and triggers a link failure:
Undefined symbols for architecture arm64:
"___aarch64_cas1_acq_rel", referenced from:
_qmp_migrate_recoverin migration_migration.c.o_cpu_atomic_cmpxchgb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_fetch_sminb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_fetch_uminb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_fetch_smaxb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_fetch_umaxb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_smin_fetchb_mmuin accel_tcg_cputlb.c.o
...
"___aarch64_ldadd4_acq_rel", referenced from:
_multifd_recv_new_channelin migration_multifd.c.o_monitor_eventin monitor_hmp.c.o_handle_hmp_commandin monitor_hmp.c.o_colo_compare_finalizein net_colo-compare.c.o_flatview_unrefin softmmu_memory.c.o_virtio_scsi_hotunplugin hw_scsi_virtio-scsi.c.o_tcg_register_threadin tcg_tcg.c.o
...
"___aarch64_swp4_acq", referenced from:
_qemu_spin_lockin softmmu_cpu-timers.c.o_cpu_get_ticksin softmmu_cpu-timers.c.o_qemu_spin_lockin softmmu_icount.c.o_cpu_execin accel_tcg_cpu-exec.c.o _page_flush_tb_1.isra.0 in accel_tcg_translate-all.c.o_page_entry_lockin accel_tcg_translate-all.c.o_do_tb_phys_invalidatein accel_tcg_translate-all.c.o
...QEMU implements its own atomic operations using C11 builtin helpers. Disable the GCC out-of-line atomic ops.
Signed-off-by Philippe Mathieu-Daudé<[email protected]>---
Cc: Stefan Hajnoczi<[email protected]>
Cc: Paolo Bonzini<[email protected]>
Quoted 7 lines
Quoted 5 lines
Clearly out of my understanding, but at least it links and the qtests pass.
---
configure | 12 ++++++++++++1 file changed, 12 insertions(+)These should have been supplied by libgcc.a, which we're supposed to be linking against. Something is wrong with your installation.
I don't have gobjc/g++ installed, so ./configure defaulted to Clang to compile these languages, but compiled C files using GCC. At the end the Clang linker is used (the default c++ symlink).
Could there be a mismatch between Clang (-mno-outline-atomics) and GCC (-moutline-atomics)?
Re: [PATCH v2 4/8] configure: Disable out-of-line atomic operations on Aarch64
Quoted 48 lines · Philippe Mathieu-Daudé
Quoted 47 lines · Richard Henderson
Quoted 45 lines · Philippe Mathieu-Daudé via
GCC 10.1 introduced the -moutline-atomics option on Aarch64. This options is enabled by default, and triggers a link failure:
Undefined symbols for architecture arm64:
"___aarch64_cas1_acq_rel", referenced from:
_qmp_migrate_recoverin migration_migration.c.o_cpu_atomic_cmpxchgb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_fetch_sminb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_fetch_uminb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_fetch_smaxb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_fetch_umaxb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_smin_fetchb_mmuin accel_tcg_cputlb.c.o
...
"___aarch64_ldadd4_acq_rel", referenced from:
_multifd_recv_new_channelin migration_multifd.c.o_monitor_eventin monitor_hmp.c.o_handle_hmp_commandin monitor_hmp.c.o_colo_compare_finalizein net_colo-compare.c.o_flatview_unrefin softmmu_memory.c.o_virtio_scsi_hotunplugin hw_scsi_virtio-scsi.c.o_tcg_register_threadin tcg_tcg.c.o
...
"___aarch64_swp4_acq", referenced from:
_qemu_spin_lockin softmmu_cpu-timers.c.o_cpu_get_ticksin softmmu_cpu-timers.c.o_qemu_spin_lockin softmmu_icount.c.o_cpu_execin accel_tcg_cpu-exec.c.o _page_flush_tb_1.isra.0 in accel_tcg_translate-all.c.o_page_entry_lockin accel_tcg_translate-all.c.o_do_tb_phys_invalidatein accel_tcg_translate-all.c.o
...QEMU implements its own atomic operations using C11 builtin helpers. Disable the GCC out-of-line atomic ops.
Signed-off-by Philippe Mathieu-Daudé<[email protected]>---
Cc: Stefan Hajnoczi<[email protected]>
Cc: Paolo Bonzini<[email protected]>Clearly out of my understanding, but at least it links and the qtests pass.
---
configure | 12 ++++++++++++1 file changed, 12 insertions(+)
Quoted 8 lines
Quoted 1 line
These should have been supplied by libgcc.a, which we're supposed to be linking against. Something is wrong with your installation.
I don't have gobjc/g++ installed, so ./configure defaulted to Clang to compile these languages, but compiled C files using GCC. At the end the Clang linker is used (the default c++ symlink).
Could there be a mismatch between Clang (-mno-outline-atomics) and GCC (-moutline-atomics)?
I think you have to instruct Clang to use libgcc instead of compiler-rt and link the objects with GCC. Here is the documentation of Clang about the runtime I could find:
https://clang.llvm.org/docs/Toolchain.html#libgcc-s-gnu
Re: [PATCH v2 4/8] configure: Disable out-of-line atomic operations on Aarch64
Quoted 55 lines · Akihiko Odaki
Quoted 54 lines · Philippe Mathieu-Daudé
Quoted 41 lines · Richard Henderson
Quoted 40 lines · Philippe Mathieu-Daudé via
GCC 10.1 introduced the -moutline-atomics option on Aarch64. This options is enabled by default, and triggers a link failure:
Undefined symbols for architecture arm64:
"___aarch64_cas1_acq_rel", referenced from:
_qmp_migrate_recoverin migration_migration.c.o_cpu_atomic_cmpxchgb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_fetch_sminb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_fetch_uminb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_fetch_smaxb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_fetch_umaxb_mmuin accel_tcg_cputlb.c.o_cpu_atomic_smin_fetchb_mmuin accel_tcg_cputlb.c.o
...
"___aarch64_ldadd4_acq_rel", referenced from:
_multifd_recv_new_channelin migration_multifd.c.o_monitor_eventin monitor_hmp.c.o_handle_hmp_commandin monitor_hmp.c.o_colo_compare_finalizein net_colo-compare.c.o_flatview_unrefin softmmu_memory.c.o_virtio_scsi_hotunplugin hw_scsi_virtio-scsi.c.o_tcg_register_threadin tcg_tcg.c.o
...
"___aarch64_swp4_acq", referenced from:
_qemu_spin_lockin softmmu_cpu-timers.c.o_cpu_get_ticksin softmmu_cpu-timers.c.o_qemu_spin_lockin softmmu_icount.c.o_cpu_execin accel_tcg_cpu-exec.c.o _page_flush_tb_1.isra.0 in accel_tcg_translate-all.c.o_page_entry_lockin accel_tcg_translate-all.c.o_do_tb_phys_invalidatein accel_tcg_translate-all.c.o
...QEMU implements its own atomic operations using C11 builtin helpers. Disable the GCC out-of-line atomic ops.
Signed-off-by Philippe Mathieu-Daudé<[email protected]>---
Cc: Stefan Hajnoczi<[email protected]>
Cc: Paolo Bonzini<[email protected]>Quoted 7 lines
Quoted 5 lines
Clearly out of my understanding, but at least it links and the qtests pass.
---
configure | 12 ++++++++++++1 file changed, 12 insertions(+)These should have been supplied by libgcc.a, which we're supposed to be linking against. Something is wrong with your installation.
I don't have gobjc/g++ installed, so ./configure defaulted to Clang to compile these languages, but compiled C files using GCC. At the end the Clang linker is used (the default c++ symlink).
Quoted 5 lines
Quoted 2 lines
Could there be a mismatch between Clang (-mno-outline-atomics) and GCC (-moutline-atomics)?
I think you have to instruct Clang to use libgcc instead of compiler-rt and link the objects with GCC. Here is the documentation of Clang about the runtime I could find:
https://clang.llvm.org/docs/Toolchain.html#libgcc-s-gnu
Thanks for the pointer. And the next section is
https://clang.llvm.org/docs/Toolchain.html#atomics-library :)
Clang does not currently automatically link against libatomic when
using libgcc_s. You may need to manually add -latomic to support
this configuration when using non-native atomic operations (if you see link errors referring to __atomic_* functions).
I'll try that.
Re: [PATCH v2 4/8] configure: Disable out-of-line atomic operations on Aarch64
Quoted 7 lines · Philippe Mathieu-Daudé
Thanks for the pointer. And the next section is
https://clang.llvm.org/docs/Toolchain.html#atomics-library :)Clang does not currently automatically link against libatomic when
usinglibgcc_s. You may need to manually add -latomic to support
this configuration when using non-native atomic operations (if you see link errors referring to __atomic_* functions).
We deliberately don't link against libatomic at the moment...
-- PMM
Re: [PATCH v2 4/8] configure: Disable out-of-line atomic operations on Aarch64
In reply to Philippe Mathieu-Daudé viaQuoted 8 lines · Philippe Mathieu-Daudé
Quoted 7 lines · Akihiko Odaki
Quoted 6 lines · Philippe Mathieu-Daudé
Quoted 1 line · Richard Henderson
These should have been supplied by libgcc.a, which we're supposed to be linking against. Something is wrong with your installation.
I don't have gobjc/g++ installed, so ./configure defaulted to Clang to compile these languages, but compiled C files using GCC. At the end the Clang linker is used (the default c++ symlink).
This is another form of compiler mis-configuration.
If you don't have g++ to go with gcc, use --cxx=false to avoid picking up a different compiler.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Could there be a mismatch between Clang (-mno-outline-atomics) and GCC (-moutline-atomics)?
I have no idea if those options do the same thing.
Quoted 6 lines
Quoted 2 lines
I think you have to instruct Clang to use libgcc instead of compiler-rt and link the objects with GCC. Here is the documentation of Clang about the runtime I could find:
https://clang.llvm.org/docs/Toolchain.html#libgcc-s-gnuThanks for the pointer. And the next section is
https://clang.llvm.org/docs/Toolchain.html#atomics-library :)
Quoted 6 lines
Clang does not currently automatically link against libatomic when using
libgcc_s. You may need to manually add -latomic to support this configuration when using non-native atomic operations (if you see link errors referring to __atomic_* functions).I'll try that.
-moutline-atomics is *not* the same as libatomic.
You should not need libatomic at all.
r~
Re: [PATCH v2 4/8] configure: Disable out-of-line atomic operations on Aarch64
Quoted 7 lines · Richard Henderson
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
I don't have gobjc/g++ installed, so ./configure defaulted to Clang to compile these languages, but compiled C files using GCC. At the end the Clang linker is used (the default c++ symlink).
This is another form of compiler mis-configuration.
If you don't have g++ to go with gcc, use --cxx=false to avoid picking up a different compiler.
This would be the kind of problem that this test is trying to cover:
if do_cxx $CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
# C++ compiler $cxx works ok with C compiler $cc
:
else
echo "C++ compiler $cxx does not work with C compiler $cc"
echo "Disabling C++ specific optional code"
cxx=
fi
In the past it detected issues with libasan/libtsan incompatibilities. We should either add a test for atomic operations, or just drop the test.
Paolo
Re: [PATCH v2 4/8] configure: Disable out-of-line atomic operations on Aarch64
Quoted 21 lines · Paolo Bonzini
Quoted 7 lines · Richard Henderson
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
I don't have gobjc/g++ installed, so ./configure defaulted to Clang to compile these languages, but compiled C files using GCC. At the end the Clang linker is used (the default c++ symlink).
This is another form of compiler mis-configuration.
If you don't have g++ to go with gcc, use --cxx=false to avoid picking up a different compiler.This would be the kind of problem that this test is trying to cover:
if
do_cxx$CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS
$QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
# C++ compiler $cxx works ok with C compiler $cc :
else
echo "C++ compiler $cxx does not work with C compiler $cc" echo "Disabling C++ specific optional code" cxx=
fi
Quoted 3 lines
In the past it detected issues with libasan/libtsan incompatibilities. We should either add a test for atomic operations, or just drop the test.
We shouldn't assume gcc is GCC:
$ c++ --version Apple clang version 13.0.0 (clang-1300.0.29.30) Target: arm64-apple-darwin21.3.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ g++ --version Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1 Apple clang version 13.0.0 (clang-1300.0.29.30) Target: arm64-apple-darwin21.3.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ gcc --version Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1 Apple clang version 13.0.0 (clang-1300.0.29.30) Target: arm64-apple-darwin21.3.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ clang --version Apple clang version 13.0.0 (clang-1300.0.29.30) Target: arm64-apple-darwin21.3.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Re: [PATCH v2 4/8] configure: Disable out-of-line atomic operations on Aarch64
In reply to Philippe Mathieu-Daudé viaconfigure else · line 2838
Quoted 8 lines · Philippe Mathieu-Daudé via
configure +8
-0+ +case "$cpu" in + aarch64) + write_c_skeleton; + if compile_prog "$CPU_CFLAGS -Werror -mno-outline-atomics" "" ; then + CPU_CFLAGS="-mno-outline-atomics $CPU_CFLAGS" + fi + ;;
Apart from the question of whether/how to work around this issue, this should not be added to CPU_CFLAGS. CPU_CFLAGS is only for things that change the ABI.
Paolo
PATCH v2 5/8 meson: Log QEMU_CXXFLAGS content in summary
In reply to Philippe Mathieu-Daudé via--- meson.build | 1 + 1 file changed, 1 insertion(+)
meson.build +1 -0
@@ -3305,6 +3305,7 @@ if link_args.length() > 0 summary_info += {'LDFLAGS': ' '.join(link_args)} endif summary_info += {'QEMU_CFLAGS': config_host['QEMU_CFLAGS']} +summary_info += {'QEMU_CXXFLAGS': config_host['QEMU_CXXFLAGS']} summary_info += {'QEMU_LDFLAGS': config_host['QEMU_LDFLAGS']} summary_info += {'profiler': config_host.has_key('CONFIG_PROFILER')} summary_info += {'link-time optimization (LTO)': get_option('b_lto')}
Signature · 1 line
2.34.1
PATCH v2 6/8 configure: Pass filtered QEMU_OBJCFLAGS to meson
In reply to Philippe Mathieu-Daudé viaFilter unsupported Objective-C options, to avoid 'unknown-warning-option' warnings when using Clang:
[34/373] Compiling Objective-C object libcommon.fa.p/audio_coreaudio.m.o
warning: unknown warning option '-Wold-style-declaration'; did you mean '-Wout-of-line-declaration'? [-Wunknown-warning-option]
warning: unknown warning option '-Wimplicit-fallthrough=2'; did you mean '-Wimplicit-fallthrough'? [-Wunknown-warning-option] 2 warnings generated.
--- configure | 23 +++++++++++++++++++++++ meson.build | 5 ++++- 2 files changed, 27 insertions(+), 1 deletion(-)
configure +23 -0
@@ -77,6 +77,7 @@ TMPB="qemu-conf" TMPC="${TMPDIR1}/${TMPB}.c" TMPO="${TMPDIR1}/${TMPB}.o" TMPCXX="${TMPDIR1}/${TMPB}.cxx" +TMPM="${TMPDIR1}/${TMPB}.m" TMPE="${TMPDIR1}/${TMPB}.exe" rm -f config.log
@@ -148,6 +149,10 @@ do_cxx() { do_compiler "$cxx" $CPU_CFLAGS "$@" } +do_objc() { + do_compiler "$objcc" $CPU_CFLAGS "$@" +} + # Append $2 to the variable named $1, with space separation add_to() { eval $1=\${$1:+\"\$$1 \"}\$2
@@ -1616,10 +1621,27 @@ cc_has_warning_flag() { compile_prog "-Werror $optflag" "" } +objcc_has_warning_flag() { + cat > $TMPM <<EOF +int main(void) { return 0; } +EOF + + # Use the positive sense of the flag when testing for -Wno-wombat + # support (gcc will happily accept the -Wno- form of unknown + # warning options). + optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" + do_objc -Werror $optflag \ + $OBJCFLAGS $EXTRA_OBJCFLAGS $CONFIGURE_OBJCFLAGS $QEMU_OBJCFLAGS \ + -o $TMPE $TMPM $QEMU_LDFLAGS +} + for flag in $gcc_flags; do if cc_has_warning_flag $flag ; then QEMU_CFLAGS="$QEMU_CFLAGS $flag" fi + if objcc_has_warning_flag $flag ; then + QEMU_OBJCFLAGS="$QEMU_OBJCFLAGS $flag" + fi done if test "$stack_protector" != "no"; then
@@ -3579,6 +3601,7 @@ echo "LD=$ld" >> $config_host_mak echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak +echo "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak echo "GLIB_LIBS=$glib_libs" >> $config_host_mak echo "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak
meson.build +4 -1
@@ -199,9 +199,11 @@ if get_option('fuzzing') endif add_global_arguments(config_host['QEMU_CFLAGS'].split(), - native: false, language: ['c', 'objc']) + native: false, language: ['c']) add_global_arguments(config_host['QEMU_CXXFLAGS'].split(), native: false, language: 'cpp') +add_global_arguments(config_host['QEMU_OBJCFLAGS'].split(), + native: false, language: ['objc']) add_global_link_arguments(config_host['QEMU_LDFLAGS'].split(), native: false, language: ['c', 'cpp', 'objc'])
@@ -3306,6 +3308,7 @@ if link_args.length() > 0 endif summary_info += {'QEMU_CFLAGS': config_host['QEMU_CFLAGS']} summary_info += {'QEMU_CXXFLAGS': config_host['QEMU_CXXFLAGS']} +summary_info += {'QEMU_OBJCFLAGS': config_host['QEMU_OBJCFLAGS']} summary_info += {'QEMU_LDFLAGS': config_host['QEMU_LDFLAGS']} summary_info += {'profiler': config_host.has_key('CONFIG_PROFILER')} summary_info += {'link-time optimization (LTO)': get_option('b_lto')}
Signature · 1 line
2.34.1
Re: [PATCH v2 6/8] configure: Pass filtered QEMU_OBJCFLAGS to meson
Quoted 9 lines · Philippe Mathieu-Daudé via
Filter unsupported Objective-C options, to avoid 'unknown-warning-option' warnings when using Clang:
[34/373] Compiling Objective-C object
libcommon.fa.p/audio_coreaudio.m.o
warning: unknown warning option '-Wold-style-declaration'; did you mean '-Wout-of-line-declaration'? [-Wunknown-warning-option]
warning: unknown warning option '-Wimplicit-fallthrough=2'; did you mean '-Wimplicit-fallthrough'? [-Wunknown-warning-option] 2 warnings generated.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 89 lines
--- configure | 23 +++++++++++++++++++++++ meson.build | 5 ++++- 2 files changed, 27 insertions(+), 1 deletion(-)configure +23
-0@@ -77,6 +77,7 @@ TMPB="qemu-conf" TMPC="${TMPDIR1}/${TMPB}.c" TMPO="${TMPDIR1}/${TMPB}.o" TMPCXX="${TMPDIR1}/${TMPB}.cxx" +TMPM="${TMPDIR1}/${TMPB}.m" TMPE="${TMPDIR1}/${TMPB}.exe" rm -f config.log@@ -148,6 +149,10 @@ do_cxx() { do_compiler "$cxx" $CPU_CFLAGS "$@" } +do_objc() { + do_compiler "$objcc" $CPU_CFLAGS "$@" +} + # Append $2 to the variable named $1, with space separation add_to() { eval $1=\${$1:+\"\$$1 \"}\$2@@ -1616,10 +1621,27 @@ cc_has_warning_flag() { compile_prog "-Werror $optflag" "" } +objcc_has_warning_flag() { + cat > $TMPM <<EOF +int main(void) { return 0; } +EOF + + # Use the positive sense of the flag when testing for -Wno-wombat + # support (gcc will happily accept the -Wno- form of unknown + # warning options). + optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" + do_objc -Werror $optflag \ + $OBJCFLAGS $EXTRA_OBJCFLAGS $CONFIGURE_OBJCFLAGS $QEMU_OBJCFLAGS \ + -o $TMPE $TMPM $QEMU_LDFLAGS +} + for flag in $gcc_flags; do if cc_has_warning_flag $flag ; then QEMU_CFLAGS="$QEMU_CFLAGS $flag" fi + if objcc_has_warning_flag $flag ; then + QEMU_OBJCFLAGS="$QEMU_OBJCFLAGS $flag" + fi done if test "$stack_protector" != "no"; then@@ -3579,6 +3601,7 @@ echo "LD=$ld" >> $config_host_mak echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak +echo "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak echo "GLIB_LIBS=$glib_libs" >> $config_host_mak echo "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_makmeson.build +4
-1@@ -199,9 +199,11 @@ if get_option('fuzzing') endif add_global_arguments(config_host['QEMU_CFLAGS'].split(), - native: false, language: ['c', 'objc']) + native: false, language: ['c']) add_global_arguments(config_host['QEMU_CXXFLAGS'].split(), native: false, language: 'cpp') +add_global_arguments(config_host['QEMU_OBJCFLAGS'].split(), + native: false, language: ['objc']) add_global_link_arguments(config_host['QEMU_LDFLAGS'].split(), native: false, language: ['c', 'cpp', 'objc'])@@ -3306,6 +3308,7 @@ if link_args.length() > 0 endif summary_info += {'QEMU_CFLAGS': config_host['QEMU_CFLAGS']} summary_info += {'QEMU_CXXFLAGS': config_host['QEMU_CXXFLAGS']} +summary_info += {'QEMU_OBJCFLAGS': config_host['QEMU_OBJCFLAGS']} summary_info += {'QEMU_LDFLAGS': config_host['QEMU_LDFLAGS']} summary_info += {'profiler': config_host.has_key('CONFIG_PROFILER')} summary_info += {'link-time optimization (LTO)': get_option('b_lto')}
PATCH v2 7/8 audio: Rename coreaudio extension to use Objective-C compiler
In reply to Philippe Mathieu-Daudé viaThe coreaudio library includes Objective-C declarations (using the caret '^' symbol to declare block references [*]). When building with a C compiler we get:
[175/839] Compiling C object libcommon.fa.p/audio_coreaudio.c.o
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/CoreAudio.h:18,
from ../../audio/coreaudio.c:26:
/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardware.h:162:2: error: expected identifier or '(' before '^' token
162 | (^AudioObjectPropertyListenerBlock)( UInt32 inNumberAddresses,
| ^
FAILED: libcommon.fa.p/audio_coreaudio.c.o
Rename the file to use the Objective-C default extension (.m) so meson calls the correct compiler.
---
audio/{coreaudio.c => coreaudio.m} | 0
audio/meson.build | 2 +-
2 files changed, 1 insertion(+), 1 deletion(-)
rename audio/{coreaudio.c => coreaudio.m} (100%)audio/coreaudio.m renamed from audio/coreaudio.c +0 -0
audio/meson.build +1 -1
@@ -7,7 +7,7 @@ softmmu_ss.add(files( 'wavcapture.c', )) -softmmu_ss.add(when: coreaudio, if_true: files('coreaudio.c')) +softmmu_ss.add(when: coreaudio, if_true: files('coreaudio.m')) softmmu_ss.add(when: dsound, if_true: files('dsoundaudio.c', 'audio_win_int.c')) audio_modules = {}
Signature · 1 line
2.34.1
PATCH v2 8/8 ui/cocoa: Constify qkeycode translation arrays
In reply to Philippe Mathieu-Daudé via--- ui/cocoa.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
ui/cocoa.m +2 -2
@@ -651,7 +651,7 @@ QemuCocoaView *cocoaView; /* translates Macintosh keycodes to QEMU's keysym */ - int without_control_translation[] = { + static const int without_control_translation[] = { [0 ... 0xff] = 0, // invalid key [kVK_UpArrow] = QEMU_KEY_UP,
@@ -666,7 +666,7 @@ QemuCocoaView *cocoaView; [kVK_Delete] = QEMU_KEY_BACKSPACE, }; - int with_control_translation[] = { + static const int with_control_translation[] = { [0 ... 0xff] = 0, // invalid key [kVK_UpArrow] = QEMU_KEY_CTRL_UP,
Signature · 1 line
2.34.1