Skip to contentSkip to conversation

Update the avx2 configure test to be compatible with clang

PATCH Superseded Rebecca Cran 3 participants 4 messages Aug 9, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Update the avx2 configure test to be compatible with clang

clang doesn't support the GCC pragma to enable AVX2, but instead requires the command line option -mavx2. Since GCC also supports that, remove the pragma lines and add the -mavx2 option when building the test.

---
 configure | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
configure +1 -3
index 714e7fb6a1..30d6c02ab4 100755
@@ -5392,8 +5392,6 @@ fi
 
 if test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
   cat > $TMPC << EOF
-#pragma GCC push_options
-#pragma GCC target("avx2")
 #include <cpuid.h>
 #include <immintrin.h>
 static int bar(void *a) {
@@ -5402,7 +5400,7 @@ static int bar(void *a) {
 }
 int main(int argc, char *argv[]) { return bar(argv[0]); }
 EOF
-  if compile_object "" ; then
+  if compile_object "-mavx2" ; then
     avx2_opt="yes"
   else
     avx2_opt="no"
Signature · 1 line
2.22.0
#1 lore raw
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series failed the asan build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-fedora V=1 NETWORK=1
time make docker-test-debug@fedora TARGET_LIST=x86_64-softmmu J=14 NETWORK=1 === TEST SCRIPT END ===

  CC      util/qemu-sockets.o
  CC      util/uri.o
  CC      util/notify.o
/tmp/qemu-test/src/util/bufferiszero.c:71:13: error: unknown pragma ignored [-Werror,-Wunknown-pragmas]
#pragma GCC push_options
            ^
/tmp/qemu-test/src/util/bufferiszero.c:72:13: error: unknown pragma ignored [-Werror,-Wunknown-pragmas]
#pragma GCC target("sse2")
            ^
/tmp/qemu-test/src/util/bufferiszero.c:108:13: error: unknown pragma ignored [-Werror,-Wunknown-pragmas]
#pragma GCC pop_options
            ^
/tmp/qemu-test/src/util/bufferiszero.c:116:13: error: unknown pragma ignored [-Werror,-Wunknown-pragmas]
#pragma GCC push_options
            ^
/tmp/qemu-test/src/util/bufferiszero.c:117:13: error: unknown pragma ignored [-Werror,-Wunknown-pragmas]
#pragma GCC target("sse4")
            ^
/tmp/qemu-test/src/util/bufferiszero.c:148:13: error: unknown pragma ignored [-Werror,-Wunknown-pragmas]
#pragma GCC pop_options
            ^
/tmp/qemu-test/src/util/bufferiszero.c:149:13: error: unknown pragma ignored [-Werror,-Wunknown-pragmas]
#pragma GCC push_options
            ^
/tmp/qemu-test/src/util/bufferiszero.c:150:13: error: unknown pragma ignored [-Werror,-Wunknown-pragmas]
#pragma GCC target("avx2")
            ^
/tmp/qemu-test/src/util/bufferiszero.c:187:13: error: unknown pragma ignored [-Werror,-Wunknown-pragmas]
#pragma GCC pop_options
            ^

9 errors generated.

The full log is available at
http://patchew.org/logs/[email protected]/testing.asan/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#2 lore raw
In reply to Rebecca Cran
Quoted 4 lines · Rebecca Cran

clang doesn't support the GCC pragma to enable AVX2, but instead requires the command line option -mavx2. Since GCC also supports that, remove the pragma lines and add the -mavx2 option when building the test.

No, this means we're not testing what we need:

We need to compile exactly one function using avx2.

The other functions should be compiled with sse4 and sse2, respectively, and we choose between them by testing cpuid bits at startup. If you supply -mavx2 to the entire compilation, then the routine that is supposed to use only sse2 will in fact use avx2, and then the runtime selection is moot.

r~

#3 lore raw
Quoted 9 lines · Richard Henderson

No, this means we're not testing what we need:

We need to compile exactly one function using avx2.

The other functions should be compiled with sse4 and sse2, respectively, and we choose between them by testing cpuid bits at startup. If you supply -mavx2 to the entire compilation, then the routine that is supposed to use only sse2 will in fact use avx2, and then the runtime selection is moot.

Oh, sorry, I hadn't fully realized there's runtime selection. Fixing this would require significant rework in that case, so I'll just build with GCC instead for now!

Signature · 1 line
Rebecca Cran