All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v3 0/2] AVX2 configure fixes
@ 2016-06-10 11:16 Dr. David Alan Gilbert (git)
  2016-06-10 11:16 ` [Qemu-devel] [PATCH v3 1/2] Make avx2 configure test work with -O2 Dr. David Alan Gilbert (git)
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-06-10 11:16 UTC (permalink / raw)
  To: qemu-devel, pbonzini, peter.maydell; +Cc: liang.z.li, amit.shah, quintela

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Hi,
  This pair of patches fixes a couple of issues that we found during test.
The first is that the configure test is pessimistic when compiled with -O2,
the second is that the explicit 4.9 gcc test is a bit coarse; I've removed
that test but beefed up the ./configure test to actually use the avx2
intrinsics and that fails in the same way as the main code, so it works
in the same way as the explicit check but allows older gcc's to work
when -save-temps isn't used.

Dave

v3
  Use compile_object rather than compile_prog as suggested by Peter to
  hopefully fail on his ccache setup.

v2
  Remove the explicit version check
  Split the patches


Dr. David Alan Gilbert (2):
  Make avx2 configure test work with -O2
  avx2 configure: Use primitives in test

 configure     | 17 ++++++++++++-----
 util/cutils.c |  8 +-------
 2 files changed, 13 insertions(+), 12 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH v3 1/2] Make avx2 configure test work with -O2
  2016-06-10 11:16 [Qemu-devel] [PATCH v3 0/2] AVX2 configure fixes Dr. David Alan Gilbert (git)
@ 2016-06-10 11:16 ` Dr. David Alan Gilbert (git)
  2016-06-10 11:16 ` [Qemu-devel] [PATCH v3 2/2] avx2 configure: Use primitives in test Dr. David Alan Gilbert (git)
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 19+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-06-10 11:16 UTC (permalink / raw)
  To: qemu-devel, pbonzini, peter.maydell; +Cc: liang.z.li, amit.shah, quintela

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

When configured with --extra-cflags=-O2 gcc optimised out the test
and the readelf failed the check leaving avx2 disabled.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 8c2f90b..ffa5b62 100755
--- a/configure
+++ b/configure
@@ -1784,7 +1784,7 @@ fi
 cat > $TMPC << EOF
 static void bar(void) {}
 static void *bar_ifunc(void) {return (void*) bar;}
-static void foo(void) __attribute__((ifunc("bar_ifunc")));
+void foo(void) __attribute__((ifunc("bar_ifunc")));
 int main(void) { foo(); return 0; }
 EOF
 if compile_prog "-mavx2" "" ; then
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH v3 2/2] avx2 configure: Use primitives in test
  2016-06-10 11:16 [Qemu-devel] [PATCH v3 0/2] AVX2 configure fixes Dr. David Alan Gilbert (git)
  2016-06-10 11:16 ` [Qemu-devel] [PATCH v3 1/2] Make avx2 configure test work with -O2 Dr. David Alan Gilbert (git)
@ 2016-06-10 11:16 ` Dr. David Alan Gilbert (git)
  2016-07-14 13:13   ` Aaron Lindsay
  2016-06-13  9:31 ` [Qemu-devel] [PATCH v3 0/2] AVX2 configure fixes Paolo Bonzini
  2016-06-13 10:51 ` Peter Maydell
  3 siblings, 1 reply; 19+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-06-10 11:16 UTC (permalink / raw)
  To: qemu-devel, pbonzini, peter.maydell; +Cc: liang.z.li, amit.shah, quintela

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Use the avx2 primitives during the test, thus making sure that the
compiler and assembler could actually use avx2.

This also detects the failure case on gcc 4.8.x with -save-temps
and avoids the need for the gcc version check in cutils.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 configure     | 17 ++++++++++++-----
 util/cutils.c |  8 +-------
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/configure b/configure
index ffa5b62..3204785 100755
--- a/configure
+++ b/configure
@@ -1782,13 +1782,20 @@ fi
 # avx2 optimization requirement check
 
 cat > $TMPC << EOF
-static void bar(void) {}
+#pragma GCC push_options
+#pragma GCC target("avx2")
+#include <cpuid.h>
+#include <immintrin.h>
+
+static int bar(void *a) {
+    return _mm256_movemask_epi8(_mm256_cmpeq_epi8(*(__m256i *)a, (__m256i){0}));
+}
 static void *bar_ifunc(void) {return (void*) bar;}
