* [PATCH v2] meson.build: add -mcx16 flag for x86_64 host
@ 2024-05-23 5:11 Artyom Kunakovsky
2024-05-23 8:45 ` Daniel P. Berrangé
0 siblings, 1 reply; 3+ messages in thread
From: Artyom Kunakovsky @ 2024-05-23 5:11 UTC (permalink / raw)
To: qemu-devel; +Cc: Artyom Kunakovsky
Fix linker error if the project was configured by the './configure --cpu=unknown --target-list=riscv64-softmmu' command
Signed-off-by: Artyom Kunakovsky <artyomkunakovsky@gmail.com>
---
meson.build | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/meson.build b/meson.build
index a9de71d450..e68fbfc662 100644
--- a/meson.build
+++ b/meson.build
@@ -336,6 +336,12 @@ if host_arch == 'i386' and not cc.links('''
qemu_common_flags = ['-march=i486'] + qemu_common_flags
endif
+
+if host_arch == 'x86_64'
+ qemu_common_flags = ['-mcx16'] + qemu_common_flags
+endif
+
+
if get_option('prefer_static')
qemu_ldflags += get_option('b_pie') ? '-static-pie' : '-static'
endif
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] meson.build: add -mcx16 flag for x86_64 host
2024-05-23 5:11 [PATCH v2] meson.build: add -mcx16 flag for x86_64 host Artyom Kunakovsky
@ 2024-05-23 8:45 ` Daniel P. Berrangé
2024-05-24 7:15 ` Paolo Bonzini
0 siblings, 1 reply; 3+ messages in thread
From: Daniel P. Berrangé @ 2024-05-23 8:45 UTC (permalink / raw)
To: Artyom Kunakovsky; +Cc: qemu-devel
On Thu, May 23, 2024 at 08:11:18AM +0300, Artyom Kunakovsky wrote:
> Fix linker error if the project was configured by the './configure --cpu=unknown --target-list=riscv64-softmmu' command
As with v1, why are you intentionally passing a bogus CPU target
name to the --cpu arg ? QEMU already correctly sets '-mcx16' if
you omit --cpu, or pass a correct "x86_64" target name to --cpu.
>
> Signed-off-by: Artyom Kunakovsky <artyomkunakovsky@gmail.com>
> ---
> meson.build | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/meson.build b/meson.build
> index a9de71d450..e68fbfc662 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -336,6 +336,12 @@ if host_arch == 'i386' and not cc.links('''
> qemu_common_flags = ['-march=i486'] + qemu_common_flags
> endif
>
> +
> +if host_arch == 'x86_64'
> + qemu_common_flags = ['-mcx16'] + qemu_common_flags
> +endif
> +
> +
> if get_option('prefer_static')
> qemu_ldflags += get_option('b_pie') ? '-static-pie' : '-static'
> endif
> --
> 2.25.1
>
>
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] meson.build: add -mcx16 flag for x86_64 host
2024-05-23 8:45 ` Daniel P. Berrangé
@ 2024-05-24 7:15 ` Paolo Bonzini
0 siblings, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2024-05-24 7:15 UTC (permalink / raw)
To: Daniel P. Berrangé, Artyom Kunakovsky; +Cc: qemu-devel
On 5/23/24 10:45, Daniel P. Berrangé wrote:
> On Thu, May 23, 2024 at 08:11:18AM +0300, Artyom Kunakovsky wrote:
>> Fix linker error if the project was configured by the './configure --cpu=unknown --target-list=riscv64-softmmu' command
>
> As with v1, why are you intentionally passing a bogus CPU target
> name to the --cpu arg ? QEMU already correctly sets '-mcx16' if
> you omit --cpu, or pass a correct "x86_64" target name to --cpu.
The patch has a point though, in that right above we have another test
to add -march=i486. It's just that we do that one conditionally,
because most of the time the compiler will already apply the less-
restrictive -march=i686.
The point of CPU_CFLAGS is really just to select the appropriate
multilib, for example for library linking tests, and -mcx16 is not
needed for that purpose. And -mcx16 is not applied to cross-compiled
x86_64 code too, so why is it even in configure.
This is not to say that passing --cpu=unknown is a good idea; the
reason that Artyom gives is not really compelling. But I think
I am going to apply it as a cleanup together with the matching
change to configure:
--------------- 8< -----------------
From: Artyom Kunakovsky <artyomkunakovsky@gmail.com>
Subject: [PATCH] configure: move -mcx16 flag out of CPU_CFLAGS
The point of CPU_CFLAGS is really just to select the appropriate multilib,
for example for library linking tests, and -mcx16 is not needed for
that purpose.
Furthermore, if -mcx16 is part of QEMU's choice of a basic x86_64
instruction set, it should be applied to cross-compiled x86_64 code too;
it is plausible that tests/tcg would want to cover cmpxchg16b as well,
for example. In the end this makes just as much sense as a per sub-build
tweak, so move the flag to meson.build and cross_cc_cflags_x86_64.
This leaves out contrib/plugins, which would fail when attempting to use
__sync_val_compare_and_swap_16 (note it does not do yet); while minor,
this *is* a disadvantage of this change. But building contrib/plugins
with a Makefile instead of meson.build is something self-inflicted just
for the sake of showing that it can be done, and if this kind of papercut
started becoming a problem we could make the directory part of the meson
build. Until then, we can live with the limitation.
Signed-off-by: Artyom Kunakovsky <artyomkunakovsky@gmail.com>
Message-ID: <20240523051118.29367-1-artyomkunakovsky@gmail.com>
[rewrite commit message, remove from configure. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
diff --git a/configure b/configure
index 38ee2577013..4d01a42ba65 100755
--- a/configure
+++ b/configure
@@ -512,10 +512,7 @@ case "$cpu" in
cpu="x86_64"
host_arch=x86_64
linux_arch=x86
- # ??? Only extremely old AMD cpus do not have cmpxchg16b.
- # If we truly care, we should simply detect this case at
- # runtime and generate the fallback to serial emulation.
- CPU_CFLAGS="-m64 -mcx16"
+ CPU_CFLAGS="-m64"
;;
esac
@@ -1203,7 +1200,7 @@ fi
: ${cross_cc_cflags_sparc64="-m64 -mcpu=ultrasparc"}
: ${cross_cc_sparc="$cross_cc_sparc64"}
: ${cross_cc_cflags_sparc="-m32 -mcpu=supersparc"}
-: ${cross_cc_cflags_x86_64="-m64"}
+: ${cross_cc_cflags_x86_64="-m64 -mcx16"}
compute_target_variable() {
eval "$2="
diff --git a/meson.build b/meson.build
index a9de71d4506..7fd82b5f48c 100644
--- a/meson.build
+++ b/meson.build
@@ -336,6 +336,13 @@ if host_arch == 'i386' and not cc.links('''
qemu_common_flags = ['-march=i486'] + qemu_common_flags
endif
+# ??? Only extremely old AMD cpus do not have cmpxchg16b.
+# If we truly care, we should simply detect this case at
+# runtime and generate the fallback to serial emulation.
+if host_arch == 'x86_64'
+ qemu_common_flags = ['-mcx16'] + qemu_common_flags
+endif
+
if get_option('prefer_static')
qemu_ldflags += get_option('b_pie') ? '-static-pie' : '-static'
endif
>>
>> Signed-off-by: Artyom Kunakovsky <artyomkunakovsky@gmail.com>
>> ---
>> meson.build | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/meson.build b/meson.build
>> index a9de71d450..e68fbfc662 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -336,6 +336,12 @@ if host_arch == 'i386' and not cc.links('''
>> qemu_common_flags = ['-march=i486'] + qemu_common_flags
>> endif
>>
>> +
>> +if host_arch == 'x86_64'
>> + qemu_common_flags = ['-mcx16'] + qemu_common_flags
>> +endif
>> +
>> +
>> if get_option('prefer_static')
>> qemu_ldflags += get_option('b_pie') ? '-static-pie' : '-static'
>> endif
>> --
>> 2.25.1
>>
>>
>
> With regards,
> Daniel
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-24 7:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-23 5:11 [PATCH v2] meson.build: add -mcx16 flag for x86_64 host Artyom Kunakovsky
2024-05-23 8:45 ` Daniel P. Berrangé
2024-05-24 7:15 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).