Create a separate variable for compiler flags that enable
specific instruction set extensions, so that they can be used with
cc.compiles/cc.links.
Note that -mfpmath=sse is a code generation option but it does not
enable new instructions, therefore I did not make it part of
qemu_isa_flags.
Suggested-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
meson.build | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/meson.build b/meson.build
index 76335bb2a51..bbb0f6d9bcf 100644
--- a/meson.build
+++ b/meson.build
@@ -335,6 +335,10 @@ elif host_os == 'windows'
endif
endif
+# Choose instruction set (currently x86-only)
+
+qemu_isa_flags = []
+
# __sync_fetch_and_and requires at least -march=i486. Many toolchains
# use i686 as default anyway, but for those that don't, an explicit
# specification is necessary
@@ -351,7 +355,7 @@ if host_arch == 'i386' and not cc.links('''
sfaa(&val);
return val;
}''')
- qemu_common_flags = ['-march=i486'] + qemu_common_flags
+ qemu_isa_flags = ['-march=i486']
endif
# Pick x86-64 baseline version
@@ -367,29 +371,31 @@ if host_arch in ['i386', 'x86_64']
else
# present on basically all processors but technically not part of
# x86-64-v1, so only include -mneeded for x86-64 version 2 and above
- qemu_common_flags = ['-mcx16'] + qemu_common_flags
+ qemu_isa_flags = ['-mcx16'] + qemu_isa_flags
endif
endif
if get_option('x86_version') >= '2'
- qemu_common_flags = ['-mpopcnt'] + qemu_common_flags
- qemu_common_flags = cc.get_supported_arguments('-mneeded') + qemu_common_flags
+ qemu_isa_flags = ['-mpopcnt'] + qemu_isa_flags
+ qemu_isa_flags = cc.get_supported_arguments('-mneeded') + qemu_isa_flags
endif
if get_option('x86_version') >= '3'
- qemu_common_flags = ['-mmovbe', '-mabm', '-mbmi', '-mbmi2', '-mfma', '-mf16c'] + qemu_common_flags
+ qemu_isa_flags = ['-mmovbe', '-mabm', '-mbmi', '-mbmi2', '-mfma', '-mf16c'] + qemu_isa_flags
endif
# add required vector instruction set (each level implies those below)
if get_option('x86_version') == '1'
- qemu_common_flags = ['-msse2'] + qemu_common_flags
+ qemu_isa_flags = ['-msse2'] + qemu_isa_flags
elif get_option('x86_version') == '2'
- qemu_common_flags = ['-msse4.2'] + qemu_common_flags
+ qemu_isa_flags = ['-msse4.2'] + qemu_isa_flags
elif get_option('x86_version') == '3'
- qemu_common_flags = ['-mavx2'] + qemu_common_flags
+ qemu_isa_flags = ['-mavx2'] + qemu_isa_flags
elif get_option('x86_version') == '4'
- qemu_common_flags = ['-mavx512f', '-mavx512bw', '-mavx512cd', '-mavx512dq', '-mavx512vl'] + qemu_common_flags
+ qemu_isa_flags = ['-mavx512f', '-mavx512bw', '-mavx512cd', '-mavx512dq', '-mavx512vl'] + qemu_isa_flags
endif
endif
+qemu_common_flags = qemu_isa_flags + qemu_common_flags
+
if get_option('prefer_static')
qemu_ldflags += get_option('b_pie') ? '-static-pie' : '-static'
endif
--
2.46.1
On 10/7/24 01:43, Paolo Bonzini wrote: > Create a separate variable for compiler flags that enable > specific instruction set extensions, so that they can be used with > cc.compiles/cc.links. > > Note that -mfpmath=sse is a code generation option but it does not > enable new instructions, therefore I did not make it part of > qemu_isa_flags. > > Suggested-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> > Cc: qemu-stable@nongnu.org > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> > --- > meson.build | 24 +++++++++++++++--------- > 1 file changed, 15 insertions(+), 9 deletions(-) > > diff --git a/meson.build b/meson.build > index 76335bb2a51..bbb0f6d9bcf 100644 > --- a/meson.build > +++ b/meson.build > @@ -335,6 +335,10 @@ elif host_os == 'windows' > endif > endif > > +# Choose instruction set (currently x86-only) > + > +qemu_isa_flags = [] > + > # __sync_fetch_and_and requires at least -march=i486. Many toolchains > # use i686 as default anyway, but for those that don't, an explicit > # specification is necessary > @@ -351,7 +355,7 @@ if host_arch == 'i386' and not cc.links(''' > sfaa(&val); > return val; > }''') > - qemu_common_flags = ['-march=i486'] + qemu_common_flags > + qemu_isa_flags = ['-march=i486'] Use += ? > - qemu_common_flags = ['-mcx16'] + qemu_common_flags > + qemu_isa_flags = ['-mcx16'] + qemu_isa_flags Likewise, why verbosely prepend, rather than append with += ? The same for all others, including > +qemu_common_flags = qemu_isa_flags + qemu_common_flags r~
07.10.2024 17:46, Richard Henderson пишет: > On 10/7/24 01:43, Paolo Bonzini wrote: >> Create a separate variable for compiler flags that enable >> specific instruction set extensions, so that they can be used with >> cc.compiles/cc.links. >> >> Note that -mfpmath=sse is a code generation option but it does not >> enable new instructions, therefore I did not make it part of >> qemu_isa_flags. >> >> Suggested-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> >> Cc: qemu-stable@nongnu.org >> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> >> --- >> meson.build | 24 +++++++++++++++--------- >> 1 file changed, 15 insertions(+), 9 deletions(-) >> >> diff --git a/meson.build b/meson.build >> index 76335bb2a51..bbb0f6d9bcf 100644 >> --- a/meson.build >> +++ b/meson.build >> @@ -335,6 +335,10 @@ elif host_os == 'windows' >> endif >> endif >> +# Choose instruction set (currently x86-only) >> + >> +qemu_isa_flags = [] >> + >> # __sync_fetch_and_and requires at least -march=i486. Many toolchains >> # use i686 as default anyway, but for those that don't, an explicit >> # specification is necessary >> @@ -351,7 +355,7 @@ if host_arch == 'i386' and not cc.links(''' >> sfaa(&val); >> return val; >> }''') >> - qemu_common_flags = ['-march=i486'] + qemu_common_flags >> + qemu_isa_flags = ['-march=i486'] > > Use += ? Yes, it is better to use += here - when reviewing the patch this is obvious qemu_isa_flags is empty at this point, but it wont be as obvious in the actual code when initial assignment is quite far away from this prepending. >> - qemu_common_flags = ['-mcx16'] + qemu_common_flags >> + qemu_isa_flags = ['-mcx16'] + qemu_isa_flags > > Likewise, why verbosely prepend, rather than append with += ? > The same for all others, including > >> +qemu_common_flags = qemu_isa_flags + qemu_common_flags I'd keep prepending here (but not in qemu_isa_flags above) because this way it is possible to override some flags by the user. /mjt
On Mon, Oct 7, 2024 at 4:46 PM Richard Henderson <richard.henderson@linaro.org> wrote: > > - qemu_common_flags = ['-march=i486'] + qemu_common_flags > > + qemu_isa_flags = ['-march=i486'] > > Use += ? Here the qemu_isa_flags are known to be empty. > > - qemu_common_flags = ['-mcx16'] + qemu_common_flags > > + qemu_isa_flags = ['-mcx16'] + qemu_isa_flags > > Likewise, why verbosely prepend, rather than append with += ? > The same for all others, including > > > +qemu_common_flags = qemu_isa_flags + qemu_common_flags The prepending behavior came from CPU_CFLAGS originally being before all other compiler flags. I just didn't want to change behavior here (especially since this patch was already about subtle changes in behavior). But you're right that at least within qemu_isa_flags the order should not matter. Paolo
On 10/7/24 07:48, Paolo Bonzini wrote: > On Mon, Oct 7, 2024 at 4:46 PM Richard Henderson > <richard.henderson@linaro.org> wrote: >>> - qemu_common_flags = ['-march=i486'] + qemu_common_flags >>> + qemu_isa_flags = ['-march=i486'] >> >> Use += ? > > Here the qemu_isa_flags are known to be empty. ... until we add something else beforehand and fail to update. Surely it's easier to assume that it's not empty. > I just didn't want to change behavior here (especially since this > patch was already about subtle changes in behavior). But you're right > that at least within qemu_isa_flags the order should not matter. Fair enough. r~
© 2016 - 2024 Red Hat, Inc.