-void foo(void) __attribute__((ifunc("bar_ifunc")));
-int main(void) { foo(); return 0; }
+int foo(void *a) __attribute__((ifunc("bar_ifunc")));
+int main(int argc, char *argv[]) { return foo(argv[0]);}
 EOF
-if compile_prog "-mavx2" "" ; then
-    if readelf --syms $TMPE |grep "IFUNC.*foo" >/dev/null 2>&1; then
+if compile_object "" ; then
+    if readelf --syms $TMPO |grep "IFUNC.*foo" >/dev/null 2>&1; then
         avx2_opt="yes"
     fi
 fi
diff --git a/util/cutils.c b/util/cutils.c
index 43d1afb..5830a68 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -256,13 +256,7 @@ static size_t buffer_find_nonzero_offset_inner(const void *buf, size_t len)
     return i * sizeof(VECTYPE);
 }
 
-/*
- * GCC before version 4.9 has a bug which will cause the target
- * attribute work incorrectly and failed to compile in some case,
- * restrict the gcc version to 4.9+ to prevent the failure.
- */
-
-#if defined CONFIG_AVX2_OPT && QEMU_GNUC_PREREQ(4, 9)
+#if defined CONFIG_AVX2_OPT
 #pragma GCC push_options
 #pragma GCC target("avx2")
 #include <cpuid.h>
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH v3 0/2] AVX2 configure fixes
  2016-06-10 11:16 [Qemu-devel] [PATCH v3 0/2] AVX2 configure fixes Dr. David Alan Gilbert (git)
  2016-06-10 11:16 ` [Qemu-devel] [PATCH v3 1/2] Make avx2 configure test work with -O2 Dr. David Alan Gilbert (git)
  2016-06-10 11:16 ` [Qemu-devel] [PATCH v3 2/2] avx2 configure: Use primitives in test Dr. David Alan Gilbert (git)
@ 2016-06-13  9:31 ` Paolo Bonzini
  2016-06-13 10:51 ` Peter Maydell
  3 siblings, 0 replies; 19+ messages in thread
From: Paolo Bonzini @ 2016-06-13  9:31 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git), qemu-devel, peter.maydell
  Cc: liang.z.li, amit.shah, quintela



On 10/06/2016 13:16, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> 
> Hi,
>   This pair of patches fixes a couple of issues that we found during test.
> The first is that the configure test is pessimistic when compiled with -O2,
> the second is that the explicit 4.9 gcc test is a bit coarse; I've removed
> that test but beefed up the ./configure test to actually use the avx2
> intrinsics and that fails in the same way as the main code, so it works
> in the same way as the explicit check but allows older gcc's to work
> when -save-temps isn't used.
> 
> Dave
> 
> v3
>   Use compile_object rather than compile_prog as suggested by Peter to
>   hopefully fail on his ccache setup.

Queued, thanks.

Paolo

> v2
>   Remove the explicit version check
>   Split the patches
> 
> 
> Dr. David Alan Gilbert (2):
>   Make avx2 configure test work with -O2
>   avx2 configure: Use primitives in test
> 
>  configure     | 17 ++++++++++++-----
>  util/cutils.c |  8 +-------
>  2 files changed, 13 insertions(+), 12 deletions(-)
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH v3 0/2] AVX2 configure fixes
  2016-06-10 11:16 [Qemu-devel] [PATCH v3 0/2] AVX2 configure fixes Dr. David Alan Gilbert (git)
                   ` (2 preceding siblings ...)
  2016-06-13  9:31 ` [Qemu-devel] [PATCH v3 0/2] AVX2 configure fixes Paolo Bonzini
@ 2016-06-13 10:51 ` Peter Maydell
  2016-06-13 10:58   ` Dr. David Alan Gilbert
  3 siblings, 1 reply; 19+ messages in thread
From: Peter Maydell @ 2016-06-13 10:51 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git)
  Cc: QEMU Developers, Paolo Bonzini, Liang Li, Amit Shah, Juan Quintela

On 10 June 2016 at 12:16, Dr. David Alan Gilbert (git)
<dgilbert@redhat.com> wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>
> Hi,
>   This pair of patches fixes a couple of issues that we found during test.
> The first is that the configure test is pessimistic when compiled with -O2,
> the second is that the explicit 4.9 gcc test is a bit coarse; I've removed
> that test but beefed up the ./configure test to actually use the avx2
> intrinsics and that fails in the same way as the main code, so it works
> in the same way as the explicit check but allows older gcc's to work
> when -save-temps isn't used.
>
> Dave
>
> v3
>   Use compile_object rather than compile_prog as suggested by Peter to
>   hopefully fail on his ccache setup.

I ran these patches through my build tests and it all compiled OK,
so the new configure test does correctly say "no AVX" on this setup.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH v3 0/2] AVX2 configure fixes
  2016-06-13 10:51 ` Peter Maydell
@ 2016-06-13 10:58   ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 19+ messages in thread
From: Dr. David Alan Gilbert @ 2016-06-13 10:58 UTC (permalink / raw)
  To: Peter Maydell
  Cc: QEMU Developers, Paolo Bonzini, Liang Li, Amit Shah, Juan Quintela

* Peter Maydell (peter.maydell@linaro.org) wrote:
> On 10 June 2016 at 12:16, Dr. David Alan Gilbert (git)
> <dgilbert@redhat.com> wrote:
> > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> >
> > Hi,
> >   This pair of patches fixes a couple of issues that we found during test.
> > The first is that the configure test is pessimistic when compiled with -O2,
> > the second is that the explicit 4.9 gcc test is a bit coarse; I've removed
> > that test but beefed up the ./configure test to actually use the avx2
> > intrinsics and that fails in the same way as the main code, so it works
> > in the same way as the explicit check but allows older gcc's to work
> > when -save-temps isn't used.
> >
> > Dave
> >
> > v3
> >   Use compile_object rather than compile_prog as suggested by Peter to
> >   hopefully fail on his ccache setup.
> 
> I ran these patches through my build tests and it all compiled OK,
> so the new configure test does correctly say "no AVX" on this setup.

Thanks for checking.

Dave

> 
> thanks
> -- PMM
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH v3 2/2] avx2 configure: Use primitives in test
  2016-06-10 11:16 ` [Qemu-devel] [PATCH v3 2/2] avx2 configure: Use primitives in test Dr. David Alan Gilbert (git)
@ 2016-07-14 13:13   ` Aaron Lindsay
  2016-07-14 13:15     ` Paolo Bonzini
  2016-07-14 13:33     ` Dr. David Alan Gilbert
  0 siblings, 2 replies; 19+ messages in thread
From: Aaron Lindsay @ 2016-07-14 13:13 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git)
  Cc: qemu-devel, pbonzini, peter.maydell, amit.shah, liang.z.li, quintela

On Jun 10 12:16, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> 
> Use the avx2 primitives during the test, thus making sure that the
> compiler and assembler could actually use avx2.
> 
> This also detects the failure case on gcc 4.8.x with -save-temps
> and avoids the need for the gcc version check in cutils.

I'm getting a segfault when running the latest tip compiled with gcc
4.8.4 on Ubuntu 14.04 and I've bisected it to this commit.

# gcc --version
gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4

I'm configuring with:
# ./configure \
    --static \
	--disable-gtk \
	--target-list=aarch64-softmmu

When run under gdb, I get:
Program received signal SIGSEGV, Segmentation fault.
buffer_find_nonzero_offset_ifunc () at ./util/cutils.c:333
333     {
(gdb) bt
#0  buffer_find_nonzero_offset_ifunc () at ./util/cutils.c:333
#1  0x0000000000939c58 in __libc_start_main ()
#2  0x0000000000419337 in _start ()

I confess I don't understand the intricacies here, but I'm willing to
test fixes if you have any ideas for how to make this also work for my
compiler without blindly excluding all gcc < 4.9.

-Aaron

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH v3 2/2] avx2 configure: Use primitives in test
  2016-07-14 13:13   ` Aaron Lindsay
@ 2016-07-14 13:15     ` Paolo Bonzini
  2016-07-14 13:23       ` Peter Maydell
  2016-07-14 13:33     ` Dr. David Alan Gilbert
  1 sibling, 1 reply; 19+ messages in thread
From: Paolo Bonzini @ 2016-07-14 13:15 UTC (permalink / raw)
  To: Aaron Lindsay, Dr. David Alan Gilbert (git)
  Cc: qemu-devel, peter.maydell, amit.shah, liang.z.li, quintela



On 14/07/2016 15:13, Aaron Lindsay wrote:
> On Jun 10 12:16, Dr. David Alan Gilbert (git) wrote:
>> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>>
>> Use the avx2 primitives during the test, thus making sure that the
>> compiler and assembler could actually use avx2.
>>
>> This also detects the failure case on gcc 4.8.x with -save-temps
>> and avoids the need for the gcc version check in cutils.
> 
> I'm getting a segfault when running the latest tip compiled with gcc
> 4.8.4 on Ubuntu 14.04 and I've bisected it to this commit.
> 
> # gcc --version
> gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
> 
> I'm configuring with:
> # ./configure \
>     --static \
> 	--disable-gtk \
> 	--target-list=aarch64-softmmu
> 
> When run under gdb, I get:
> Program received signal SIGSEGV, Segmentation fault.
> buffer_find_nonzero_offset_ifunc () at ./util/cutils.c:333
> 333     {
> (gdb) bt
> #0  buffer_find_nonzero_offset_ifunc () at ./util/cutils.c:333
> #1  0x0000000000939c58 in __libc_start_main ()
> #2  0x0000000000419337 in _start ()
> 
> I confess I don't understand the intricacies here, but I'm willing to
> test fixes if you have any ideas for how to make this also work for my
> compiler without blindly excluding all gcc < 4.9.

Hmm, it's possible that we have to disable ifunc together with --static.

Paolo

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH v3 2/2] avx2 configure: Use primitives in test
  2016-07-14 13:15     ` Paolo Bonzini
@ 2016-07-14 13:23       ` Peter Maydell
  2016-07-14 14:27         ` Aaron Lindsay
  0 siblings, 1 reply; 19+ messages in thread
From: Peter Maydell @ 2016-07-14 13:23 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Aaron Lindsay, Dr. David Alan Gilbert (git),
	QEMU Developers, Amit Shah, Liang Li, Juan Quintela

On 14 July 2016 at 14:15, Paolo Bonzini <pbonzini@redhat.com> wrote:
> On 14/07/2016 15:13, Aaron Lindsay wrote:
>> I'm configuring with:
>> # ./configure \
>>     --static \
>>       --disable-gtk \
>>       --target-list=aarch64-softmmu

> Hmm, it's possible that we have to disable ifunc together with --static.

I'm still tempted to say we should just forbid building the softmmu
binaries with --static, unless somebody has a serious use case for it...

thanks
-- PMM

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH v3 2/2] avx2 configure: Use primitives in test
  2016-07-14 13:13   ` Aaron Lindsay
  2016-07-14 13:15     ` Paolo Bonzini
@ 2016-07-14 13:33     ` Dr. David Alan Gilbert
  2016-07-14 14:18       ` Aaron Lindsay
  1 sibling, 1 reply; 19+ messages in thread
From: Dr. David Alan Gilbert @ 2016-07-14 13:33 UTC (permalink / raw)
  To: Aaron Lindsay
  Cc: qemu-devel, pbonzini, peter.maydell, amit.shah, liang.z.li, quintela

* Aaron Lindsay (alindsay@codeaurora.org) wrote:
> On Jun 10 12:16, Dr. David Alan Gilbert (git) wrote:
> > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> > 
> > Use the avx2 primitives during the test, thus making sure that the
> > compiler and assembler could actually use avx2.
> > 
> > This also detects the failure case on gcc 4.8.x with -save-temps
> > and avoids the need for the gcc version check in cutils.
> 
> I'm getting a segfault when running the latest tip compiled with gcc
> 4.8.4 on Ubuntu 14.04 and I've bisected it to this commit.
> 
> # gcc --version
> gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
> 
> I'm configuring with:
> # ./configure \
>     --static \
> 	--disable-gtk \
> 	--target-list=aarch64-softmmu
> 
> When run under gdb, I get:
> Program received signal SIGSEGV, Segmentation fault.
> buffer_find_nonzero_offset_ifunc () at ./util/cutils.c:333
> 333     {
> (gdb) bt
> #0  buffer_find_nonzero_offset_ifunc () at ./util/cutils.c:333
> #1  0x0000000000939c58 in __libc_start_main ()
> #2  0x0000000000419337 in _start ()
> 
> I confess I don't understand the intricacies here, but I'm willing to
> test fixes if you have any ideas for how to make this also work for my
> compiler without blindly excluding all gcc < 4.9.

Does it work if you configure without the --static?

Dave

> 
> -Aaron
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH v3 2/2] avx2 configure: Use primitives in test
  2016-07-14 13:33     ` Dr. David Alan Gilbert
@ 2016-07-14 14:18       ` Aaron Lindsay
  2016-07-14 15:05         ` Dr. David Alan Gilbert
  0 siblings, 1 reply; 19+ messages in thread
From: Aaron Lindsay @ 2016-07-14 14:18 UTC (permalink / raw)
  To: Dr. David Alan Gilbert
  Cc: peter.maydell, quintela, liang.z.li, qemu-devel, amit.shah, pbonzini

On Jul 14 14:33, Dr. David Alan Gilbert wrote:
> * Aaron Lindsay (alindsay@codeaurora.org) wrote:
> > I'm configuring with:
> > # ./configure \
> >     --static \
> > 	--disable-gtk \
> > 	--target-list=aarch64-softmmu
> 
> Does it work if you configure without the --static?

Yes, it works if I configure without --static.

-Aaron

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH v3 2/2] avx2 configure: Use primitives in test
  2016-07-14 13:23       ` Peter Maydell
@ 2016-07-14 14:27         ` Aaron Lindsay
  2016-07-14 14:35           ` Peter Maydell
  0 siblings, 1 reply; 19+ messages in thread
From: Aaron Lindsay @ 2016-07-14 14:27 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Paolo Bonzini, Juan Quintela, Liang Li,
	Dr. David Alan Gilbert (git),
	QEMU Developers, Amit Shah

On Jul 14 14:23, Peter Maydell wrote:
> On 14 July 2016 at 14:15, Paolo Bonzini <pbonzini@redhat.com> wrote:
> > On 14/07/2016 15:13, Aaron Lindsay wrote:
> >> I'm configuring with:
> >> # ./configure \
> >>     --static \
> >>       --disable-gtk \
> >>       --target-list=aarch64-softmmu
> 
> > Hmm, it's possible that we have to disable ifunc together with --static.
> 
> I'm still tempted to say we should just forbid building the softmmu
> binaries with --static, unless somebody has a serious use case for it...

FWIW, we do find it convenient to be able to compile one binary capable
of running on multiple systems with different (and incompatible) library
versions.

-Aaron

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH v3 2/2] avx2 configure: Use primitives in test
  2016-07-14 14:27         ` Aaron Lindsay
@ 2016-07-14 14:35           ` Peter Maydell
  2016-07-14 19:44             ` Aaron Lindsay
  0 siblings, 1 reply; 19+ messages in thread
From: Peter Maydell @ 2016-07-14 14:35 UTC (permalink / raw)
  To: Aaron Lindsay
  Cc: Paolo Bonzini, Juan Quintela, Liang Li,
	Dr. David Alan Gilbert (git),
	QEMU Developers, Amit Shah

On 14 July 2016 at 15:27, Aaron Lindsay <alindsay@codeaurora.org> wrote:
> On Jul 14 14:23, Peter Maydell wrote:
>> On 14 July 2016 at 14:15, Paolo Bonzini <pbonzini@redhat.com> wrote:
>> > On 14/07/2016 15:13, Aaron Lindsay wrote:
>> >> I'm configuring with:
>> >> # ./configure \
>> >>     --static \
>> >>       --disable-gtk \
>> >>       --target-list=aarch64-softmmu
>>
>> > Hmm, it's possible that we have to disable ifunc together with --static.
>>
>> I'm still tempted to say we should just forbid building the softmmu
>> binaries with --static, unless somebody has a serious use case for it...
>
> FWIW, we do find it convenient to be able to compile one binary capable
> of running on multiple systems with different (and incompatible) library
> versions.

The difficulty here is that the system emulators may call
functions in glibc which do dynamic resolution anyway, and so
"require the shared libraries from the glibc version used for
linking", to quote the linker warning. For the user-only binaries
we can claim we don't make those function calls, but for softmmu
we do.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH v3 2/2] avx2 configure: Use primitives in test
  2016-07-14 14:18       ` Aaron Lindsay
@ 2016-07-14 15:05         ` Dr. David Alan Gilbert
  2016-07-14 19:36           ` Aaron Lindsay
  0 siblings, 1 reply; 19+ messages in thread
From: Dr. David Alan Gilbert @ 2016-07-14 15:05 UTC (permalink / raw)
  To: Aaron Lindsay
  Cc: peter.maydell, quintela, liang.z.li, qemu-devel, amit.shah, pbonzini

* Aaron Lindsay (alindsay@codeaurora.org) wrote:
> On Jul 14 14:33, Dr. David Alan Gilbert wrote:
> > * Aaron Lindsay (alindsay@codeaurora.org) wrote:
> > > I'm configuring with:
> > > # ./configure \
> > >     --static \
> > > 	--disable-gtk \
> > > 	--target-list=aarch64-softmmu
> > 
> > Does it work if you configure without the --static?
> 
> Yes, it works if I configure without --static.

Hmm; I wonder what the best fix is here; we could just disable
it with static; it seems an easy fix assuming very few people
care about the combination of avx2 performance and static,
or we could try and detect the problem/old version.
(it seems fine on a modern Fedora; have you tried using a modern
Ubuntu?)

Dave

> 
> -Aaron
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH v3 2/2] avx2 configure: Use primitives in test
  2016-07-14 15:05         ` Dr. David Alan Gilbert
@ 2016-07-14 19:36           ` Aaron Lindsay
  2016-07-14 19:38             ` [Qemu-devel] [PATCH] avx2 configure: Disable if static build Aaron Lindsay
  0 siblings, 1 reply; 19+ messages in thread
From: Aaron Lindsay @ 2016-07-14 19:36 UTC (permalink / raw)
  To: Dr. David Alan Gilbert
  Cc: peter.maydell, quintela, liang.z.li, qemu-devel, amit.shah, pbonzini

On Jul 14 16:05, Dr. David Alan Gilbert wrote:
> * Aaron Lindsay (alindsay@codeaurora.org) wrote:
> > On Jul 14 14:33, Dr. David Alan Gilbert wrote:
> > > * Aaron Lindsay (alindsay@codeaurora.org) wrote:
> > > > I'm configuring with:
> > > > # ./configure \
> > > >     --static \
> > > > 	--disable-gtk \
> > > > 	--target-list=aarch64-softmmu
> > > 
> > > Does it work if you configure without the --static?
> > 
> > Yes, it works if I configure without --static.
> 
> Hmm; I wonder what the best fix is here; we could just disable
> it with static; it seems an easy fix assuming very few people
> care about the combination of avx2 performance and static,
> or we could try and detect the problem/old version.
> (it seems fine on a modern Fedora; have you tried using a modern
> Ubuntu?)

That seems like a reasonable fix to me. Assuming your intention was to
do this in 'configure', I'll send out a patch shortly.

Unfortunately I haven't been able to try on a 'modern' Ubuntu yet.

-Aaron

--
Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH] avx2 configure: Disable if static build
  2016-07-14 19:36           ` Aaron Lindsay
@ 2016-07-14 19:38             ` Aaron Lindsay
  2016-07-19 19:12               ` Dr. David Alan Gilbert
  0 siblings, 1 reply; 19+ messages in thread
From: Aaron Lindsay @ 2016-07-14 19:38 UTC (permalink / raw)
  To: Dr. David Alan Gilbert, peter.maydell, qemu-devel; +Cc: Aaron Lindsay

This avoids a segfault like the following for at least some 4.8 versions
of gcc when configured with --static if avx2 instructions are also
enabled:

	Program received signal SIGSEGV, Segmentation fault.
	buffer_find_nonzero_offset_ifunc () at ./util/cutils.c:333
	333     {
	(gdb) bt
	#0  buffer_find_nonzero_offset_ifunc () at ./util/cutils.c:333
	#1  0x0000000000939c58 in __libc_start_main ()
	#2  0x0000000000419337 in _start ()

Signed-off-by: Aaron Lindsay <alindsay@codeaurora.org>
---
 configure | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 5ada56d..169aa88 100755
--- a/configure
+++ b/configure
@@ -1788,7 +1788,9 @@ fi
 ##########################################
 # avx2 optimization requirement check
 
-cat > $TMPC << EOF
+
+if test "$static" = "no" ; then
+  cat > $TMPC << EOF
 #pragma GCC push_options
 #pragma GCC target("avx2")
 #include <cpuid.h>
@@ -1801,12 +1803,13 @@ static void *bar_ifunc(void) {return (void*) bar;}
 int foo(void *a) __attribute__((ifunc("bar_ifunc")));
 int main(int argc, char *argv[]) { return foo(argv[0]);}
 EOF
-if compile_object "" ; then
-    if has readelf; then
-        if readelf --syms $TMPO 2>/dev/null |grep -q "IFUNC.*foo"; then
-            avx2_opt="yes"
-        fi
-    fi
+  if compile_object "" ; then
+      if has readelf; then
+          if readelf --syms $TMPO 2>/dev/null |grep -q "IFUNC.*foo"; then
+              avx2_opt="yes"
+          fi
+      fi
+  fi
 fi
 
 #########################################
-- 
Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH v3 2/2] avx2 configure: Use primitives in test
  2016-07-14 14:35           ` Peter Maydell
@ 2016-07-14 19:44             ` Aaron Lindsay
  0 siblings, 0 replies; 19+ messages in thread
From: Aaron Lindsay @ 2016-07-14 19:44 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Paolo Bonzini, Juan Quintela, Liang Li,
	Dr. David Alan Gilbert (git),
	QEMU Developers, Amit Shah

On Jul 14 15:35, Peter Maydell wrote:
> On 14 July 2016 at 15:27, Aaron Lindsay <alindsay@codeaurora.org> wrote:
> > On Jul 14 14:23, Peter Maydell wrote:
> >> On 14 July 2016 at 14:15, Paolo Bonzini <pbonzini@redhat.com> wrote:
> >> > On 14/07/2016 15:13, Aaron Lindsay wrote:
> >> >> I'm configuring with:
> >> >> # ./configure \
> >> >>     --static \
> >> >>       --disable-gtk \
> >> >>       --target-list=aarch64-softmmu
> >>
> >> > Hmm, it's possible that we have to disable ifunc together with --static.
> >>
> >> I'm still tempted to say we should just forbid building the softmmu
> >> binaries with --static, unless somebody has a serious use case for it...
> >
> > FWIW, we do find it convenient to be able to compile one binary capable
> > of running on multiple systems with different (and incompatible) library
> > versions.
> 
> The difficulty here is that the system emulators may call
> functions in glibc which do dynamic resolution anyway, and so
> "require the shared libraries from the glibc version used for
> linking", to quote the linker warning. For the user-only binaries
> we can claim we don't make those function calls, but for softmmu
> we do.

We haven't observed any problems with this approach so far, but your
point is well taken. Perhaps we get what we deserve if we insist on
statically compiling ;-)

-Aaron

-- 
Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH] avx2 configure: Disable if static build
  2016-07-14 19:38             ` [Qemu-devel] [PATCH] avx2 configure: Disable if static build Aaron Lindsay
@ 2016-07-19 19:12               ` Dr. David Alan Gilbert
  2016-07-29 14:22                 ` Peter Maydell
  0 siblings, 1 reply; 19+ messages in thread
From: Dr. David Alan Gilbert @ 2016-07-19 19:12 UTC (permalink / raw)
  To: Aaron Lindsay; +Cc: peter.maydell, qemu-devel

* Aaron Lindsay (alindsay@codeaurora.org) wrote:
> This avoids a segfault like the following for at least some 4.8 versions
> of gcc when configured with --static if avx2 instructions are also
> enabled:
> 
> 	Program received signal SIGSEGV, Segmentation fault.
> 	buffer_find_nonzero_offset_ifunc () at ./util/cutils.c:333
> 	333     {
> 	(gdb) bt
> 	#0  buffer_find_nonzero_offset_ifunc () at ./util/cutils.c:333
> 	#1  0x0000000000939c58 in __libc_start_main ()
> 	#2  0x0000000000419337 in _start ()
> 
> Signed-off-by: Aaron Lindsay <alindsay@codeaurora.org>

It does look like the simplest solution to the problem;

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

Dave

> ---
>  configure | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/configure b/configure
> index 5ada56d..169aa88 100755
> --- a/configure
> +++ b/configure
> @@ -1788,7 +1788,9 @@ fi
>  ##########################################
>  # avx2 optimization requirement check
>  
> -cat > $TMPC << EOF
> +
> +if test "$static" = "no" ; then
> +  cat > $TMPC << EOF
>  #pragma GCC push_options
>  #pragma GCC target("avx2")
>  #include <cpuid.h>
> @@ -1801,12 +1803,13 @@ static void *bar_ifunc(void) {return (void*) bar;}
>  int foo(void *a) __attribute__((ifunc("bar_ifunc")));
>  int main(int argc, char *argv[]) { return foo(argv[0]);}
>  EOF
> -if compile_object "" ; then
> -    if has readelf; then
> -        if readelf --syms $TMPO 2>/dev/null |grep -q "IFUNC.*foo"; then
> -            avx2_opt="yes"
> -        fi
> -    fi
> +  if compile_object "" ; then
> +      if has readelf; then
> +          if readelf --syms $TMPO 2>/dev/null |grep -q "IFUNC.*foo"; then
> +              avx2_opt="yes"
> +          fi
> +      fi
> +  fi
>  fi
>  
>  #########################################
> -- 
> Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc.
> Qualcomm Technologies, Inc. is a member of the
> Code Aurora Forum, a Linux Foundation Collaborative Project.
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH] avx2 configure: Disable if static build
  2016-07-19 19:12               ` Dr. David Alan Gilbert
@ 2016-07-29 14:22                 ` Peter Maydell
  0 siblings, 0 replies; 19+ messages in thread
From: Peter Maydell @ 2016-07-29 14:22 UTC (permalink / raw)
  To: Dr. David Alan Gilbert; +Cc: Aaron Lindsay, QEMU Developers

On 19 July 2016 at 20:12, Dr. David Alan Gilbert <dgilbert@redhat.com> wrote:
> * Aaron Lindsay (alindsay@codeaurora.org) wrote:
>> This avoids a segfault like the following for at least some 4.8 versions
>> of gcc when configured with --static if avx2 instructions are also
>> enabled:
>>
>>       Program received signal SIGSEGV, Segmentation fault.
>>       buffer_find_nonzero_offset_ifunc () at ./util/cutils.c:333
>>       333     {
>>       (gdb) bt
>>       #0  buffer_find_nonzero_offset_ifunc () at ./util/cutils.c:333
>>       #1  0x0000000000939c58 in __libc_start_main ()
>>       #2  0x0000000000419337 in _start ()
>>
>> Signed-off-by: Aaron Lindsay <alindsay@codeaurora.org>
>
> It does look like the simplest solution to the problem;
>
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

Applied to master, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2016-07-29 14:22 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-10 11:16 [Qemu-devel] [PATCH v3 0/2] AVX2 configure fixes Dr. David Alan Gilbert (git)
2016-06-10 11:16 ` [Qemu-devel] [PATCH v3 1/2] Make avx2 configure test work with -O2 Dr. David Alan Gilbert (git)
2016-06-10 11:16 ` [Qemu-devel] [PATCH v3 2/2] avx2 configure: Use primitives in test Dr. David Alan Gilbert (git)
2016-07-14 13:13   ` Aaron Lindsay
2016-07-14 13:15     ` Paolo Bonzini
2016-07-14 13:23       ` Peter Maydell
2016-07-14 14:27         ` Aaron Lindsay
2016-07-14 14:35           ` Peter Maydell
2016-07-14 19:44             ` Aaron Lindsay
2016-07-14 13:33     ` Dr. David Alan Gilbert
2016-07-14 14:18       ` Aaron Lindsay
2016-07-14 15:05         ` Dr. David Alan Gilbert
2016-07-14 19:36           ` Aaron Lindsay
2016-07-14 19:38             ` [Qemu-devel] [PATCH] avx2 configure: Disable if static build Aaron Lindsay
2016-07-19 19:12               ` Dr. David Alan Gilbert
2016-07-29 14:22                 ` Peter Maydell
2016-06-13  9:31 ` [Qemu-devel] [PATCH v3 0/2] AVX2 configure fixes Paolo Bonzini
2016-06-13 10:51 ` Peter Maydell
2016-06-13 10:58   ` Dr. David Alan Gilbert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.